Package org.jdom2

Examples of org.jdom2.Attribute


        Element subjectElement = new Element("subject", getDCNamespace());

        if (subject.getTaxonomyUri() != null) {
            Element descriptionElement = new Element("Description", getRDFNamespace());
            Element topicElement = new Element("topic", getTaxonomyNamespace());
            Attribute resourceAttribute = new Attribute("resource", subject.getTaxonomyUri(), getRDFNamespace());
            topicElement.setAttribute(resourceAttribute);
            descriptionElement.addContent(topicElement);

            if (subject.getValue() != null) {
                Element valueElement = new Element("value", getRDFNamespace());
View Full Code Here


            history.addUpdate(update);
        }
    }

    private String parseStringAttribute(Element syncChild, String attrName) {
        Attribute idAttribute = syncChild.getAttribute(attrName);
        return (idAttribute != null ? idAttribute.getValue().trim() : null);
    }
View Full Code Here

        Attribute idAttribute = syncChild.getAttribute(attrName);
        return (idAttribute != null ? idAttribute.getValue().trim() : null);
    }

    private Integer parseIntegerAttribute(Element sharingChild, String attrName) {
        Attribute integerAttribute = sharingChild.getAttribute(attrName);
        Integer integerAttr = null;
        if (integerAttribute != null) {
            try {
                integerAttr = new Integer(integerAttribute.getIntValue());
            } catch (DataConversionException e) {
                // dont use the data
            }
        }
        return integerAttr;
View Full Code Here

    protected Element generateQueryElement(OSQuery query) {
     
        Element qElement = new Element("Query", OS_NS);
       
        if (query.getRole() != null) {
            Attribute roleAttribute = new Attribute("role", query.getRole());
            qElement.setAttribute(roleAttribute);
        }
        else{
          throw new RequiredAttributeMissingException("If declaring a Query element, the field 'role' must be be specified");
        }

        if(query.getOsd() != null){
          Attribute osd = new Attribute("osd", query.getOsd());
            qElement.setAttribute(osd);
        }
       
        if(query.getSearchTerms() != null){
          Attribute searchTerms = new Attribute("searchTerms", query.getSearchTerms());
            qElement.setAttribute(searchTerms);
        }
       
        if(query.getStartPage() > -1){
          int startPage = (query.getStartPage() != 0)?query.getStartPage():1;
          Attribute sp = new Attribute("startPage", Integer.toString(startPage));
            qElement.setAttribute(sp);
        }
       
        if(query.getTitle() != null){
          qElement.setAttribute(new Attribute("title", query.getTitle()));
        }
        if(query.getTotalResults() > -1){
          qElement.setAttribute(new Attribute("totalResults", Integer.toString(query.getTotalResults())));
        }
       
        return qElement;
    }
View Full Code Here

        }
        return integerAttr;
    }

    private Boolean parseBooleanAttr(Element sharingChild, String attrName) {
        Attribute attribute = sharingChild.getAttribute(attrName);
        Boolean attrValue = null;
        if (attribute != null) {
            try {
                attrValue = Boolean.valueOf(attribute.getBooleanValue());
            } catch (DataConversionException e) {
                // dont use the data
            }
        }
        return attrValue;
View Full Code Here

   
    protected Element generateLinkElement(Link link) {
        Element linkElement = new Element("link", OS_NS);

        if (link.getRel() != null) {
            Attribute relAttribute = new Attribute("rel", "search");
            linkElement.setAttribute(relAttribute);
        }

        if (link.getType() != null) {
            Attribute typeAttribute = new Attribute("type", link.getType());
            linkElement.setAttribute(typeAttribute);
        }

        if (link.getHref() != null) {
            Attribute hrefAttribute = new Attribute("href", link.getHref());
            linkElement.setAttribute(hrefAttribute);
        }
       
        if (link.getHreflang() != null) {
            Attribute hreflangAttribute = new Attribute("hreflang", link.getHreflang());
            linkElement.setAttribute(hreflangAttribute);
        }
        return linkElement;
    }
View Full Code Here

        }
        return attrValue;
    }

    private Date parseDateAttribute(Element childElement, String attrName) {
        Attribute dateAttribute = childElement.getAttribute(attrName);
        Date date = null;
        if (dateAttribute != null) {
            // SSE spec requires the timezone to be 'GMT'
            // admittedly, this is a bit heavy-handed
            String dateAttr = dateAttribute.getValue().trim();
            return DateParser.parseRFC822(dateAttr);
        }
        return date;
    }
View Full Code Here

 
    /** Use xml:base attributes at feed and entry level to resolve relative links */
    private static String resolveURI(URL baseURI, Parent parent, String url) {
        url = (url.equals(".") || url.equals("./")) ? "" : url;
        if (isRelativeURI(url) && parent != null && parent instanceof Element) {
            Attribute baseAtt = ((Element)parent).getAttribute("base", Namespace.XML_NAMESPACE);
            String xmlBase = (baseAtt == null) ? "" : baseAtt.getValue();
            if (!isRelativeURI(xmlBase) && !xmlBase.endsWith("/")) {
                xmlBase = xmlBase.substring(0, xmlBase.lastIndexOf("/")+1);
            }
            return resolveURI(baseURI, parent.getParent(), xmlBase + url);
        } else if (isRelativeURI(url) && parent == null) {
View Full Code Here

        String ret = null;
        List linksList = parent.getChildren("link", ATOM_10_NS);
        if (linksList != null) {
            for (Iterator links = linksList.iterator(); links.hasNext(); ) {
                Element link = (Element)links.next();
                Attribute relAtt = getAttribute(link, "rel");
                Attribute hrefAtt = getAttribute(link, "href");
                if (   (relAtt == null && "alternate".equals(rel))
                    || (relAtt != null && relAtt.getValue().equals(rel))) {
                    ret = hrefAtt.getValue();
                    break;
                }
            }
        }
        return ret;
View Full Code Here

        return new Document(root);
    }

    protected Element createRootElement(Channel channel) {
        Element root = new Element("rss", getFeedNamespace());
        Attribute version = new Attribute("version", getVersion());
        root.setAttribute(version);
        root.addNamespaceDeclaration(getContentNamespace());
        generateModuleNamespaceDefs(root);

        return root;
View Full Code Here

TOP

Related Classes of org.jdom2.Attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.