Java Code Examples for org.xml.sax.Attributes.getValue()

The following are Jave code examples for showing how to use getValue() of the org.xml.sax.Attributes class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: OpenJSharp   File: SynthParser.java   View Source Code Vote up 6 votes
private void startBindKey(Attributes attributes) throws SAXException {
    if (_inputMapID == null) {
        // Not in an inputmap, bail.
        return;
    }
    if (_style != null) {
        String key = null;
        String value = null;
        for(int i = attributes.getLength() - 1; i >= 0; i--) {
            String aKey = attributes.getQName(i);

            if (aKey.equals(ATTRIBUTE_KEY)) {
                key = attributes.getValue(i);
            }
            else if (aKey.equals(ATTRIBUTE_ACTION)) {
                value = attributes.getValue(i);
            }
        }
        if (key == null || value == null) {
            throw new SAXException(
                "bindKey: you must supply a key and action");
        }
        _inputMapBindings.add(key);
        _inputMapBindings.add(value);
    }
}
 
Example 2
Project: monarch   File: CacheXmlParser.java   View Source Code Vote up 6 votes
private void startPdx(Attributes atts) {
  String readSerialized = atts.getValue(READ_SERIALIZED);
  if (readSerialized != null) {
    cache.setPdxReadSerialized(Boolean.parseBoolean(readSerialized));
  }
  String ignoreUnreadFields = atts.getValue(IGNORE_UNREAD_FIELDS);
  if (ignoreUnreadFields != null) {
    cache.setPdxIgnoreUnreadFields(Boolean.parseBoolean(ignoreUnreadFields));
  }
  String persistent = atts.getValue(PERSISTENT);
  if (persistent != null) {
    cache.setPdxPersistent(Boolean.parseBoolean(persistent));
  }
  String diskStoreName = atts.getValue(DISK_STORE_NAME);
  if (diskStoreName != null) {
    cache.setPdxDiskStore(diskStoreName);
  }
}
 
Example 3
Project: lams   File: ConfigRuleSet.java   View Source Code Vote up 6 votes
public Object createObject(Attributes attributes) {

        // Identify the name of the class to instantiate
        String className = attributes.getValue("className");
        if (className == null) {
            ModuleConfig mc = (ModuleConfig) digester.peek();
            className = mc.getActionFormBeanClass();
        }

        // Instantiate the new object and return it
        Object actionFormBean = null;
        try {
            actionFormBean =
                RequestUtils.applicationInstance(className);
        } catch (Exception e) {
            digester.getLogger().error(
                    "ActionFormBeanFactory.createObject: ", e);
        }

        return actionFormBean;
    }
 
Example 4
Project: apache-tomcat-7.0.73-with-comment   File: Validator.java   View Source Code Vote up 6 votes
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 5
Project: fastAOP   File: ASMContentHandler.java   View Source Code Vote up 6 votes
@Override
public void begin(final String name, final Attributes attrs) {
    String desc = attrs.getValue("desc");
    boolean visible = Boolean.valueOf(attrs.getValue("visible"))
            .booleanValue();
    int typeRef = Integer.parseInt(attrs.getValue("typeRef"));
    TypePath typePath = TypePath.fromString(attrs.getValue("typePath"));

    Object v = peek();
    if (v instanceof ClassVisitor) {
        push(((ClassVisitor) v).visitTypeAnnotation(typeRef, typePath,
                desc, visible));
    } else if (v instanceof FieldVisitor) {
        push(((FieldVisitor) v).visitTypeAnnotation(typeRef, typePath,
                desc, visible));
    } else if (v instanceof MethodVisitor) {
        push(((MethodVisitor) v).visitTypeAnnotation(typeRef, typePath,
                desc, visible));
    }
}
 
Example 6
Project: OpenJSharp   File: EncodingAlgorithmAttributesImpl.java   View Source Code Vote up 6 votes
/**
 * Copy an entire Attributes object.
 *
 * @param atts The attributes to copy.
 */
public void setAttributes(Attributes atts) {
    _length = atts.getLength();
    if (_length > 0) {

        if (_length >= _algorithmData.length) {
            resizeNoCopy();
        }

        int index = 0;
        for (int i = 0; i < _length; i++) {
            _data[index++] = atts.getURI(i);
            _data[index++] = atts.getLocalName(i);
            _data[index++] = atts.getQName(i);
            _data[index++] = atts.getType(i);
            _data[index++] = atts.getValue(i);
            index++;
            _toIndex[i] = false;
            _alphabets[i] = null;
        }
    }
}
 
