Java 类org.dom4j.Attribute 实例源码

项目:iBase4J-Common    文件:XmlUtil.java   
/**
 * Element to map
 * @param e
 * @param map
 */
public static void element2Map(Element e, Map<String, Object> map) {
    List<Object> list = e.elements();
    if (e.attributeCount() > 0) {
        for (Object attri : e.attributes()) {
            Attribute at = (Attribute)attri;
            map.put(at.getName(), at.getValue());
        }
    }
    if (list.size() < 1 && DataUtil.isEmpty(e.getText())) {
        return;
    } else if (list.size() < 1 && !DataUtil.isEmpty(e.getText())) {
        map.put("text", e.getText());
    }
    for (Object aList : list) {
        Element iter = (Element)aList;
        Map<String, Object> cMap = new HashMap<String, Object>();
        element2Map(iter, cMap);
        map.put(iter.getName(), cMap);
    }
}
项目:automat    文件:XmlUtil.java   
/**
 * Element to map
 * 
 * @param e
 * @return
 */
public static void element2Map(Element e, Map<String, Object> map) {
    List<Object> list = e.elements();
    if (e.attributeCount() > 0) {
        for (Object attri : e.attributes()) {
            Attribute at = (Attribute) attri;
            map.put(at.getName(), at.getValue());
        }
    }
    if (list.size() < 1 && DataUtil.isEmpty(e.getText())) {
        return;
    } else if (list.size() < 1 && !DataUtil.isEmpty(e.getText())) {
        map.put("text", e.getText());
    }
    for (Object aList : list) {
        Element iter = (Element) aList;
        Map<String, Object> cMap = new HashMap<String, Object>();
        element2Map(iter, cMap);
        map.put(iter.getName(), cMap);
    }
}
项目:parabuild-ci    文件:Binder.java   
private static int getOptimisticLockMode(Attribute olAtt) throws MappingException {

    if (olAtt==null) return Versioning.OPTIMISTIC_LOCK_VERSION;
    String olMode = olAtt.getValue();
    if ( olMode==null || "version".equals(olMode) ) {
        return Versioning.OPTIMISTIC_LOCK_VERSION;
    }
    else if ( "dirty".equals(olMode) ) {
        return Versioning.OPTIMISTIC_LOCK_DIRTY;
    }
    else if ( "all".equals(olMode) ) {
        return Versioning.OPTIMISTIC_LOCK_ALL;
    }
    else if ( "none".equals(olMode) ) {
        return Versioning.OPTIMISTIC_LOCK_NONE;
    }
    else {
        throw new MappingException("Unsupported optimistic-lock style: " + olMode);
    }
}
项目:joai-project    文件:SchemaProps.java   
public void init (Document  schemaDoc) {
    rootElement = schemaDoc.getRootElement();

    if (rootElement == null) {
        prtln ("SchemaProps ERROR: rootElement not found");
        return;
    }

    setProp ("namespace", rootElement.getNamespace());

    setDefaultProps ();

    for (Iterator i=rootElement.attributeIterator();i.hasNext();) {
        Attribute att = (Attribute)i.next();
        setProp (att.getName(), att.getValue());
    }
}
项目:parabuild-ci    文件:Binder.java   
public static void bindColumn(Element node, Column model, boolean isNullable) {
    Attribute lengthNode = node.attribute("length");
    if (lengthNode!=null) model.setLength( Integer.parseInt( lengthNode.getValue() ) );
    Attribute nullNode = node.attribute("not-null");
    model.setNullable( (nullNode!=null) ?
        !StringHelper.booleanValue( nullNode.getValue() ) :
        isNullable
    );
    Attribute unqNode = node.attribute("unique");
    model.setUnique( unqNode!=null && StringHelper.booleanValue( unqNode.getValue() ) );
    model.setCheckConstraint( node.attributeValue("check") );
    //Attribute qtNode = node.attribute("quote");
    //model.setQuoted( qtNode!=null && StringHelper.booleanValue( qtNode.getValue() ) );
    Attribute typeNode = node.attribute("sql-type");
    model.setSqlType( (typeNode==null) ? null : typeNode.getValue() );
}
项目:atlas    文件:ManifestFileUtils.java   
/**
 * Update the attributes of element
 *
 * @param element
 * @param properties
 */
