/** * Creates a document name from a string of the form "name" * * @param name The name string to parse. * @throws NumberFormatException if the version part of the name is present but is not a number */ public DataTypeName(String name) { this.name = new Utf8String(name); } public DataTypeName(Utf8Array name) {
/** * Create from a Java-type value * * @param value the value **/ public StringValue(String value) { this.value = new Utf8String(value); } public StringValue(Utf8String value) {
public CaseInsensitiveIdentifier(String s) { this(new Utf8String(s)); } public CaseInsensitiveIdentifier(byte [] utf8) {
public XMLWriter openTag(String s) { return openTag(new Utf8String(s)); } public XMLWriter openTag(Utf8String tag) {
public XMLWriter attribute(String name, Object value) { if (value==null) return this; return attribute(new Utf8String(name), value.toString()); }
public DataTypeIdentifier(AbstractUtf8Array utf8) { this.utf8 = new Utf8String(utf8); verify(utf8.wrap().array()); } public DataTypeIdentifier(byte [] utf8) {
public DataTypeIdentifier(String s) { utf8 = new Utf8String(s); verify(utf8.wrap().array()); } public DataTypeIdentifier(AbstractUtf8Array utf8) {
/** * Create by decoding the value from the given buffer * * @param src buffer where the value is stored **/ StringValue(ByteBuffer src) { int size = src.getInt(); value = new Utf8String(new Utf8Array(src, size)); }
private static boolean verifyFirst(byte c, byte [] identifier) { if (!((c == '_') || ((c >= 'a') && (c <= 'z')))) { throw new IllegalArgumentException("Illegal starting character '" + (char)c + "' of identifier '" + new Utf8String(new Utf8Array(identifier)).toString() +"'."); } return true; } private static boolean verifyAny(byte c, byte [] identifier) {
private static boolean verifyFirst(byte c, byte [] identifier) { if (!((c == '_') || ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')))) { throw new IllegalArgumentException("Illegal starting character '" + (char)c + "' of identifier '" + new Utf8String(new Utf8Array(identifier)).toString() +"'."); } return true; } private static boolean verifyAny(byte c, byte [] identifier) {
private static boolean verifyAny(byte c, byte [] identifier) { if (!((c == '_') || (c == '.') || ((c >= 'a') && (c <= 'z')) || ((c >= '0') && (c <= '9')))) { throw new IllegalArgumentException("Illegal character '" + (char)c + "' of identifier '" + new Utf8String(new Utf8Array(identifier)).toString() +"'."); } return true; }
private static boolean verifyAny(byte c, byte [] identifier) { if ((c >= 'A') && (c <= 'Z')) { throw new IllegalArgumentException("Illegal uppercase character '" + (char)c + "' of identifier '" + new Utf8String(new Utf8Array(identifier)).toString() +"'."); } return true; }
private static boolean verifyAny(byte c, byte [] identifier) { if (!((c == '_') || ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9')))) { throw new IllegalArgumentException("Illegal character '" + (char)c + "' of identifier '" + new Utf8String(new Utf8Array(identifier)).toString() +"'."); } return true; } }
/** * Writes the given string. If markup is us ascii (default), and the wrapped writer encodes in UTF, this will write * the string <b>as is, with no transcoding</b> (for speed). Hence, this should never be used for just any content. * * @return this for consistency */ private final XMLWriter w(String s) { return markupIsAscii ? w(new Utf8String(s)) : w(s); }
private Utf8String deserializeAttributeString() throws DeserializationException { int length = getByte(null); return new Utf8String(parseNullTerminatedString(length)); }
private Utf8String deserializeAttributeString() throws DeserializationException { int length = getByte(null); return new Utf8String(parseNullTerminatedString(length)); }
public DocumentType readDocumentType() { Utf8Array docTypeName = parseNullTerminatedString(); int ignored = getShort(null); // used to hold the version DocumentType docType = manager.getDocumentType(new DataTypeName(docTypeName)); if (docType == null) { throw new DeserializationException("No known document type with name " + new Utf8String(docTypeName).toString()); } return docType; }
public DocumentType readDocumentType() { Utf8Array docTypeName = parseNullTerminatedString(); int ignored = getShort(null); // used to hold the version DocumentType docType = manager.getDocumentType(new DataTypeName(docTypeName)); if (docType == null) { throw new DeserializationException("No known document type with name " + new Utf8String(docTypeName).toString()); } return docType; }
private void writeOpenFieldElement(XMLWriter writer, String relevancyFieldName) { Utf8String utf8 = fieldNameMap.get(relevancyFieldName); if (utf8 == null) { utf8 = new Utf8String(relevancyFieldName); fieldNameMap.put(relevancyFieldName, utf8); } writer.openTag(FIELD).attribute(NAME, utf8); writer.closeStartTag(); }
private void writeOpenFieldElement(XMLWriter writer, String relevancyFieldName) { Utf8String utf8 = fieldNameMap.get(relevancyFieldName); if (utf8 == null) { utf8 = new Utf8String(relevancyFieldName); fieldNameMap.put(relevancyFieldName, utf8); } writer.openTag(FIELD).attribute(NAME, utf8); writer.closeStartTag(); }