org.xml.sax.Attributes Java Examples

The following examples show how to use org.xml.sax.Attributes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: foreignAttributes.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
    int $ai;
    $uri = $__uri;
    $localName = $__local;
    $qname = $__qname;
    switch($_ngcc_current_state) {
    case 0:
        {
            revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
        }
        break;
    default:
        {
            unexpectedEnterElement($__qname);
        }
        break;
    }
}
 
Example #2
Source File: PayloadElementSniffer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {

    if (bodyStarted) {
        payloadQName = new QName(uri, localName);
        // we have what we wanted - let's skip rest of parsing ...
        throw new SAXException("Payload element found, interrupting the parsing process.");
    }

    // check for both SOAP 1.1/1.2
    if (equalsQName(uri, localName, SOAPConstants.QNAME_SOAP_BODY) ||
            equalsQName(uri, localName, SOAP12Constants.QNAME_SOAP_BODY)) {
        bodyStarted = true;
    }

}
 
Example #3
Source File: DOMBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {
    super.startElement(namespaceURI, localName, qName, atts);

    Element e = getCurrentElement();
    locatorTable.storeStartLocation( e, locator );

    // check if this element is an outer-most <jaxb:bindings>
    if( JAXWSBindingsConstants.JAXWS_BINDINGS.getNamespaceURI().equals(e.getNamespaceURI())
    &&  "bindings".equals(e.getLocalName()) ) {

        // if this is the root node (meaning that this file is an
        // external binding file) or if the parent is XML Schema element
        // (meaning that this is an "inlined" external binding)
        Node p = e.getParentNode();
        if( p instanceof Document) {
            outerMostBindings.add(e);   // remember this value
        }
    }
}
 
Example #4
Source File: SVGParser.java    From microMathematics with GNU General Public License v3.0 6 votes vote down vote up
private void  marker(Attributes attributes) throws SVGParseException
{
   debug("<marker>");

   if (currentElement == null)
      throw new SVGParseException("Invalid document. Root element must be <svg>");
   SVG.Marker  obj = new SVG.Marker();
   obj.document = svgDocument;
   obj.parent = currentElement;
   parseAttributesCore(obj, attributes);
   parseAttributesStyle(obj, attributes);
   parseAttributesConditional(obj, attributes);
   parseAttributesViewBox(obj, attributes);
   parseAttributesMarker(obj, attributes);
   currentElement.addChild(obj);
   currentElement = obj;
}
 
Example #5
Source File: ersSet.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
    int $ai;
    $uri = $__uri;
    $localName = $__local;
    $qname = $__qname;
    switch($_ngcc_current_state) {
    case 0:
        {
            revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
        }
        break;
    default:
        {
            unexpectedEnterElement($__qname);
        }
        break;
    }
}
 
Example #6
Source File: JRChartPlotFactory.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Object createObject(Attributes atts)
{
	int seriesIndex = -1;
	Color color = null;
	
	String seriesNumber = atts.getValue(JRXmlConstants.ATTRIBUTE_seriesOrder);
	if (seriesNumber != null && seriesNumber.length() > 0)
	{
		seriesIndex = Integer.valueOf(seriesNumber);
	}
	String colorName = atts.getValue(JRXmlConstants.ATTRIBUTE_color);
	if (colorName != null && colorName.length() > 0)
	{
		color = JRColorUtil.getColor(colorName, null);
	}
	
	return new JRBaseChartPlot.JRBaseSeriesColor(seriesIndex, color);
}
 
Example #7
Source File: DIDLParser.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    super.startElement(uri, localName, qName, attributes);

    if (!DIDLContent.NAMESPACE_URI.equals(uri)) return;

    if (localName.equals("container")) {

        Container container = createContainer(attributes);
        getInstance().addContainer(container);
        createContainerHandler(container, this);

    } else if (localName.equals("item")) {

        Item item = createItem(attributes);
        getInstance().addItem(item);
        createItemHandler(item, this);

    } else if (localName.equals("desc")) {

        DescMeta desc = createDescMeta(attributes);
        getInstance().addDescMetadata(desc);
        createDescMetaHandler(desc, this);

    }
}
 
Example #8
Source File: ResourceRegistrationHelper.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void readAttributes(String qname, Attributes attributes) throws SAXException {
    properties = new HashMap<String, String>();

    String resourceName = attributes.getValue(nameKey);
    properties.put(nameKey, resourceName);  //NOI18N

    int attrLen = attributes.getLength();
    for (int i = 0; i < attrLen; i++) {
        String name = attributes.getLocalName(i);
        String value = attributes.getValue(i);
        if (name != null && name.length() > 0 && value != null && value.length() > 0) {
            properties.put(name, value);
        }
    }
}
 