private static void updateElement(Element element, Map<String, String> properties) {
    for (Map.Entry<String, String> entry : properties.entrySet()) {
        String key = entry.getKey();
        if (key.startsWith("tools:")) {
            continue;
        }
        String keyNoPrefix = key;
        String[] values = StringUtils.split(key, ":");
        if (values.length > 1) {
            keyNoPrefix = values[1];
        }
        if (null == entry.getValue()) {
            continue;
        } else {
            Attribute attribute = element.attribute(keyNoPrefix);
            if (null != attribute) {
                attribute.setValue(entry.getValue());
            } else {
                element.addAttribute(key, entry.getValue());
            }
        }
    }
}
项目:atlas    文件:ManifestFileUtils.java   
/**
 * Update the plug-in's minSdkVersion and targetSdkVersion
 *
 * @param androidManifestFile
 * @throws IOException
 * @throws DocumentException
 */
public static String getVersionName(File androidManifestFile) throws IOException, DocumentException {
    SAXReader reader = new SAXReader();
    String versionName = "";
    if (androidManifestFile.exists()) {
        Document document = reader.read(androidManifestFile);// Read the XML file
        Element root = document.getRootElement();// Get the root node
        if ("manifest".equalsIgnoreCase(root.getName())) {
            List<Attribute> attributes = root.attributes();
            for (Attribute attr : attributes) {
                if (StringUtils.equalsIgnoreCase(attr.getName(), "versionName")) {
                    versionName = attr.getValue();
                }
            }
        }
    }
    return versionName;
}
项目:atlas    文件:ManifestFileUtils.java   
public static String getVersionCode(File androidManifestFile) throws IOException, DocumentException {
    SAXReader reader = new SAXReader();
    String versionCode = "";
    if (androidManifestFile.exists()) {
        Document document = reader.read(androidManifestFile);// Read the XML file
        Element root = document.getRootElement();// Get the root node
        if ("manifest".equalsIgnoreCase(root.getName())) {
            List<Attribute> attributes = root.attributes();
            for (Attribute attr : attributes) {
                if (StringUtils.equalsIgnoreCase(attr.getName(), "versionCode")) {
                    versionCode = attr.getValue();
                }
            }
        }
    }
    return versionCode;
}
项目:parabuild-ci    文件:Binder.java   
private static void initOuterJoinFetchSetting(Element node, Fetchable model) {
    Attribute jfNode = node.attribute("outer-join");
    if ( jfNode==null ) {
        model.setOuterJoinFetchSetting(OuterJoinLoader.AUTO);
    }
    else {
        String eoj = jfNode.getValue();
        if ( "auto".equals(eoj) ) {
            model.setOuterJoinFetchSetting(OuterJoinLoader.AUTO);
        }
        else {
            model.setOuterJoinFetchSetting(
                "true".equals(eoj) ? OuterJoinLoader.EAGER : OuterJoinLoader.LAZY
            );
        }
    }
}
项目:lams    文件:HbmBinder.java   
private static String getClassTableName(
        PersistentClass model,
        Element node,
        String schema,
        String catalog,
        Table denormalizedSuperTable,
        Mappings mappings) {
    Attribute tableNameNode = node.attribute( "table" );
    String logicalTableName;
    String physicalTableName;
    if ( tableNameNode == null ) {
        logicalTableName = StringHelper.unqualify( model.getEntityName() );
        physicalTableName = getNamingStrategyDelegate( mappings ).determineImplicitPrimaryTableName(
                model.getEntityName(),
                model.getJpaEntityName()
        );
    }
    else {
        logicalTableName = tableNameNode.getValue();
        physicalTableName = getNamingStrategyDelegate( mappings ).toPhysicalTableName( logicalTableName );
    }
    mappings.addTableBinding( schema, catalog, logicalTableName, physicalTableName, denormalizedSuperTable );
    return physicalTableName;
}
项目:lams    文件:HbmBinder.java   
private static OptimisticLockStyle getOptimisticLockStyle(Attribute olAtt) throws MappingException {
    if ( olAtt == null ) {
        return OptimisticLockStyle.VERSION;
    }

    final String olMode = olAtt.getValue();
    if ( olMode == null || "version".equals( olMode ) ) {
        return OptimisticLockStyle.VERSION;
    }
    else if ( "dirty".equals( olMode ) ) {
        return OptimisticLockStyle.DIRTY;
    }
    else if ( "all".equals( olMode ) ) {
        return OptimisticLockStyle.ALL;
    }
    else if ( "none".equals( olMode ) ) {
        return OptimisticLockStyle.NONE;
    }
    else {
        throw new MappingException( "Unsupported optimistic-lock style: " + olMode );
    }
}
项目:xpath-to-xml    文件:Dom4jNavigatorSpi.java   
@Override
public <T> T process(T xml, Iterable<Effect> effects) throws XmlBuilderException {
    if (!canHandle(xml)) {
        throw new IllegalArgumentException("XML model is not supported");
    }
    final Node xmlNode = (Node) xml;
    final Dom4jNode<?> node;
    switch (xmlNode.getNodeType()) {
        case Node.DOCUMENT_NODE:
            node = new Dom4jDocument((Document) xmlNode);
            break;
        case Node.ELEMENT_NODE:
            node = new Dom4jElement((Element) xmlNode);
            break;
        case Node.ATTRIBUTE_NODE:
            node = new Dom4jAttribute((Attribute) xmlNode);
            break;
        default:
            throw new IllegalArgumentException("XML node type is not supported");
    }
    final Navigator<Dom4jNode> navigator = new Dom4jNavigator(xmlNode);
    for (Effect effect : effects) {
        effect.perform(navigator, node);
    }
    return xml;
}
项目:iBase4J    文件:XmlUtil.java   
/**
 * Element to map
 * 
 * @param e
 * @return
 */