Example 7
Project: cyberduck   File: CloudberryBookmarkCollection.java   View Source Code Vote up 6 votes
@Override
public void startElement(String name, Attributes attrs) {
    switch(name) {
        case "Settings":
            String type = attrs.getValue("xsi:type");
            switch(type) {
                case "GoogleSettings":
                    current = new Host(protocols.forType(Protocol.Type.googlestorage));
                    break;
                case "S3Settings":
                case "DunkelSettings":
                    current = new Host(protocols.forType(Protocol.Type.s3));
                    break;
                default:
                    log.warn("Unsupported connection type:" + type);
                    break;
            }
            break;
    }
}
 
Example 8
Project: openddr-java   File: DeviceDatasourceHandler.java   View Source Code Vote up 5 votes
private void startDeviceElement(Attributes attributes) {
    device = new Device();
    device.setId(attributes.getValue(ATTRIBUTE_DEVICE_ID));
    if (attributes.getValue(ATTRIBUTE_DEVICE_PARENT_ID) != null) {
        device.setParentId(attributes.getValue(ATTRIBUTE_DEVICE_PARENT_ID));
    }
    properties = new HashMap();
}
 
Example 9
Project: powertext   File: ThemeNULL.java   View Source Code Vote up 5 votes
private static int parseInt(Attributes attrs, String attr,
		int def) {
	int value = def;
	String temp = attrs.getValue(attr);
	if (temp != null) {
		try {
			value = Integer.parseInt(temp);
		} catch (NumberFormatException nfe) {
			nfe.printStackTrace();
		}
	}
	return value;
}
 
Example 10
Project: oscm   File: TechnicalProductImportParser.java   View Source Code Vote up 5 votes
String getValidatedBillingID(Attributes atts, String techProductId)
        throws SAXException {
    String billingID = atts.getValue(ATTRIBUTE_BILLING_IDENTIFIER);
    if (billingID != null) {
        billingID = billingID.trim();
    } else {
        billingID = "";
    }

    return getBillingAdapter(billingID, techProductId)
            .getBillingIdentifier();

}
 
Example 11
Project: incubator-netbeans   File: ExternalTerminalProvider.java   View Source Code Vote up 5 votes
@Override
public void startElement(
        String uri,
        String localName,
        String qName,
        Attributes attributes) throws SAXException {
    accumulator.setLength(0);

    if ("terminaldefinition".equals(qName)) { // NOI18N
        context.push(Context.root);

        String xmlns = attributes.getValue("xmlns"); // NOI18N
        if (xmlns != null) {
            int lastSlash = xmlns.lastIndexOf('/'); // NOI18N
            if (lastSlash >= 0 && (lastSlash + 1 < xmlns.length())) {
                String versionStr = xmlns.substring(lastSlash + 1);
                if (versionStr.length() > 0) {
                    try {
                        version = Integer.parseInt(versionStr);
                    } catch (NumberFormatException ex) {
                        // skip
                        log.fine("Incorrect version information:" + xmlns); // NOI18N
                    }

                    log.log(Level.FINE, "Terminal definition XML version: " + version); // NOI18N
                }
            } else {
                log.fine("Incorrect version information:" + xmlns); // NOI18N
            }
        }
    } else {
        context.push(elementStarted(qName, attributes));
    }
}
 
Example 12
Project: fastAOP   File: ASMContentHandler.java   View Source Code Vote up 5 votes
@Override
public void begin(final String name, final Attributes attrs) {
    int parameter = Integer.parseInt(attrs.getValue("parameter"));
    String desc = attrs.getValue("desc");
    boolean visible = Boolean.valueOf(attrs.getValue("visible"))
            .booleanValue();

    push(((MethodVisitor) peek()).visitParameterAnnotation(parameter,
            desc, visible));
}
 
Example 13
Project: oscm   File: ProductImportParser.java   View Source Code Vote up 5 votes
/**
 * Process a priced event element (get the corresponding event and insert a
 * new priced event).
 * 
 * @param techProduct
 *            the technical product which defines the events.
 * @param product
 *            the product with the price model for the priced event.
 * @param qName
 *            the qualified name (with prefix) of the current element.
 * @param atts
 *            the attributes attached to the current element.
 */
