Copyright© 2008-2022 Sitevision AB, all rights reserved.
@Requireable(value="EndecUtil") public interface EndecUtil
An instance of the Sitevision class implementing this interface can be obtained via
Utils.getEndecUtil()
.
See Utils
for how to obtain an instance of the Utils
interface.
Modifier and Type | Method and Description |
---|---|
String |
base64decode(String aBase64EncodedString)
Decodes a base64 encoded string (using UTF-8 encoding).
|
byte[] |
base64decodeToBytes(String aBase64EncodedString)
Decodes a base64 encoded string to a byte array (using UTF-8 encoding).
|
String |
base64encode(String aString)
Encodes a string using base64 encoding (using UTF-8 encoding).
|
String |
base64encodeToString(byte[] aBytes)
Encodes a byte array to a base64 encoded string (using UTF-8 encoding).
|
String |
br(String aString)
Converts line breaks to xhtml <br /> elements.
|
String |
decodeURL(String aURL)
Decodes a URL safe String into its original form using the default charset.
|
String |
encodeURL(String aURL)
Encodes a String into its URL safe form using the default charset.
|
String |
escapeIdentifier(String aPrefix,
String anIdentifier)
Escapes/encodes an identifier.
|
String |
escapeJcrName(String aJcrName)
Escapes/encodes a jcr name (property name or node name) that might contain illegal characters.
|
String |
escapeXML(String aString)
Escapes/encodes the characters in a String using XML entities.
|
String |
getBaseSubstitute(String aString)
Replaces characters to their base subtitute.
|
String |
unEscapeHTML4(String aString)
Unescapes/decodes a string containing HTML 4 entities to a string containing the actual Unicode characters corresponding to the entities.
|
String |
unEscapeIdentifier(String aPrefix,
String anIdentifier)
Unescapes/decodes an escaped/encoded identifier.
|
String |
unEscapeJcrName(String aJcrName)
Unescapes/decodes a jcr name (property name or node name) that might be escape/encoded.
|
String |
unEscapeXML(String aString)
Unescapes/decodes a string containing basic XML entities to a string containing the actual Unicode characters corresponding to the entities.
|
String escapeXML(String aString)
Example: "One <br /> & two" -> "One <br /> & two"
aString
- a String
that needs to be escapedString unEscapeXML(String aString)
Supports the 5 basic XML entities (gt, lt, quot, amp, apos) and numerical unicodes (decimal and hex).
Examples:
[ One <br /> & two
] will become:
[ One <br /> & two
]
[ "Hej å hå" är kopieringsskyddat© sägs det
] will become:
[ "Hej å hå" är kopieringsskyddat© sägs det
]
aString
- a String
that contains escaped xml entitiesunEscapeHTML4(String)
String unEscapeHTML4(String aString)
Supports HTML 4.0 entities, including numerical unicodes (decimal and hex).
Examples:
[ One <br /> & two
] will become:
[ One <br /> & two
]
[ "Hej å hå" är kopieringsskyddat© sägs det
] will become:
[ "Hej å hå" är kopieringsskyddat© sägs det
]
aString
- a String
that contains escaped html 4 entitiesunEscapeXML(String)
String encodeURL(String aURL)
Handles the www-form-urlencoded encoding scheme, also misleadingly known as URL encoding
aURL
- the string to convert to a URL safe formnull
if aURL
is null
or can't be encoded.String decodeURL(String aURL)
Handles the www-form-urlencoded encoding scheme, also misleadingly known as URL encoding
aURL
- URL safe String to convert to its original formnull
if aURL
is null
or can't be decoded.String br(String aString)
Example: "Line 1\nLine 2" -> "Line 1<br />Line2"
aString
- a String
to convertString getBaseSubstitute(String aString)
Example: "xml ëBå_$-1205" -> "xmleBa1205"
aString
- a String
that should be base substitutedString escapeJcrName(String aJcrName)
Any operation that includes a JCR name that contains illegal characters must be escaped. For example:
javax.jcr.Node node = ...
javax.jcr.NodeIterator nodeIterator = node.getNodes("aNodeNameThatShouldBeEscaped");
javax.jcr.NodeIterator anotherNodeIterator = node.getNodes("aNodeNameThatShouldBeEscaped/aNodeNameThatShouldBeEscaped");
javax.jcr.Property property = node.getProperty("aPropertyNameThatShouldBeEscaped");
Characters in JCR Names - section 3.2.5.4 of the JSR 283 specification (Java Content Repository 2.0)
Illegal character | Substitution character |
---|---|
* (U+002A) "asterix" |
U+F02A |
/ (U+002F) "slash" |
U+F02F |
: (U+003A) "colon" |
U+F03A |
[ (U+005B) "left bracket" |
U+F05B |
] (U+005D) "right bracket" |
U+F05D |
| (U+007C) "pipe" |
U+F07C |
Some specific names are conflicting with the JCR naming semantics and must also be escaped:
(though, these two "dot-only" expressions would typically be extremely uncommon as names)
Illegal Name | Substitution Name |
---|---|
"." (the JCR Self Notation) |
U+F02E |
".." (the JCR Parent Notation) |
U+F02E and U+F02E |
aJcrName
- a name that should be escaped/encodedunEscapeJcrName(String)
String unEscapeJcrName(String aJcrName)
Any operation that includes getting a JCR name must be unescaped if it contains illegal characters. For example:
javax.jcr.Node node = ...
javax.jcr.Property property = ...
java.lang.String aNameThatNeedsToBeUnEscaped = node.getName();
java.lang.String anotherNameThatNeedsToBeUnEscaped = property.getName();
See escapeJcrName(String)
for escape/unescape characters and names
aJcrName
- a name that might be escaped/encodedescapeJcrName(String)
String base64encode(String aString)
aString
- a String
that should be base64 encodedaString
base64 encoded. Returns null
if aString
is null
base64decode(String)
String base64encodeToString(byte[] aBytes)
aBytes
- a byte array that should be base64 encoded as stringbase64encode(String)
String base64decode(String aBase64EncodedString)
aBase64EncodedString
- a base64 encoded Stringbase64encode(String)
byte[] base64decodeToBytes(String aBase64EncodedString)
aBase64EncodedString
- a base64 encoded Stringbase64decode(String)
String escapeIdentifier(String aPrefix, String anIdentifier)
aPrefix | anIdentifier | Returned |
---|---|---|
null | null | "" |
"" | null | "" |
null | "" | "" |
"" | "" | "" |
"pcx" | null | "pcx" |
null | "pcx" | "pcx" |
"pcx" | "" | "pcx" |
"pcx" | "123" | "pcx123" |
"pcx" | "1.23" | "pcx1_23" |
"pcx" | "1.23.45" | "pcx1_23_45" |
aPrefix
- a prefix added to the resultanIdentifier
- a string idunEscapeIdentifier(String, String)
String unEscapeIdentifier(String aPrefix, String anIdentifier)
aPrefix | anIdentifier | Returned |
---|---|---|
null | null | "" |
"" | null | "" |
null | "" | "" |
"" | "" | "" |
"pcx" | null | "" |
null | "pcx" | "pcx" |
"pcx" | "" | "" |
"pcx" | "pcx123" | "123" |
"pcx" | "pcx1_23" | "1.23" |
"pcx" | "pcx1_23_45" | "1.23.45" |
null | "pcx1_23" | "pcx1.23" |
"" | "pcx1_23" | "pcx1.23" |
"badprefix" | "pcx1_23" | "pcx1.23" |
aPrefix
- a prefix that will be removed from the resultanIdentifier
- a string idescapeIdentifier(String, String)
Sitevision - Portal and Content Management Made Easy
Sitevision is an advanced Java enterprise portal product and a portlet container (JSR 286) that implements Java Content Repository (JSR 283).
Copyright© 2008-2022 Sitevision AB, all rights reserved.