public static void element2Map(Element e, Map<String, Object> map) {
    List<Object> list = e.elements();
    if (e.attributeCount() > 0) {
        for (Object attri : e.attributes()) {
            Attribute at = (Attribute) attri;
            map.put(at.getName(), at.getValue());
        }
    }
    if (list.size() < 1 && DataUtil.isEmpty(e.getText())) {
        return;
    } else if (list.size() < 1 && !DataUtil.isEmpty(e.getText())) {
        map.put("text", e.getText());
    }
    for (Object aList : list) {
        Element iter = (Element) aList;
        Map<String, Object> cMap = new HashMap<String, Object>();
        element2Map(iter, cMap);
        map.put(iter.getName(), cMap);
    }
}
项目:Divinity_Original_Sin_2_zhCN    文件:DOS2ToMap.java   
@Override
public Map toMap(Document document) {
  Map<String, String> m = new HashMap<String, String>();
  /**
   * <contentList> <content contentuid=
   * "h00007224gb454g4b8bgb762g7865d9ee3dbb">如果不是这样的话!哈,开玩笑啦,我们在一起很合适,就像面包上的果酱。你想和我组队吗?我敢说你们需要一点野兽风味!</content>
   * <content contentuid="h0001d8b9g13d6g4605g85e9g708fe1e537c8">定制</content> </contentList>
   */
  // 获取根节点元素对象
  Element root = document.getRootElement();
  // 子节点
  List<Element> list = root.elements();
  // 使用递归
  Iterator<Element> iterator = list.iterator();
  while (iterator.hasNext()) {
    Element e = iterator.next();
    Attribute attribute = e.attribute("contentuid");
    m.put(attribute.getValue(), e.getText());
  }
  return m;
}
项目:unitimes    文件:LowercaseTableNames.java   
protected void writeAttributes(Element element) throws IOException {
    for (int i = 0, size = element.attributeCount(); i < size; i++) {
        Attribute attribute = element.attribute(i);
           char quote = format.getAttributeQuoteCharacter();
           if (element.attributeCount() > 2) {
               writePrintln();
               indent();
               writer.write(format.getIndent());
           } else {
            writer.write(" ");
           }
           writer.write(attribute.getQualifiedName());
           writer.write("=");
           writer.write(quote);
           writeEscapeAttributeEntities(attribute.getValue());
           writer.write(quote);
    }
}
项目:parabuild-ci    文件:Binder.java   
public static void bindSimpleValue(Element node, SimpleValue model, boolean isNullable, String path, Mappings mappings) 
throws MappingException {
    model.setType( getTypeFromXML(node) );

    Attribute formulaNode = node.attribute("formula");
    if (formulaNode!=null) {
        Formula f = new Formula();
        f.setFormula( formulaNode.getText() );
        model.setFormula(f);
    }
    else {
        bindColumns(node, model, isNullable, true, path, mappings);
    }

    Attribute fkNode = node.attribute("foreign-key");
    if (fkNode!=null) model.setForeignKeyName( fkNode.getValue() );
}
项目:parabuild-ci    文件:Binder.java   
public static void bindManyToOne(Element node, ManyToOne model, String path, boolean isNullable, Mappings mappings) 
throws MappingException {
    bindColumns(node, model, isNullable, true, path, mappings);
    initOuterJoinFetchSetting(node, model);

    Attribute ukName = node.attribute("property-ref");
    if (ukName!=null) model.setReferencedPropertyName( ukName.getValue() );

    Attribute classNode = node.attribute("class");
    if (classNode!=null) {
        try {
            model.setType( TypeFactory.manyToOne( 
                ReflectHelper.classForName( getClassName(classNode, mappings) ), 
                model.getReferencedPropertyName()
            ) );
        }
        catch (Exception e) {
            throw new MappingException( "Could not find class: " + classNode.getValue() );
        }
    }

    Attribute fkNode = node.attribute("foreign-key");
    if (fkNode!=null) model.setForeignKeyName( node.attributeValue("foreign-key") );
}
项目:Reer    文件:Dom4JUtility.java   
public static boolean getAttributeAsBoolean(Element element, String attributeName, boolean defaultValue) {
    Attribute attribute = element.attribute(attributeName);
    if (attribute == null) {
        return defaultValue;
    }

    return "true".equals(attribute.getValue());
}
项目:iBase4J-Common    文件:XmlUtil.java   
/**
 * 将XML规范的字符串转为List对象(XML基于节点属性值的方式)
 * 
 * @param pStrXml 传入的符合XML格式规范的字符串
 * @return list 返回List对象
 */
