/** @return true if at lest one attribute changed */ public boolean attacheAttrs(XMLMapAttr attrs) { if ((attrs == null) || attrs.isEmpty()) { return false; } if (foAttrs == null) { foAttrs = new XMLMapAttr(); } Iterator it = attrs.entrySet().iterator(); boolean ch = false; while (it.hasNext()) { Map.Entry attrEntry = (Map.Entry) it.next(); Object prev = foAttrs.put(attrEntry.getKey(), attrEntry.getValue()); ch |= (prev == null && attrEntry.getValue() != null) || !prev.equals(attrEntry.getValue()); } return ch; }
XMLMapAttr.Attr attr = XMLMapAttr.createAttributeAndDecode(key, value); XMLMapAttr attrMap = topRE.getAttr(true); Object retVal = attrMap.put(foName, attr); attrMap.put(foName, retVal);
public Object readAttribute(String attrName) { if (attrName.equals("layers")) { //NOI18N return getLayers(); } if (foAttrs == null) { return null; } FileObject topFO = MultiFileObject.attrAskedFileObject.get(); FileObject f = (topFO == null) ? fo : topFO; MultiFileObject.attrAskedFileObject.set(null); try { Object[] objs = new Object[] { f, attrName }; return foAttrs.get(attrName, objs); } finally { MultiFileObject.attrAskedFileObject.set(topFO); } }
/** Writes itself to XML * @param pw is PrintWriter */ public void writeToXML(PrintWriter pw) /*throws IOException */ { // list of names Iterator it = new TreeSet(keySet()).iterator(); XMLMapAttr.writeHeading(pw); while (it.hasNext()) { String file = (String) it.next(); XMLMapAttr attr = (XMLMapAttr) get(file); if ((attr != null) && !attr.isEmpty()) { attr.write(pw, file, " "); // NOI18N } } XMLMapAttr.writeEnding(pw); }
/** * Sets an attribute to the table. * New added - for Sandwich project (XML format instead of serialization) . * @param fileName - name of file * @param attrName - name of attribute * @param obj - attribute */ final void setAttr(String fileName, String attrName, Object obj) { XMLMapAttr m = (XMLMapAttr) get(fileName); if (m == null) { m = new XMLMapAttr(); //HashMap (7);//XMLMapAttr(); put(fileName, m); } m.put(attrName, obj, false); if ((obj == null) && (m.size() == 1)) { remove(fileName); } // increments the version version++; }
/** implementation of Map.get. But fires Exception to have chance in * DefaultAttributes to catch and annotate*/ Object getAttribute(Object attrName) throws Exception { return getAttribute(attrName, new Object[] { ATTR_FOR.get(), attrName }); }
boolean isHeadingWr = false; if (isEmpty()) { return;
/** * @param p1 is name of attribute * @param p2 is attribute as object * @return previous value associated with specified key, or null if there was no mapping for key. * A null return can also indicate that the HashMap previously associated null with the specified key. */ public synchronized Object put(final Object p1, final Object p2) { return put(p1, p2, true); }
public Enumeration<String> attributes() { if (foAttrs == null) { return Enumerations.empty(); } else { Set<String> s = new HashSet<String>(foAttrs.keySet()); return Collections.enumeration(s); } }
XMLMapAttr getAttr(boolean create) { if (create && (foAttrs == null)) { foAttrs = new XMLMapAttr(); } return foAttrs; }
t.setAttr(arr[1], attrName, XMLMapAttr.createAttribute(objType, value.toString()));
@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); } } }
/** Writes itself to XML * @param pw is PrintWriter */ public void writeToXML (PrintWriter pw) /*throws IOException */{ // list of names Iterator it = new TreeSet(keySet()).iterator(); XMLMapAttr.writeHeading(pw); while (it.hasNext ()) { String file = (String)it.next (); XMLMapAttr attr = (XMLMapAttr)get (file); if (attr != null && !attr.isEmpty ()) { attr.write(pw, file, " ");// NOI18N } } XMLMapAttr.writeEnding(pw); }
/** * Sets an attribute to the table. * New added - for Sandwich project (XML format instead of serialization) . * @param fileName - name of file * @param attrName - name of attribute * @param obj - attribute */ final void setAttr (String fileName, String attrName, Object obj) { XMLMapAttr m = (XMLMapAttr)get (fileName); if (m == null) { m = new XMLMapAttr();//HashMap (7);//XMLMapAttr(); put (fileName, m); } m.put (attrName, obj, false); if (obj == null && m.size() == 1) { remove(fileName); } // increments the version version++; }
/** According to name of attribute returns attribute as object * @param params has sense only for methodvalue invocation; and only 2 parametres will be used * @return attribute, which is hold in XMLMapAttr.Attr or null if such attribute doesn`t exist or isn`t able to construct form String representation */ public Object get(final Object p1, Object[] params) { Object obj; try { obj = getAttribute(p1, params); } catch (Exception e) { obj = null; ExternalUtil.LOG.log(Level.INFO, p1 + Arrays.toString(params), e); } return obj; }
public void initialize(ResourceElem res) { content = res.getContent(); XMLMapAttr tmp = res.getAttr(false); if ((tmp != null) && !tmp.isEmpty()) { foAttrs = tmp; } isFolder = (byte) (res.isFolder() ? 1 : 0); if (content == null) { content = res.getURI(); } setUrlContext(res.getUrlContext()); }
/** * @param p1 is name of attribute * @param p2 is attribute as object * @return previous value associated with specified key, or null if there was no mapping for key. * A null return can also indicate that the HashMap previously associated null with the specified key. */ public synchronized Object put(final Object p1, final Object p2) { return put (p1, p2, true); }
public Enumeration attributes() { if (foAttrs == null) { return org.openide.util.Enumerations.empty(); } else { HashSet s = new HashSet (foAttrs.keySet ()); return Collections.enumeration (s); } }
XMLMapAttr getAttr ( boolean create ) { if (create && foAttrs == null) foAttrs = new XMLMapAttr (); return foAttrs; }
t.setAttr (arr[1], attrName, XMLMapAttr.createAttribute (objType,value.toString()) );