Class StringCodecFactory.NameEncoding
- All Implemented Interfaces:
StringCodec
- Enclosing class:
- StringCodecFactory
Helper class for encoding and decoding node names
Implements the encode and decode routines based on ISO 9075-14:2003 for
node names.It encodes and decode the minimal set to garanty the node names
are jcr valid.
If a character c
is not valid in the node name it is encoded
in the form: '_x' + hexValueOf(c) + '_' (UTF-16). It only
If a node name string is encoded twice or decoded twice it should return the
same string. If a node name string doesn't contain invalid characters the
encode functions should return the string itself. If a string doesn't contain
any encoded chars it should return the string itself. Eg:
- decode(encode(x)) = x
- encode(decode(x)) = x
- encode(encode(x)) = encode(x)
- decode(decode(x)) = decode(x)
- encode(valid_chars) = valid_chars
Qualified name: a qualified name is a combination of a namespace URI and a local part. Instances of this class are used to internally represent the names of JCR content items and other objects within a content repository.
The prefixed JCR name format of a qualified name is specified by section 4.6 of the the JCR 1.0 specification (JSR 170) as follows:
name ::= simplename | prefixedname simplename ::= onecharsimplename | twocharsimplename | threeormorecharname prefixedname ::= prefix ':' localname localname ::= onecharlocalname | twocharlocalname | threeormorecharname onecharsimplename ::= (* Any Unicode character except: '.', '/', ':', '[', ']', '*', ''', '"', '|' or any whitespace character *) twocharsimplename ::= '.' onecharsimplename | onecharsimplename '.' | onecharsimplename onecharsimplename onecharlocalname ::= nonspace twocharlocalname ::= nonspace nonspace threeormorecharname ::= nonspace string nonspace prefix ::= (* Any valid non-empty XML NCName *) string ::= char | string char char ::= nonspace | ' ' nonspace ::= (* Any Unicode character except: '/', ':', '[', ']', '*', ''', '"', '|' or any whitespace character *)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionDecode the name string with the ISO9075 coding standard.final String
encode
(char c) Encode the char to a valid JCR string.final String
Encode the name to a valid JCR name, it is not possible to specify a namespace, any passed namespace prefix will be encoded as well
-
Constructor Details
-
NameEncoding
public NameEncoding()
-
-
Method Details
-
encode
Encode the char to a valid JCR string.
Calling encode multiple times on the same string will return the same result as encoding the string once.
- Parameters:
c
- the char to encode- Returns:
- the encoded char as string
-
encode
Encode the name to a valid JCR name, it is not possible to specify a namespace, any passed namespace prefix will be encoded as well
Calling encode multiple times on the same string will return the same result as encoding the string once.
An IllegalArgumentException is thrown when the name is empty or null.
- Specified by:
encode
in interfaceStringCodec
- Parameters:
name
- the name to encode- Returns:
- the encoded name
-
decode
Decode the name string with the ISO9075 coding standard.Calling decode multiple times on the same string will return the same result as decoding the string once.
- Specified by:
decode
in interfaceStringCodec
- Parameters:
name
- the name to decode- Returns:
- the decoded name
-