public static final List parseXml2List(String pStrXml) {
    List lst = new ArrayList();
    String strTitle = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    Document document = null;
    try {
        if (pStrXml.indexOf("<?xml") < 0) pStrXml = strTitle + pStrXml;
        document = DocumentHelper.parseText(pStrXml);
    } catch (DocumentException e) {
        logger.error("==开发人员请注意:==\n将XML格式的字符串转换为XML DOM对象时发生错误啦!" + "\n详细错误信息如下:", e);
    }
    // 获取到根节点
    Element elRoot = document.getRootElement();
    // 获取根节点的所有子节点元素
    Iterator elIt = elRoot.elementIterator();
    while (elIt.hasNext()) {
        Element el = (Element)elIt.next();
        Iterator attrIt = el.attributeIterator();
        Map map = new HashMap();
        while (attrIt.hasNext()) {
            Attribute attribute = (Attribute)attrIt.next();
            map.put(attribute.getName().toLowerCase(), attribute.getData());
        }
        lst.add(map);
    }
    return lst;
}
项目:alfresco-repository    文件:ModelPermissionEntry.java   
public void initialise(Element element, NamespacePrefixResolver nspr, PermissionModel permissionModel)
{
    Attribute recipientAttribute = element.attribute(RECIPIENT);
    if (recipientAttribute != null)
    {
        recipient = recipientAttribute.getStringValue();
    }
    else
    {
        recipient = null;
    }

    Attribute accessAttribute = element.attribute(ACCESS);
    if (accessAttribute != null)
    {
        if (accessAttribute.getStringValue().equalsIgnoreCase(ALLOW))
        {
            access = AccessStatus.ALLOWED;
        }
        else if (accessAttribute.getStringValue().equalsIgnoreCase(DENY))
        {
            access = AccessStatus.DENIED;
        }
        else
        {
            throw new PermissionModelException("The default permission must be deny or allow");
        }
    }
    else
    {
        access = AccessStatus.DENIED;
    }


    Element permissionReferenceElement = element.element(PERMISSION_REFERENCE);
    QName typeQName = QName.createQName(permissionReferenceElement.attributeValue(TYPE), nspr);
    String name = permissionReferenceElement.attributeValue(NAME);
    permissionReference = PermissionReferenceImpl.getPermissionReference(typeQName, name);
}
项目:GraphicsViewJambi    文件:ImportSumoNetwork.java   
/**
 * Manage all Attribute in a Node
 * 
 * @param node
 *      Node to Manage
 * @param subNode   
 *      Sub Node or not
 */