private void processPricedEvent(TechnicalProduct techProduct,
        Product product, String qName, Attributes atts) {
    String type = getMandatoryValue(atts, ATTRIBUTE_TYPE);
    String id = atts.getValue(ATTRIBUTE_ID);
    String price = getMandatoryValue(atts, ATTRIBUTE_PRICE);
    if (isBlank(type) || isBlank(id) || isBlank(price)
            || techProduct == null || product == null) {
        return;
    }

    // find the event
    Event event = null;
    if (type.equals(EventType.PLATFORM_EVENT.toString())
            && id.equals(PlatformEventIdentifier.USER_LOGIN_TO_SERVICE)) {
        event = getPlatformEvent(id);
    } else if (type.equals(EventType.PLATFORM_EVENT.toString())
            && id.equals(PlatformEventIdentifier.USER_LOGOUT_FROM_SERVICE)) {
        event = getPlatformEvent(id);
    } else if (type.equals(EventType.SERVICE_EVENT.toString())) {
        List<Event> events = techProduct.getEvents();
        event = findEvent(events, id);
    } else {
        addError(qName, "Unknown event type '" + type + "'");
    }

    // add the priced event
    if (event != null) {
        PricedEvent pricedEvent = new PricedEvent();
        pricedEvent.setPriceModel(product.getPriceModel());
        pricedEvent.setEvent(event);
        pricedEvent.setEventPrice(new BigDecimal(price));
        persist(pricedEvent);
    } else {
        addError(qName, "Unknown event type:'" + type + "' id:'" + id + "'");
    }
}
 
Example 14
Project: jerrydog   File: MemoryRuleSet.java   View Source Code Vote up 5 votes
/**
 * Process a <code>&lt;user&gt;</code> element from the XML database file.
 *
 * @param attributes The attribute list for this element
 */
public void begin(Attributes attributes) throws Exception {

    String username = attributes.getValue("name");
    if (username == null) {
        username = attributes.getValue("username");
    }
    String password = attributes.getValue("password");
    String roles = attributes.getValue("roles");

    MemoryRealm realm =
        (MemoryRealm) digester.peek(digester.getCount() - 1);
    realm.addUser(username, password, roles);

}
 
Example 15
Project: openjdk-jdk10   File: XMLSchemaInternalizationLogic.java   View Source Code Vote up 5 votes
protected String findExternalResource( String nsURI, String localName, Attributes atts) {
    if( WellKnownNamespace.XML_SCHEMA.equals(nsURI)
    && ("import".equals(localName) || "include".equals(localName) ) )
        return atts.getValue("schemaLocation");
    else
        return null;
}
 
Example 16
Project: apache-tomcat-7.0.73-with-comment   File: Validator.java   View Source Code Vote up 4 votes
@Override
public void visit(Node.TagDirective n) throws JasperException {
    // Note: Most of the validation is done in TagFileProcessor
    // when it created a TagInfo object from the
    // tag file in which the directive appeared.

    // This method does additional processing to collect page info

    Attributes attrs = n.getAttributes();
    for (int i = 0; attrs != null && i < attrs.getLength(); i++) {
        String attr = attrs.getQName(i);
        String value = attrs.getValue(i);

        if ("language".equals(attr)) {
            if (pageInfo.getLanguage(false) == null) {
                pageInfo.setLanguage(value, n, err, false);
            } else if (!pageInfo.getLanguage(false).equals(value)) {
                err.jspError(n, "jsp.error.tag.conflict.language",
                        pageInfo.getLanguage(false), value);
            }
        } else if ("isELIgnored".equals(attr)) {
            if (pageInfo.getIsELIgnored() == null) {
                pageInfo.setIsELIgnored(value, n, err, false);
            } else if (!pageInfo.getIsELIgnored().equals(value)) {
                err.jspError(n, "jsp.error.tag.conflict.iselignored",
                        pageInfo.getIsELIgnored(), value);
            }
        } else if ("pageEncoding".equals(attr)) {
            if (pageEncodingSeen)
                err.jspError(n, "jsp.error.tag.multi.pageencoding");
            pageEncodingSeen = true;
            compareTagEncodings(value, n);
            n.getRoot().setPageEncoding(value);
        } else if ("deferredSyntaxAllowedAsLiteral".equals(attr)) {
            if (pageInfo.getDeferredSyntaxAllowedAsLiteral() == null) {
                pageInfo.setDeferredSyntaxAllowedAsLiteral(value, n,
                        err, false);
            } else if (!pageInfo.getDeferredSyntaxAllowedAsLiteral()
                    .equals(value)) {
                err
                        .jspError(
                                n,
                                "jsp.error.tag.conflict.deferredsyntaxallowedasliteral",
                                pageInfo
                                        .getDeferredSyntaxAllowedAsLiteral(),
                                value);
            }
        } else if ("trimDirectiveWhitespaces".equals(attr)) {
            if (pageInfo.getTrimDirectiveWhitespaces() == null) {
                pageInfo.setTrimDirectiveWhitespaces(value, n, err,
                        false);
            } else if (!pageInfo.getTrimDirectiveWhitespaces().equals(
                    value)) {
                err
                        .jspError(
                                n,
                                "jsp.error.tag.conflict.trimdirectivewhitespaces",
                                pageInfo.getTrimDirectiveWhitespaces(),
                                value);
            }
        }
    }

    // Attributes for imports for this node have been processed by
    // the parsers, just add them to pageInfo.
    pageInfo.addImports(n.getImports());
}
 
