List of usage examples for org.xml.sax Attributes getValue
public abstract String getValue(String qName);
From source file:importer.handler.post.annotate.Annotation.java
/** * Add a start tag to the note body//from w w w .java 2 s. c om * @param localName the name of the element * @param atts its attributes */ public void addStartTag(String localName, Attributes atts) { if (this.body == null) this.body = new StringBuilder(); this.body.append("<"); this.body.append(localName); for (int i = 0; i < atts.getLength(); i++) { if (!atts.getLocalName(i).equals(Splitter.DONE)) { this.body.append(" "); this.body.append(atts.getLocalName(i)); this.body.append("=\""); this.body.append(atts.getValue(i)); this.body.append("\""); } } this.body.append(">"); }
From source file:TestModelBuilder.java
public void startElement(String namespace, String localname, String qname, Attributes atts) throws SAXException { SimpleElement element = null;/*w ww. j ava 2 s .c o m*/ try { element = (SimpleElement) Class.forName(qname).newInstance(); } catch (Exception e) { } if (element == null) element = new SimpleElement(); for (int i = 0; i < atts.getLength(); i++) element.setAttributeValue(atts.getQName(i), atts.getValue(i)); stack.push(element); }
From source file:io.inkstand.scribble.jcr.rules.util.XMLContentHandler.java
/** * Creates a new {@link PropertyDescriptor} from the attributes. * * @param attributes/*from w w w .j av a 2 s. c om*/ * the attributes defining the name and jcrType of the property * * @return a {@link PropertyDescriptor} instance */ private PropertyDescriptor newPropertyDescriptor(final Attributes attributes) { final PropertyDescriptor propDesc = FACTORY.createPropertyDescriptor(); LOG.debug("property name={}", attributes.getValue("name")); LOG.debug("property jcrType={}", attributes.getValue("jcrType")); propDesc.setName(attributes.getValue("name")); propDesc.setJcrType(PropertyValueType.fromValue(attributes.getValue("jcrType"))); return propDesc; }
From source file:fulcrum.xml.Parser.java
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { textBuilder.setLength(0);//w ww .ja v a 2 s . co m Element c = new Element(qName, uri); xPathBuilder.append(FORWARD_SLASH).append(localName); addXPath(xPathBuilder.toString(), c); for (int i = 0; i < attributes.getLength(); i++) { Attribute a = new Attribute(attributes.getQName(i), attributes.getURI(i), attributes.getValue(i)); addXPath(xPathBuilder.toString() + AT + a.getLocalName(), a); c.addAttribute(a); } elements.push(c); }
From source file:net.ontopia.xml.CanonicalPrinter.java
@Override public void startElement(String uri, String localName, String name, Attributes atts) { // first: sort attributes String[] attNames = new String[atts.getLength()]; for (int i = 0; i < atts.getLength(); i++) { attNames[i] = atts.getQName(i);/*from w ww .j a v a 2 s. com*/ } java.util.Arrays.sort(attNames); // then write it out in sorted order writer.print("<" + name); for (int i = 0; i < attNames.length; i++) writer.print(" " + attNames[i] + "=\"" + escape(atts.getValue(attNames[i])) + "\""); writer.print(">"); }
From source file:com.icesoft.faces.webapp.parser.ComponentRuleSet.java
private Attributes clone(Attributes attributes) { Attributes clone = new AttributesImpl(attributes); for (int i = 0; i < clone.getLength(); i++) { String name = attributes.getQName(i); String value = attributes.getValue(name); ((AttributesImpl) clone).setLocalName(i, name); ((AttributesImpl) clone).setValue(i, value); }/* w w w. j a v a 2 s .co m*/ return clone; }
From source file:com.icesoft.faces.webapp.parser.ComponentRuleSet.java
/** * Create clone of attributes./* www . j a v a 2 s . co m*/ * * @param attributes Attributes to clone. * @return Cloned attributes. */ private Attributes clone(Attributes attributes) { Attributes clone = new AttributesImpl(attributes); for (int i = 0; i < clone.getLength(); i++) { String name = attributes.getQName(i); String value = attributes.getValue(name); ((AttributesImpl) clone).setLocalName(i, name); ((AttributesImpl) clone).setValue(i, value); } return clone; }
From source file:jp.gr.java_conf.petit_lycee.subsonico.MethodConstants.java
/*** * ???????//www . j a va2 s . c o m * int,boolean,String,Date?? * @param obj * @param attrs attributes */ private void setValues(Object obj, org.xml.sax.Attributes attrs) { for (int i = 0; i < attrs.getLength(); i++) { try { Field field = getField(obj.getClass(), attrs.getLocalName(i)); field.setAccessible(true); String attr_value = attrs.getValue(i); if (field.getType() == boolean.class) { field.setBoolean(obj, Boolean.valueOf(attr_value)); } else if (field.getType() == int.class) { field.setInt(obj, Integer.parseInt(attr_value)); } else if (field.getType() == String.class) { field.set(obj, attr_value); } else if (field.getType() == Date.class) { String format = "yyyy-MM-dd'T'HH:mm:ss"; field.set(obj, StringUtil.toDate(attr_value, format)); } } catch (Exception ignored) { } } }
From source file:com.granule.json.utils.internal.JSONSAXHandler.java
/** * This function parses an IFix top level element and all its children. *///from w w w .j a va2 s. c o m public void startElement(String namespaceURI, String localName, String qName, Attributes attrs) throws SAXException { if (logger.isLoggable(Level.FINER)) logger.exiting(className, "startElement(String,String,String,org.xml.sax.Attributes)"); Properties props = new Properties(); int attrLength = attrs.getLength(); for (int i = 0; i < attrLength; i++) { props.put(attrs.getQName(i), attrs.getValue(i)); } JSONObject obj = new JSONObject(localName, props); if (this.head == null) { this.head = obj; this.current = head; } else { if (current != null) { this.previousObjects.push(current); this.current.addJSONObject(obj); } this.current = obj; } if (logger.isLoggable(Level.FINER)) logger.exiting(className, "startElement(String,String,String,org.xml.sax.Attributes)"); }
From source file:com.miragedev.mononara.core.io.KanjiHandlerImpl.java
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { super.startElement(uri, localName, qName, attributes); //To change body of overridden methods use File | Settings | File Templates. //System.out.println("Parsing: uri("+uri+") localName("+localName+") qName("+qName+")"); if (qName.equalsIgnoreCase("kanjis")) { if (attributes.getLength() > 0) { numberOfEntry = Integer.parseInt(attributes.getValue("size")); }/*from w w w. j a v a 2 s. c o m*/ } else if (qName.equalsIgnoreCase("kanji")) { parentId = Integer.parseInt(attributes.getValue("id")); Kanji kanji = kanjiDao.findById(parentId); isNew = false; currentTagList = new Vector<String>(); if (kanji == null) { kanji = new Kanji(); kanji.setId(parentId); kanjiDao.save(kanji); isNew = true; } } else if (qName.equalsIgnoreCase("name")) { inName = true; inTag = false; } else if (qName.equalsIgnoreCase("tag")) { inTag = true; inName = false; } }