@SuppressWarnings("unchecked")
private void manageAttributeInfo(final Element node, final boolean subNode)
{
    final String startVorString =  (subNode == false) ? "! Start Node --  ": "! Start SubNode --  "; 
    final String startHinString =  (subNode == false) ? "  -- Start Node ! ": "  -- Start SubNode !"; 
    final String endVorString =  (subNode == false) ? "! End Node --  ": "! End SubNode --  "; 
    final String endHinString =  (subNode == false) ? "  -- End Node !": "  -- End SubNode !"; 

    System.out.println("! ----------------------------------------------- !");
    System.out.println(startVorString + node.getName() + startHinString);
    final List<Attribute> list = node.attributes();
    for (final Attribute attr : list)
    {
        //System.out.println(attr.getText() + "\n" );
        System.out.println("  = > " + attr.getName() + " = " + attr.getValue() + ";" );
        //Do something to match related information in Node

    }

    if (!(node.getTextTrim().equals("")))
    {
        System.out.println("Text: " + node.getText());
    }
    System.out.println(endVorString + node.getName() + endHinString);
    System.out.println("! ----------------------------------------------- !\n");
}
项目:bdf2    文件:AbstractConverter.java   
protected void buildCommonGraphCellElement(Element element,Element targetElement){
    for(Object obj:element.attributes()){
        Attribute attr=(Attribute)obj;
        String name=attr.getName();
        if(name.equals("name") || name.equals("g")){
            continue;
        }
        targetElement.addAttribute(attr.getName(),attr.getValue());
    }
}
项目:alfresco-repository    文件:NodePermission.java   
public void initialise(Element element, NamespacePrefixResolver nspr, PermissionModel permissionModel)
{
   Attribute nodeRefAttribute = element.attribute(NODE_REF);
   if(nodeRefAttribute != null)
   {
       nodeRef = new NodeRef(nodeRefAttribute.getStringValue());
   }

   Attribute inheritFromParentAttribute = element.attribute(INHERIT_FROM_PARENT);
   if(inheritFromParentAttribute != null)
   {
       inheritPermissionsFromParent = Boolean.parseBoolean(inheritFromParentAttribute.getStringValue());
   }
   else
   {
       inheritPermissionsFromParent = true;
   }

   // Node Permissions Entry

   for (Iterator npit = element.elementIterator(NODE_PERMISSION); npit.hasNext(); /**/)
   {
       Element permissionEntryElement = (Element) npit.next();
       ModelPermissionEntry permissionEntry = new ModelPermissionEntry(nodeRef);
       permissionEntry.initialise(permissionEntryElement, nspr, permissionModel);
       permissionEntries.add(permissionEntry);
   }

}
项目:alfresco-repository    文件:GlobalPermissionEntry.java   
public void initialise(Element element, NamespacePrefixResolver nspr, PermissionModel permissionModel)
{
    Attribute authorityAttribute = element.attribute(AUTHORITY);
    if(authorityAttribute != null)
    {
        authority = authorityAttribute.getStringValue();
    }
    Attribute permissionAttribute = element.attribute(PERMISSION);
    if(permissionAttribute != null)
    {
        permissionReference = permissionModel.getPermissionReference(null, permissionAttribute.getStringValue());
    }

}
项目:automat    文件:XmlUtil.java   
/**
 * 将XML规范的字符串转为List对象(XML基于节点属性值的方式)
 * 
 * @param pStrXml 传入的符合XML格式规范的字符串
 * @return list 返回List对象
 */
