public static class StringCodecFactory.NameEncoding extends Object implements StringCodec
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:
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 and Description |
---|
NameEncoding() |
Modifier and Type | Method and Description |
---|---|
String |
decode(String name)
Decode the name string with the ISO9075 coding standard.
|
String |
encode(char c)
Encode the char to a valid JCR string.
|
String |
encode(String name)
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
|
public final String encode(char c)
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.
c
- the char to encodepublic final String encode(String name)
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.
encode
in interface StringCodec
name
- the name to encodepublic String decode(String name)
Calling decode multiple times on the same string will return the same result as decoding the string once.
decode
in interface StringCodec
name
- the name to decodeCopyright © 2007–2017 Hippo B.V. (http://www.onehippo.com). All rights reserved.