Methods Summary |
---|
public static boolean | compareAlternateLinks(org.apache.lucene.gdata.gom.GOMLink left, org.apache.lucene.gdata.gom.GOMLink right)Compares two links with rel attribute "alternate" Checks if href and type
are equal
if ((left.getType() == null) ^ right.getType() == null
|| (left.getType() == null && right.getType() == null)) {
return false;
} else {
if (!left.getType().equalsIgnoreCase(right.getType()))
return false;
}
if (((left.getHrefLang() == null) ^ right.getHrefLang() == null)
|| (left.getHrefLang() == null && right.getHrefLang() == null)) {
return false;
} else {
if (!left.getHrefLang().equalsIgnoreCase(right.getHrefLang()))
return false;
}
return true;
|
public static java.lang.String | escapeXMLCharacter(java.lang.String aString)Replaces all xml character with the corresponding entity.
- <!ENTITY lt "&#60;">
- <!ENTITY gt ">">
- <!ENTITY amp "&#38;">
- <!ENTITY apos "'">
- <!ENTITY quot """>
see W3C
specification
StringBuilder builder = new StringBuilder();
char[] cs = aString.toCharArray();
for (int i = 0; i < cs.length; i++) {
switch (cs[i]) {
case '<":
builder.append("<");
break;
case '>":
builder.append(">");
break;
case '"":
builder.append(""");
break;
case '\'":
builder.append("'");
break;
case '&":
builder.append("&");
break;
case '\0":
// this breaks some xml serializer like soap serializer -->
// remove it
break;
default:
builder.append(cs[i]);
}
}
return builder.toString();
|
public static java.lang.String | getAbsolutAtomURI(java.lang.String xmlBase, java.lang.String atomUri)
if (atomUri == null)
throw new IllegalArgumentException("atomUri must not be null");
if (atomUri.startsWith("www."))
atomUri = "http://" + atomUri;
URI aUri = new URI(atomUri);
if (xmlBase == null || xmlBase.length() == 0) {
if (!aUri.isAbsolute()) {
throw new URISyntaxException(atomUri,
" -- no xml:base specified atom uri must be an absolute url");
}
}
return atomUri;
|
public static org.apache.lucene.gdata.gom.AtomMediaType | getAtomMediaType(java.lang.String aMediaType)
if (aMediaType == null || !isAtomMediaType(aMediaType))
throw new IllegalArgumentException(
"aMediaType must be a media type and not be null ");
if (aMediaType.endsWith("+xml") || aMediaType.endsWith("/xml"))
return AtomMediaType.XML;
if (aMediaType.startsWith("text/"))
return AtomMediaType.TEXT;
return AtomMediaType.BINARY;
|
public static boolean | isAtomMediaType(java.lang.String aMediaType)
return (aMediaType == null || aMediaType.length() < 3) ? false
: ATOM_MEDIA_TYPE_PATTERN.matcher(aMediaType).matches();
|
public static void | main(java.lang.String[] args)
// String s = new String(
// "<!ENTITY lt \"<\"><!ENTITY gt \">\"><!ENTITY amp
// \"&\"><!ENTITY apos \"'\"><!ENTITY quot \""\">");
// System.out.println(escapeXMLCharacter(s));
//
System.out.println(isAtomMediaType("t/h"));
|