public static final List parseXml2List(String pStrXml) {
    List lst = new ArrayList();
    String strTitle = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    Document document = null;
    try {
        if (pStrXml.indexOf("<?xml") < 0)
            pStrXml = strTitle + pStrXml;
        document = DocumentHelper.parseText(pStrXml);
    } catch (DocumentException e) {
        log.error("==开发人员请注意:==\n将XML格式的字符串转换为XML DOM对象时发生错误啦!" + "\n详细错误信息如下:", e);
    }
    // 获取到根节点
    Element elRoot = document.getRootElement();
    // 获取根节点的所有子节点元素
    Iterator elIt = elRoot.elementIterator();
    while (elIt.hasNext()) {
        Element el = (Element) elIt.next();
        Iterator attrIt = el.attributeIterator();
        Map map = new HashMap();
        while (attrIt.hasNext()) {
            Attribute attribute = (Attribute) attrIt.next();
            map.put(attribute.getName().toLowerCase(), attribute.getData());
        }
        lst.add(map);
    }
    return lst;
}
项目:ats-framework    文件:XmlNode.java   
public XmlNode( XmlNode parent, Element node ) {

        this.node = node;

        Namespace nodeNamespace = node.getNamespace();
        if (nodeNamespace != null && !StringUtils.isNullOrEmpty(nodeNamespace.getPrefix())) {
            this.name = nodeNamespace.getPrefix() + ":" + node.getName();
        } else {
            this.name = node.getName();
        }

        this.attributes = new TreeMap<>();
        for (int i = 0; i < node.attributes().size(); i++) {
            Attribute att = node.attribute(i);
            this.attributes.put(att.getName(), att.getValue());
        }

        this.value = this.node.getTextTrim();

        this.parent = parent;

        this.children = new ArrayList<>();
        List<Element> childrenElements = this.node.elements();
        for (Element child : childrenElements) {
            if (child.getNodeType() == Node.ELEMENT_NODE) {
                this.children.add(new XmlNode(this, child));
            }
        }
    }
项目:joai-project    文件:DleseCollectionFileIndexingWriter.java   
/**
 *  Gets the URL to the collection's scope statement.
 *
 * @return                The URL to the collection's scope statement, or null if none.
 * @exception  Exception  If error
 */
protected String getScopeUrl() throws Exception {
    List nodes = getDom4jDoc().selectNodes("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='policies']/*[local-name()='policy'][@type='Collection scope']/@url");
    if (nodes == null || nodes.size() == 0)
        return null;
    Attribute attrib = (Attribute) nodes.get(0);
    return attrib.getValue();
}
项目:joai-project    文件:DleseCollectionFileIndexingWriter.java   
/**
 *  Gets the URL to the collection's review process statement.
 *
 * @return                The URL to the collection's review process statement.
 * @exception  Exception  If error
 */
protected String getReviewProcessUrl() throws Exception {
    List nodes = getDom4jDoc().selectNodes("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='reviewProcess']/@url");
    if (nodes.size() > 1)
        prtln("More than one review process URL!");
    if (nodes.size() == 0)
        return null;
    Attribute attrib = (Attribute) nodes.get(0);
    return attrib.getValue();
}
项目:joai-project    文件:DleseCollectionFileIndexingWriter.java   
/**
 *  Gets the format of the records in this collection.
 *
 * @return                The records format.
 * @exception  Exception  If error
 */
protected String getFormatOfRecords() throws Exception {
    List nodes = getDom4jDoc().selectNodes("/*[local-name()='collectionRecord']/*[local-name()='access']/*[local-name()='key']/@libraryFormat");
    if (nodes.size() != 1)
        throw new Exception("Unable to get format of records. Wrong number of elements: " + nodes.size());
    Attribute attrib = (Attribute) nodes.get(0);
    return attrib.getValue();
}
项目:joai-project    文件:DleseCollectionFileIndexingWriter.java   
/**
 *  Gets the status of the collection based on the values in the collection-level record.
 *
 * @param  doc  A dlese_collect XML Document
 * @return      The currentCollectionStatus value
 */
