@Override public void internalStartElement(String elemName, HashMap mapMandatory, HashMap mapAllowed) throws SAXException { String attrName; if (mapAllowed.isEmpty()) { return; } attrName = (String) mapMandatory.get("NAME"); // NOI18N if (attrName == null) { attrName = (String) mapMandatory.get("name"); // NOI18N } if (attrName == null) { return; } Iterator it = mapAllowed.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); if (XMLMapAttr.Attr.isValid((String) pair.getKey()) != -1) { XMLMapAttr.Attr attr = XMLMapAttr.createAttributeAndDecode( (String) pair.getKey(), (String) pair.getValue() ); setAttr(fileName.toString(), attrName, attr); } } }
/** * Checks if key is valid and sets key and value * @param key Key of attribute. Defines type of attribute in textual form. * @param value Value of attribute. Defines value of attribute as literal or HEX expression of serialization. */ private final void putEntry(String key, String value) { this.keyIndex = isValid(key); this.value = value.intern(); }
final void maybeAddSerValueComment(PrintWriter pw, String indent) { if (obj != null) { Object modifObj = null; if (obj instanceof ModifiedAttribute) { modifObj = ((Attr) ((ModifiedAttribute) obj).getValue()).getValue(); if (distinguishObject(modifObj) != Attr.isValid("SERIALVALUE")) { //NOI18N return; } } // Important for debugging to know what this stuff really is. // Note this comment is only written to disk when the attr is // first saved; after that successive saves will just know the // ser value and will not print the comment. So look at .nbattrs // immediately after setting something serialized. --jglick pw.print(indent); pw.print("<!-- "); // NOI18N String s = (modifObj != null) ? modifObj.toString() : obj.toString(); if (s.indexOf("--") != -1) { // NOI18N // XML comment no-no. s = s.replace('-', '_'); // NOI18N } pw.print(s); pw.println(" -->"); // NOI18N } }
/** * @param key One of the possible keys: * "bytevalue","shortvalue","intvalue","longvalue","floatvalue","doublevalue","boolvalue","charvalue","stringvalue","methodvalue","serialvalue","urlvalue" * @param value Corresponding value to key in textual form. */ private Attr(String key, String value) { keyIndex = isValid(key); this.value = value.intern(); }
/** * @return key. Key expresses type of this attribute (in textual form) or "" if internal error. */ final String getKey() { String keyArray[] = getAttrTypes(); if (obj != null) return "serialvalue";//back compatibility // NOI18N if (isValid() == -1) return ""; // NOI18N return keyArray[keyIndex]; }
/** * Checks if key is valid * @return Index to array of allowed keys or -1 which means error. */ final int isValid() { String keyArray[] = getAttrTypes(); if (obj != null) return isValid("SERIALVALUE");//back compatibility // NOI18N if (keyIndex >= keyArray.length || keyIndex < 0) return -1; return keyIndex; }
/** * Checks if key is valid and sets key and value * @param key Key of attribute. Defines type of attribute in textual form. * @param value Value of attribute. Defines value of attribute as literal or HEX expression of serialization. */ private final void putEntry(String key, String value) { this.keyIndex = isValid(key); this.value = value.intern(); }
/** * @param key One of the possible keys: * "bytevalue","shortvalue","intvalue","longvalue","floatvalue","doublevalue","boolvalue","charvalue","stringvalue","methodvalue","serialvalue","urlvalue" * @param value Corresponding value to key in textual form. */ private Attr(String key, String value) { keyIndex = isValid(key); this.value = value.intern(); }
if ((index = isValid()) != -1) { try { switch (index) {
String value = amap.getValue(i); if (XMLMapAttr.Attr.isValid(key) != -1) { XMLMapAttr.Attr attr = XMLMapAttr.createAttributeAndDecode(key, value); XMLMapAttr attrMap = topRE.getAttr(true);
} else { if ( (objType = XMLMapAttr.Attr.distinguishObject(value)) == XMLMapAttr.Attr.isValid( "SERIALVALUE"
return isValid("BYTEVALUE"); // NOI18N return isValid("SHORTVALUE"); // NOI18N return isValid("INTVALUE"); // NOI18N return isValid("LONGVALUE"); // NOI18N return isValid("FLOATVALUE"); // NOI18N return isValid("DOUBLEVALUE"); // NOI18N return isValid("BOOLVALUE"); // NOI18N return isValid("CHARVALUE"); // NOI18N return isValid("STRINGVALUE"); // NOI18N return isValid("URLVALUE"); // NOI18N return isValid("SERIALVALUE"); // NOI18N
/**Method for back compatibility; called in write*/ private void transformMe() { int objType; if (obj == null) { return; } Object unObj = unMarshallObjectRecursively(obj); if (unObj != null) { if ((objType = XMLMapAttr.Attr.distinguishObject(unObj)) != XMLMapAttr.Attr.isValid("SERIALVALUE")) { // NOI18N obj = null; putEntry(ALLOWED_ATTR_KEYS[objType], unObj.toString()); } else { String newValue; try { newValue = encodeValue(unObj); } catch (IOException iox) { return; } obj = null; putEntry(ALLOWED_ATTR_KEYS[objType], newValue); } } }
/** * Checks if key is valid * @return Index to array of allowed keys or -1 which means error. */ final int isValid() { String[] keyArray = getAttrTypes(); if (obj != null) { return isValid("SERIALVALUE"); //back compatibility // NOI18N } if ((keyIndex >= keyArray.length) || (keyIndex < 0)) { return -1; } return keyIndex; }
/** * @return key. Key expresses type of this attribute (in textual form) or "" if internal error. */ final String getKey() { String[] keyArray = getAttrTypes(); if (obj != null) { return "serialvalue"; //back compatibility // NOI18N } if (isValid() == -1) { return ""; // NOI18N } return keyArray[keyIndex]; }
/** * @param key One of the possible keys: * "bytevalue","shortvalue","intvalue","longvalue","floatvalue","doublevalue","boolvalue","charvalue","stringvalue","methodvalue","serialvalue","urlvalue" * @param value Corresponding value to key in textual form. */ private Attr(String key, String value) { keyIndex = isValid(key); this.value = value.intern(); }
final String getKeyForPrint() { if ((obj != null) && obj instanceof ModifiedAttribute) { Attr modifAttr = (Attr) ((ModifiedAttribute) obj).getValue(); int keyIdx = Attr.isValid("SERIALVALUE"); //NOI18N if (modifAttr != null) { keyIdx = distinguishObject(modifAttr.getValue()); } String[] keyArray = getAttrTypes(); return keyArray[keyIdx]; } return getKey(); }