synchronized Object put(final Object p1, final Object p2, boolean decode) { if ((p1 == null) || !(p1 instanceof String)) { return null; } Object[] keyValuePair = ModifiedAttribute.translateInto((String) p1, p2); String key = (String) keyValuePair[0]; Object value = keyValuePair[1]; Object toStore; if (value == null) { toStore = null; } else if (value instanceof Attr) { toStore = value; } else if (value instanceof Method && key.startsWith("methodvalue:")) { // NOI18N Method m = (Method)value; key = key.substring("methodvalue:".length()); // NOI18N toStore = new Attr("methodvalue", m.getDeclaringClass().getName() + '.' + m.getName()); // NOI18N } else if (value instanceof Class && key.startsWith("newvalue:")) { // NOI18N Class<?> c = (Class<?>)value; key = key.substring("newvalue:".length()); // NOI18N toStore = new Attr("newvalue", c.getName()); // NOI18N } else { toStore = new Attr(value); } if (decode) { key = Attr.decode(key).intern(); } return map.put(key, toStore); }
if ((index = isValid()) != -1) { try { switch (index) { return value; case 9: return methodValue(value, params).invoke(); case 10: return decodeValue(value); case 11: return new URL(value);
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 } }
if (obj != null) return obj;//back compatibility if ((index = isValid()) != -1) { try { switch(index) { return value; case 9: return methodValue (value,params); case 10: return decodeValue(value); case 11: return new URL(value);
if (obj != null) return obj;//back compatibility if ((index = isValid()) != -1) { try { switch(index) { return value; case 9: return methodValue (value,params); case 10: return decodeValue(value); case 11: return new URL(value);
t.setAttr (arr[1], attrName, null); // clear the attribute }else { if ((objType = XMLMapAttr.Attr.distinguishObject (value)) == XMLMapAttr.Attr.isValid("SERIALVALUE") ) { // NOI18N t.setAttr (arr[1], attrName, value);//change value instead of marshall
Attr attr = (Attr)entry.getValue(); if (attrName == null || attr == null || attrName.length() == 0 || attr.isValid() == -1 ) { if (attrName != null && attrName.length() != 0 && (attr == null || attr.isValid() == -1)) { entryIter.remove (); pw.println(blockPrefix+blockPrefix+"<attr name=\""+attr.getAttrNameForPrint (attrName)+"\" "+ attr.getKeyForPrint ()+"=\""+attr.getValueForPrint()+"\"/>");// NOI18N attr.maybeAddSerValueComment(pw,blockPrefix+blockPrefix);
Attr attr = (Attr)entry.getValue(); if (attrName == null || attr == null || attrName.length() == 0 || attr.isValid() == -1 ) { if (attrName != null && attrName.length() != 0 && (attr == null || attr.isValid() == -1)) { entryIter.remove (); pw.println(blockPrefix+blockPrefix+"<attr name=\""+attr.getAttrNameForPrint (attrName)+"\" "+ attr.getKeyForPrint ()+"=\""+attr.getValueForPrint()+"\"/>");// NOI18N attr.maybeAddSerValueComment(pw,blockPrefix+blockPrefix);
t.setAttr (arr[1], attrName, null); // clear the attribute }else { if ((objType = XMLMapAttr.Attr.distinguishObject (value)) == XMLMapAttr.Attr.isValid("SERIALVALUE") ) { // NOI18N t.setAttr (arr[1], attrName, value);//change value instead of marshall
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 } }
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 } }
/**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); } } }
/**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 static int isValid(String key) { int index = -1,i; String strArray[] = getAttrTypes(); String trimmedKey = key.trim(); for (i = 0; i < strArray.length;i++) { if (trimmedKey.equalsIgnoreCase(strArray[i]) == true) { index = i; break; } } return index; } }
/** * Checks if key is valid * @return Index to array of allowed keys or -1 which means error. */ final static int isValid(String key) { int index = -1,i; String strArray[] = getAttrTypes(); String trimmedKey = key.trim(); for (i = 0; i < strArray.length;i++) { if (trimmedKey.equalsIgnoreCase(strArray[i]) == true) { index = i; break; } } return index; } }
static String encode(String inStr) { try { inStr = org.openide.xml.XMLUtil.toAttributeValue(inStr); } catch (Exception ignore) {} StringBuffer outStr = new StringBuffer(6*inStr.length()); for (int i = 0; i < inStr.length(); i++) { if (Character.isISOControl(inStr.charAt(i)) || isEncodedChar(i, inStr)) { outStr.append(encodeChar(inStr.charAt(i))); continue; } outStr.append(inStr.charAt(i)); } return outStr.toString(); }
static Attr createAttribute (int index, String value) { return new Attr(index, value); } /** According to name of attribute returns attribute as object
static String encode(String inStr) { try { inStr = org.openide.xml.XMLUtil.toAttributeValue(inStr); } catch (Exception ignore) {} StringBuffer outStr = new StringBuffer(6*inStr.length()); for (int i = 0; i < inStr.length(); i++) { if (Character.isISOControl(inStr.charAt(i)) || isEncodedChar(i, inStr)) { outStr.append(encodeChar(inStr.charAt(i))); continue; } outStr.append(inStr.charAt(i)); } return outStr.toString(); }
final String getValueForPrint() { if (obj != null) { Attr modifAttr = null; if (obj instanceof ModifiedAttribute) modifAttr = (Attr)((ModifiedAttribute)obj).getValue (); return (modifAttr != null) ? encode(modifAttr.getValue ()) : encode(getValue ()); } return (value != null)?encode(value) : ""; // NOI18N }