public final static String getCurrentCollectionStatus(org.dom4j.Document doc) {
    List nodes = doc.selectNodes("/*[local-name()='collectionRecord']/*[local-name()='approval']/*[local-name()='collectionStatuses']/*[local-name()='collectionStatus']");

    if (nodes == null || nodes.size() == 0)
        return "Error: no collectionStatus elements found in the XML";

    Collections.sort(nodes, new CollectionAccessionStatusComparator());

    Element collectionStatus = (Element) nodes.get(0);
    Attribute collecitonState = collectionStatus.attribute("state");

    return collecitonState.getText();
}
项目:parabuild-ci    文件:Filter.java   
private Matcher getMatcher(Element element) throws FilterException {
    // These will be either BugCode, Method, or Or elements.
    String name = element.getName();
    if (name.equals("BugCode")) {
        return new BugCodeMatcher(element.valueOf("@name"));
    } else if (name.equals("Method")) {
        Attribute nameAttr = element.attribute("name");
        Attribute paramsAttr = element.attribute("params");
        Attribute returnsAttr = element.attribute("returns");

        if (nameAttr == null)
            throw new FilterException("Missing name attribute in Method element");

        if ((paramsAttr != null || returnsAttr != null) && (paramsAttr == null || returnsAttr == null))
            throw new FilterException("Method element must have both params and returns attributes if either is used");

        if (paramsAttr == null)
            return new MethodMatcher(nameAttr.getValue());
        else
            return new MethodMatcher(nameAttr.getValue(), paramsAttr.getValue(), returnsAttr.getValue());
    } else if (name.equals("Or")) {
        OrMatcher orMatcher = new OrMatcher();
        Iterator i = element.elementIterator();
        while (i.hasNext()) {
            orMatcher.addChild(getMatcher((Element) i.next()));
        }
        return orMatcher;
    } else
        throw new FilterException("Unknown element: " + name);
}
项目:joai-project    文件:StructureWalker.java   
/**
 *  Gets the path attribute of the StructureWalker object
 *
 * @param  a  Description of the Parameter
 * @return    The path value
 */
public String getPath(Attribute a) {
    prtln("getPath: attribute: " + a.asXML(), 1);
    prtln(" ... attributeName: " + a.getName(), 1);
    prtln(" ... qualifiedName: " + a.getQualifiedName(), 1);
    Element parent = a.getParent();
    if (parent == null) {
        prtln(" ... parent is null!", 1);
    }
    // return getPath((Node) a);
    return getPath(parent) + "/@" + a.getQualifiedName();
}
项目:joai-project    文件:SchemaReader.java   
/**
 *  Determines the targetNamespace of the schema document. If a "targetNamespace" is explicitly declared, then
 this is returned. Otherwise, the "defaultTargetNamespaceURI" is used.
 *
 * @param  defaultTargetNamespaceURI  NOT YET DOCUMENTED
 * @return                            The targetNamespace value
 */
private String getTargetNamespaceUri(String defaultTargetNamespaceURI) {
    Attribute tnsAttribute = root.attribute("targetNamespace");
    if (tnsAttribute != null)
        return tnsAttribute.getText();
    else
        return defaultTargetNamespaceURI;
}
项目:parabuild-ci    文件:Binder.java   
private static String getClassName(Attribute att, Mappings model) {
    String result = att.getValue();
    if (result==null) return null;
    if ( result.indexOf('.')<0 && model.getDefaultPackage()!=null ) {
        result = model.getDefaultPackage() + StringHelper.DOT + result;
    }
    return result;
}
项目:joai-project    文件:SchemEditForm.java   
/**
 *  Return true if the node specified by key exists in the instance document
 *  and it has a required attribute in the instance document.
 *
 * @param  key  a jsp-encoded xpath
 * @return      The nodeExistsWithRequiredAttribute value
 */