Example #9
Source File: SynthParser.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private void startStyle(Attributes attributes) throws SAXException {
    String id = null;

    _style = null;
    for(int i = attributes.getLength() - 1; i >= 0; i--) {
        String key = attributes.getQName(i);
        if (key.equals(ATTRIBUTE_CLONE)) {
            _style = (ParsedSynthStyle)((ParsedSynthStyle)lookup(
                     attributes.getValue(i), ParsedSynthStyle.class)).
                     clone();
        }
        else if (key.equals(ATTRIBUTE_ID)) {
            id = attributes.getValue(i);
        }
    }
    if (_style == null) {
        _style = new ParsedSynthStyle();
    }
    register(id, _style);
}
 
Example #10
Source File: MutableAttrListImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Add the contents of the attribute list to this list.
 *
 * @param atts List of attributes to add to this list
 */
public void addAttributes(Attributes atts)
{

  int nAtts = atts.getLength();

  for (int i = 0; i < nAtts; i++)
  {
    String uri = atts.getURI(i);

    if (null == uri)
      uri = "";

    String localName = atts.getLocalName(i);
    String qname = atts.getQName(i);
    int index = this.getIndex(uri, localName);
    // System.out.println("MutableAttrListImpl#addAttributes: "+uri+":"+localName+", "+index+", "+atts.getQName(i)+", "+this);
    if (index >= 0)
      this.setAttribute(index, uri, localName, qname, atts.getType(i),
                        atts.getValue(i));
    else
      addAttribute(uri, localName, qname, atts.getType(i),
                   atts.getValue(i));
  }
}
 
Example #11
Source File: SortComponentSymbolFontFactory.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setStyle(JRFont font, Attributes atts)
{
	JRDesignFont designFont = (JRDesignFont)font;
		String styleName = atts.getValue(JRXmlConstants.ATTRIBUTE_reportFont);
		
		if (styleName != null)
		{
			JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2);
			Map<String,JRStyle> stylesMap = jasperDesign.getStylesMap();

			if (stylesMap.containsKey(styleName))
			{
				JRStyle style = stylesMap.get(styleName);
				designFont.setStyle(style);
			}
			else
			{
				designFont.setStyleNameReference(styleName);
			}
		}
}
 
Example #12
Source File: FxModelBuilder.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "#0 - attribute name",
    "ERR_unexpectedScriptAttribute=Unexpected attribute in fx:script: {0}"
})
private FxNode handleFxScript(Attributes atts) {
    String ref = null;
    
    for (int i = 0; i < atts.getLength(); i++) {
        String name = atts.getLocalName(i);
         if (!FX_ATTR_REFERENCE_SOURCE.equals(name)) {
            addAttributeError(atts.getQName(i),
                "invalid-script-attribute",
                ERR_unexpectedScriptAttribute(name),
                name
            );
            continue;
        }
        ref = atts.getValue(i);
    }
    return accessor.createScript(ref);
}
 
Example #13
Source File: Validator.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
private String findUri(String prefix, Node n) {

            for (Node p = n; p != null; p = p.getParent()) {
                Attributes attrs = p.getTaglibAttributes();
                if (attrs == null) {
                    continue;
                }
                for (int i = 0; i < attrs.getLength(); i++) {
                    String name = attrs.getQName(i);
                    int k = name.indexOf(':');
                    if (prefix == null && k < 0) {
                        // prefix not specified and a default ns found
                        return attrs.getValue(i);
                    }
                    if (prefix != null && k >= 0
                            && prefix.equals(name.substring(k + 1))) {
                        return attrs.getValue(i);
                    }
                }
            }
            return null;
        }
 
Example #14
Source File: XmlUtils.java    From entity-fishing with Apache License 2.0 6 votes vote down vote up
/**
 * Build a start tag.
 * 
 * @param pTagName
 *            name of the tag.
 * 
 * @param pAtts
 *            the attributes of the tag
 * @return requested tag.
 */
public static String startTag(String pTagName, Attributes pAtts) {
	StringBuilder tag = new StringBuilder();
	tag.append(TAG_START_LOW);
	tag.append(pTagName);
	String name;
	String value;
	for (int i = 0; i < pAtts.getLength(); i++) {
		name = pAtts.getQName(i);
		value = pAtts.getValue(i);
		tag.append(SPACE);
		tag.append(name);
		tag.append(EQUALS);
		tag.append(QUOTE);
		tag.append(value);
		tag.append(QUOTE);
	}
	tag.append(TAG_START_SUP);
	return tag.toString();
}
 