Example 17
Project: Phoenicia   File: LocaleParser.java   View Source Code Vote up 4 votes
private void parseMusic(Attributes attributes) throws SAXException {
    Debug.v("Parsing locale music");
    this.locale.music_src = attributes.getValue("src");
}
 
Example 18
Project: incubator-netbeans   File: AutomaticDependencies.java   View Source Code Vote up 4 votes
public void handle_exclusion(final Attributes meta) throws SAXException {
    Exclusion excl = new Exclusion();
    excl.codenamebase = meta.getValue("codenamebase");
    excl.prefix = Boolean.valueOf(meta.getValue("prefix")).booleanValue();
    currentGroup.exclusions.add(excl);
}
 
Example 19
Project: lazycat   File: Validator.java   View Source Code Vote up 4 votes
@Override
public void visit(Node.CustomTag n) throws JasperException {

	TagInfo tagInfo = n.getTagInfo();
	if (tagInfo == null) {
		err.jspError(n, "jsp.error.missing.tagInfo", n.getQName());
	}

	/*
	 * The bodycontent of a SimpleTag cannot be JSP.
	 */
	if (n.implementsSimpleTag() && tagInfo.getBodyContent().equalsIgnoreCase(TagInfo.BODY_CONTENT_JSP)) {
		err.jspError(n, "jsp.error.simpletag.badbodycontent", tagInfo.getTagClassName());
	}

	/*
	 * If the tag handler declares in the TLD that it supports dynamic
	 * attributes, it also must implement the DynamicAttributes
	 * interface.
	 */
	if (tagInfo.hasDynamicAttributes() && !n.implementsDynamicAttributes()) {
		err.jspError(n, "jsp.error.dynamic.attributes.not.implemented", n.getQName());
	}

	/*
	 * Make sure all required attributes are present, either as
	 * attributes or named attributes (<jsp:attribute>). Also make sure
	 * that the same attribute is not specified in both attributes or
	 * named attributes.
	 */
	TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
	String customActionUri = n.getURI();
	Attributes attrs = n.getAttributes();
	int attrsSize = (attrs == null) ? 0 : attrs.getLength();
	for (int i = 0; i < tldAttrs.length; i++) {
		String attr = null;
		if (attrs != null) {
			attr = attrs.getValue(tldAttrs[i].getName());
			if (attr == null) {
				attr = attrs.getValue(customActionUri, tldAttrs[i].getName());
			}
		}
		Node.NamedAttribute na = n.getNamedAttributeNode(tldAttrs[i].getName());

		if (tldAttrs[i].isRequired() && attr == null && na == null) {
			err.jspError(n, "jsp.error.missing_attribute", tldAttrs[i].getName(), n.getLocalName());
		}
		if (attr != null && na != null) {
			err.jspError(n, "jsp.error.duplicate.name.jspattribute", tldAttrs[i].getName());
		}
	}

	Node.Nodes naNodes = n.getNamedAttributeNodes();
	int jspAttrsSize = naNodes.size() + attrsSize;
	Node.JspAttribute[] jspAttrs = null;
	if (jspAttrsSize > 0) {
		jspAttrs = new Node.JspAttribute[jspAttrsSize];
	}
	Hashtable<String, Object> tagDataAttrs = new Hashtable<String, Object>(attrsSize);

	checkXmlAttributes(n, jspAttrs, tagDataAttrs);
	checkNamedAttributes(n, jspAttrs, attrsSize, tagDataAttrs);

	TagData tagData = new TagData(tagDataAttrs);

	// JSP.C1: It is a (translation time) error for an action that
	// has one or more variable subelements to have a TagExtraInfo
	// class that returns a non-null object.
	TagExtraInfo tei = tagInfo.getTagExtraInfo();
	if (tei != null && tei.getVariableInfo(tagData) != null && tei.getVariableInfo(tagData).length > 0
			&& tagInfo.getTagVariableInfos().length > 0) {
		err.jspError("jsp.error.non_null_tei_and_var_subelems", n.getQName());
	}

	n.setTagData(tagData);
	n.setJspAttributes(jspAttrs);

	visitBody(n);
}
 
Example 20
Project: oscm   File: ProductImportParser.java   View Source Code Vote up 3 votes
/**
 * Get a mandatory attribute value. If the attribute value is blank an error
 * message is added to the error string buffer
 * 
 * @param atts
 *            the attributes of the element
 * @param attName
 *            the attribute name
 * 
 * @return the attribute value or null if the value is blank.
 */
private String getMandatoryValue(Attributes atts, String attName) {
    String value = atts.getValue(attName);
    if (isBlank(value)) {
        throw new SaaSSystemException("Missing attribute '" + attName
                + "'.");
    }
    return value;
}