public void push(String value) { // wstaw do kolejki if (_first.getValue() == null) _first.setValue(value); else { Element e = _first; while (e.getNext() != null) e = e.getNext(); e.setNext(new Element(value)); } _size++; }
public void put(Key key, Object value) { Element e = map.get(key); if (e == null) { e = new Element(); e.setState(Element.State.CREATED); e.setValue(value); } else if (e.getState() == Element.State.LOADED) { e.setState(Element.State.UPDATED); } map.put(key, e); }
public void testXmlSerializer() throws Exception { Format root = new DataFormat("root"); Format person = root.addChild("Person", Format.Form.STRUCT); person.setProperty("test1", new Value("prop1")); person.setProperty("test2", new Value(119)); person.setProperty("test3", new Value(true)); person.setProperty("test4", new Value(3.1415926f)); person.addChild("name", Format.Form.FIELD, Type.STRING); Format asset = person.addChild("asset", Format.Form.ARRAYOFSTRUCT); asset.addChild("test", Format.Form.ARRAYOFFIELD, Type.STRING); asset.addChild("name", Format.Form.FIELD, Type.STRING); asset.addChild("price", Format.Form.FIELD, Type.FLOAT); Format name = asset .addChild("vendor", Format.Form.STRUCT) .addChild("name", Format.Form.FIELD, Type.STRING); Element personData = new DataElement(person); Element nameData = personData.addChild("name"); nameData.setValue("James wang"); assertEquals("James wang", nameData.getValue().getString()); Element assetData = personData.addChild("asset"); Element assetDataItem = assetData.addArrayItem(); assetDataItem.addChild("test").addArrayItem().setValue("test collection default index"); assetDataItem.addChild("name").setValue("Mac air book"); assetDataItem.addChild("price").setValue(12000.05f); assetDataItem.addChild("vendor").addChild("name").setValue("Apple"); assetDataItem = assetData.addArrayItem(); assetDataItem.addChild("name").setValue("HP computer"); assetDataItem.addChild("price").setValue(15000.05f); assetDataItem.addChild("vendor").addChild("name").setValue("HP"); ElementXmlSerializer serializer = new ElementXmlSerializer(personData, true); ByteArrayOutputStream baos = new ByteArrayOutputStream(); serializer.write(baos); System.out.println(baos.toString()); }
public void preload(Key key, Object value) { Element e = new Element(); e.setState(Element.State.LOADED); e.setValue(value); map.put(key, e); }