private static void collectStructure(Collection<ComponentElement> componentElements, Node node, long parent, DocumentErrorHandler errorHandler) { String id = getAttributeValue(node, DocumentSave.COMPONENTID_ATTR); if (id == null) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < node.getAttributes().getLength(); i++) { sb.append(" "); //NOI18N sb.append(node.getAttributes().item(i)); } errorHandler.addError(NbBundle.getMessage(DocumentLoad.class, "MSG_Wrong_argument") + sb.toString()); //NOI18N return; } long componentid = -1; try { componentid = Long.parseLong(id); } catch (NumberFormatException ex) { errorHandler.addError("{0} {1}", NbBundle.getMessage(DocumentLoad.class, "MSG_Wrong_argument_value"), id); //NOI18N return; } TypeID typeid = TypeID.createFrom(getAttributeValue(node, DocumentSave.TYPEID_ATTR)); componentElements.add(ComponentElement.create(parent, componentid, typeid, node)); Node[] children = getChildNode(node); for (Node child : children) { if (isComponentNode(child)) { collectStructure(componentElements, child, componentid, errorHandler); } } }
TypeID.createFrom (getAttributeValue (node, SUPER_TYPEID_ATTR)), TypeID.createFrom (thisTypeID), Boolean.parseBoolean (getAttributeValue (node, CAN_INSTANTIATE_ATTR)), Boolean.parseBoolean (getAttributeValue (node, CAN_DERIVE_ATTR)) continue; TypeID typeID = TypeID.createFrom (getAttributeValue (node, TYPEID_ATTR)); if (typeID == null) { Debug.warning ("Missing typeID attribute", name); // NOI18N
public static XMLComponentProducer deserialize (String projectType, Document document) { Node rootNode = document.getFirstChild (); if (! COMPONENT_PRODUCER_NODE.equals (rootNode.getNodeName ())) { Debug.warning ("Invalid root node"); // NOI18N return null; } String version = XMLComponentDescriptor.getAttributeValue (rootNode, VERSION_ATTR); if (! VERSION_VALUE_1.equals (version)) { Debug.warning ("Invalid version", version); // NOI18N return null; } String producerID = XMLComponentDescriptor.getAttributeValue (rootNode, PRODUCERID_ATTR); if (producerID == null) { Debug.warning ("Missing producerID attribute"); // NOI18N return null; } String typeID = XMLComponentDescriptor.getAttributeValue (rootNode, MAIN_COMPONENT_TYPEID_ATTR); if (typeID == null) { Debug.warning ("Missing mainComponentTypeID attribute"); // NOI18N return null; } PaletteDescriptor paletteDescriptor = new PaletteDescriptor ( XMLComponentDescriptor.getAttributeValue (rootNode, PREFERRED_CATEGORYID_ATTR), XMLComponentDescriptor.getAttributeValue (rootNode, DISPLAY_NAME_ATTR), XMLComponentDescriptor.getAttributeValue (rootNode, TOOLTIP_ATTR), XMLComponentDescriptor.getAttributeValue (rootNode, SMALL_ICON_ATTR), XMLComponentDescriptor.getAttributeValue (rootNode, LARGE_ICON_ATTR) ); return new XMLComponentProducer (producerID, TypeID.createFrom (typeID), paletteDescriptor); }
TypeID typeid = TypeID.createFrom(getAttributeValue(propertyNode, DocumentSave.TYPEID_ATTR)); String serialized = getAttributeValue(propertyNode, DocumentSave.VALUE_ATTR); propertyElements.add(PropertyElement.create(propertyName, typeid, serialized));