Example #15
Source File: SynthParser.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private void startImageIcon(Attributes attributes) throws SAXException {
 String path = null;
 String id = null;

 for(int i = attributes.getLength() - 1; i >= 0; i--) {
     String key = attributes.getQName(i);

     if (key.equals(ATTRIBUTE_ID)) {
         id = attributes.getValue(i);
     }
     else if (key.equals(ATTRIBUTE_PATH)) {
         path = attributes.getValue(i);
     }
 }
 if (path == null) {
     throw new SAXException("imageIcon: you must specify a path");
 }
 register(id, new LazyImageIcon(getResource(path)));
}
 
Example #16
Source File: ExtensibleXmlParser.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
/**
 * Start a configuration node.
 *
 * @param tagName
 *            Tag name.
 * @param attrs
 *            Tag attributes.
 */
public void startElementBuilder(final String tagName,
                                final Attributes attrs) {

    this.attrs = attrs;

    this.characters = new StringBuilder();

    final Element element = this.document.createElement( tagName );

    //final DefaultConfiguration config = new DefaultConfiguration( tagName );

    final int numAttrs = attrs.getLength();

    for ( int i = 0; i < numAttrs; ++i ) {
        element.setAttribute( attrs.getLocalName( i ),
                              attrs.getValue( i ) );
    }

    if ( this.configurationStack.isEmpty() ) {
        this.configurationStack.addLast( element );
    } else {
        ((Element) this.configurationStack.getLast()).appendChild( element );
        this.configurationStack.addLast( element );
    }
}
 
Example #17
Source File: SynthParser.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void startGraphics(Attributes attributes) throws SAXException {
    SynthGraphicsUtils graphics = null;

    for(int i = attributes.getLength() - 1; i >= 0; i--) {
        String key = attributes.getQName(i);
        if (key.equals(ATTRIBUTE_IDREF)) {
            graphics = (SynthGraphicsUtils)lookup(attributes.getValue(i),
                                             SynthGraphicsUtils.class);
        }
    }
    if (graphics == null) {
        throw new SAXException("graphicsUtils: you must supply an idref");
    }
    if (_style != null) {
        _style.setGraphicsUtils(graphics);
    }
}
 
Example #18
Source File: JRGenericElementFactory.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Object createObject(Attributes attrs) throws Exception
{
	JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2);
	JRDesignGenericElement element = new JRDesignGenericElement(jasperDesign);
	
	EvaluationTimeEnum evaluationTime = EvaluationTimeEnum.getByName(attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime));
	if (evaluationTime != null)
	{
		element.setEvaluationTime(evaluationTime);
	}
	
	if (element.getEvaluationTimeValue() == EvaluationTimeEnum.GROUP)
	{
		String groupName = attrs.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup);
		if (groupName != null)
		{
			element.setEvaluationGroupName(groupName);
		}
	}
	
	return element;
}
 
Example #19
Source File: SheetHandler.java    From autopoi with Apache License 2.0 6 votes vote down vote up
@Override
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
	// 置空
	lastContents = "";
	// c => 单元格
	if ("c".equals(name)) {
		// 如果下一个元素是 SST 的索引,则将nextIsString标记为true
		String cellType = attributes.getValue("t");
		if ("s".equals(cellType)) {
			type = CellValueType.String;
			return;
		}
		// 日期格式
		cellType = attributes.getValue("s");
		if ("1".equals(cellType)) {
			type = CellValueType.Date;
		} else if ("2".equals(cellType)) {
			type = CellValueType.Number;
		}
	} else if ("t".equals(name)) {// 当元素为t时
		type = CellValueType.TElement;
	}

}
 
Example #20
Source File: DefinitionHandler.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
public Object start(String uri,
                    String localName,
                    Attributes attrs,
                    ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder( localName,
                                attrs );
    
    
    String packageName = attrs.getValue( "package" );
    String name = attrs.getValue( "name" );
    
    emptyAttributeCheck( localName,
                         "package",
                         packageName,
                         parser );
    
    emptyAttributeCheck( localName,
                         "name",
                         name,
                         parser );
    DefinitionHandler.DefinitionHandlerData data = new DefinitionHandlerData(packageName, name);
    
    return data;
}
 
Example #21
Source File: SchemaContentHandler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void fillXMLAttributes(Attributes atts) {
    fAttributes.removeAllAttributes();
    final int attrCount = atts.getLength();
    for (int i = 0; i < attrCount; ++i) {
        fillQName(fAttributeQName, atts.getURI(i), atts.getLocalName(i), atts.getQName(i));
        String type = atts.getType(i);
        fAttributes.addAttributeNS(fAttributeQName, (type != null) ? type : XMLSymbols.fCDATASymbol, atts.getValue(i));
        fAttributes.setSpecified(i, true);
    }
}
 