public String getNodeExistsWithRequiredAttribute(String key) {
    String xpath = XPathUtils.decodeXPath(key);
    Node node = docMap.selectSingleNode(xpath);
    if (node == null) {
        return FALSE;
    }
    if (node.getNodeType() != Node.ELEMENT_NODE) {
        return FALSE;
    }
    Element element = (Element) node;
    if (element.attributes().isEmpty()) {
        return FALSE;
    }

    /* check attributes for a required one */
    for (Iterator i = element.attributeIterator(); i.hasNext(); ) {
        Attribute attribute = (Attribute) i.next();
        String attPath = xpath + "/@" + attribute.getQualifiedName();
        SchemaNode schemaNode = this.schemaHelper.getSchemaNode(attPath);
        if (schemaNode == null) {
            // prtln ("schemaNode not found for attribute (" + attPath + ")");
            continue;
        }
        if (schemaNode.isRequired())
            return TRUE;
    }
    return FALSE;
}
项目:gen_code    文件:ConfigParser.java   
/**
 * 将指定节点的属性设置到对象里面
 * @param obj 对象
 * @param element 节点
 * @param tempflag 模板化标识
 * @return 返回结果
 */
public static <T> T fillObj(T obj, Element element,boolean tempflag){
    if(element!=null){
        List<Attribute> attributes = element.attributes();
        for(Attribute a:attributes){
            AnalysisObject.invokeSetter(obj,a.getName(),
                    tempflag?FreeMarkerUtil.render(a.getValue()):a.getValue());
        }
    }
    return obj;
}
项目:atlas    文件:ManifestFileUtils.java   
private static void fillFullClazzName(Element root, String packageName, String type) {
    List<? extends Node> applicatNodes = root.selectNodes("//" + type);
    for (Node node : applicatNodes) {
        Element element = (Element)node;
        Attribute attribute = element.attribute("name");
        if (attribute != null) {
            if (attribute.getValue().startsWith(".")) {
                attribute.setValue(packageName + attribute.getValue());
            }
        }
    }
}
项目:lams    文件:HbmBinder.java   
private static void bindImport(Element importNode, Mappings mappings) {
    String className = getClassName( importNode.attribute( "class" ), mappings );
    Attribute renameNode = importNode.attribute( "rename" );
    String rename = ( renameNode == null ) ?
                    StringHelper.unqualify( className ) :
                    renameNode.getValue();
    LOG.debugf( "Import: %s -> %s", rename, className );
    mappings.addImport( className, rename );
}
项目:lams    文件:HbmBinder.java   
public static void bindClass(Element node, PersistentClass persistentClass, Mappings mappings,
        java.util.Map inheritedMetas) throws MappingException {
    // transfer an explicitly defined entity name
    // handle the lazy attribute
    Attribute lazyNode = node.attribute( "lazy" );
    boolean lazy = lazyNode == null ?
            mappings.isDefaultLazy() :
            "true".equals( lazyNode.getValue() );
    // go ahead and set the lazy here, since pojo.proxy can override it.
    persistentClass.setLazy( lazy );

    String entityName = node.attributeValue( "entity-name" );
    if ( entityName == null ) entityName = getClassName( node.attribute("name"), mappings );
    if ( entityName==null ) {
        throw new MappingException( "Unable to determine entity name" );
    }
    persistentClass.setEntityName( entityName );
    persistentClass.setJpaEntityName( StringHelper.unqualify( entityName ) );

    bindPojoRepresentation( node, persistentClass, mappings, inheritedMetas );
    bindDom4jRepresentation( node, persistentClass, mappings, inheritedMetas );
    bindMapRepresentation( node, persistentClass, mappings, inheritedMetas );

    Iterator itr = node.elementIterator( "fetch-profile" );
    while ( itr.hasNext() ) {
        final Element profileElement = ( Element ) itr.next();
        parseFetchProfile( profileElement, mappings, entityName );
    }

    bindPersistentClassCommonValues( node, persistentClass, mappings, inheritedMetas );
}
项目:lams    文件:HbmBinder.java   
private static boolean isCallable(Element element, boolean supportsCallable)
        throws MappingException {
    Attribute attrib = element.attribute( "callable" );
    if ( attrib != null && "true".equals( attrib.getValue() ) ) {
        if ( !supportsCallable ) {
            throw new MappingException( "callable attribute not supported yet!" );
        }
        return true;
    }
    return false;
}