Example #22
Source File: DeviceIdHandler.java    From freeacs with MIT License 5 votes vote down vote up
public void startElement(
    String namespaceURI, String localName, String qualifiedName, Attributes attributes) {
  currTextContent = new StringBuilder();
  if (DEVICE_ID_TAG.equals(localName)) {
    didStruct = new DeviceIdStruct();
  }
}
 
Example #23
Source File: XmlParserElement.java    From ghidra with Apache License 2.0 5 votes vote down vote up
XmlParserElement(String name, Attributes attrs, int lineNum) {
	isStart = true;
	this.name = name.toUpperCase();
	int count = attrs.getLength();
	for (int i = 0; i < count; i++) {
		attrsMap.put(attrs.getQName(i), attrs.getValue(i));
	}
	this.lineNum = lineNum;
}
 
Example #24
Source File: ASMContentHandler.java    From awacs with Apache License 2.0 5 votes vote down vote up
@Override
public void begin(final String name, final Attributes attrs) {
    String desc = attrs.getValue("desc");
    boolean visible = Boolean.valueOf(attrs.getValue("visible"))
            .booleanValue();

    Object v = peek();
    if (v instanceof ClassVisitor) {
        push(((ClassVisitor) v).visitAnnotation(desc, visible));
    } else if (v instanceof FieldVisitor) {
        push(((FieldVisitor) v).visitAnnotation(desc, visible));
    } else if (v instanceof MethodVisitor) {
        push(((MethodVisitor) v).visitAnnotation(desc, visible));
    }
}
 
Example #25
Source File: JerseyLibraryHelper.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    if ("server".equals(qName)) { // NOI18N
        isServer= true;
        version = Version.fromDottedNotationWithFallback(attributes.getValue("version")); // NOI18N
        serverJars = new ArrayList<ServerJar>();
    } else if ("jar".equals(qName)) { // NOI18N
        String filename = attributes.getValue("name"); // NOI18N
        String groupId = attributes.getValue("groupId"); // NOI18N
        String artifactId = attributes.getValue("artifactId"); // NOI18N
        String jarVersion = attributes.getValue("version"); // NOI18N
        serverJars.add(new ServerJar(filename, groupId, artifactId, jarVersion));
    }
}
 
Example #26
Source File: TransformerHandlerImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Implements org.xml.sax.ContentHandler.startElement()
 * Receive notification of the beginning of an element.
 */
@Override
public void startElement(String uri, String localName,
                         String qname, Attributes attributes)
    throws SAXException
{
    _handler.startElement(uri, localName, qname, attributes);
}
 
Example #27
Source File: SynthParser.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private void startBind(Attributes attributes) throws SAXException {
    ParsedSynthStyle style = null;
    String path = null;
    int type = -1;

    for(int i = attributes.getLength() - 1; i >= 0; i--) {
        String key = attributes.getQName(i);

        if (key.equals(ATTRIBUTE_STYLE)) {
            style = (ParsedSynthStyle)lookup(attributes.getValue(i),
                                              ParsedSynthStyle.class);
        }
        else if (key.equals(ATTRIBUTE_TYPE)) {
            String typeS = attributes.getValue(i).toUpperCase();

            if (typeS.equals("NAME")) {
                type = DefaultSynthStyleFactory.NAME;
            }
            else if (typeS.equals("REGION")) {
                type = DefaultSynthStyleFactory.REGION;
            }
            else {
                throw new SAXException("bind: unknown type " + typeS);
            }
        }
        else if (key.equals(ATTRIBUTE_KEY)) {
            path = attributes.getValue(i);
        }
    }
    if (style == null || path == null || type == -1) {
        throw new SAXException("bind: you must specify a style, type " +
                               "and key");
    }
    try {
        _factory.addStyle(style, path, type);
    } catch (PatternSyntaxException pse) {
        throw new SAXException("bind: " + path + " is not a valid " +
                               "regular expression");
    }
}
 
Example #28
Source File: CloverLogParser.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private int getInt(Attributes attributes, String name) {
    int i = -1;
    try {
        i = Integer.parseInt(attributes.getValue(name));
    } catch (NumberFormatException exc) {
        // ignored
    }
    return i;
}
 
Example #29
Source File: SchemaParser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String namespaceURI,
        String localName,
        String qName,
        Attributes atts) throws SAXException {
    ++level;
}
 
Example #30
Source File: AbstractLDMLHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private boolean pushIfIgnored(String qName, Attributes attributes) {
    if (isIgnored(attributes) || currentContainer instanceof IgnoredContainer) {
        pushIgnoredContainer(qName);
        return true;
    }
    return false;
}