當前位置: 首頁>>代碼示例>>Java>>正文


Java Namespace類代碼示例

本文整理匯總了Java中org.jdom.Namespace的典型用法代碼示例。如果您正苦於以下問題:Java Namespace類的具體用法?Java Namespace怎麽用?Java Namespace使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Namespace類屬於org.jdom包,在下文中一共展示了Namespace類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isMyType

import org.jdom.Namespace; //導入依賴的package包/類
/**
 * Indicates if a JDom document is an RSS instance that can be parsed with the parser.
 * <p/>
 * It checks for RDF ("http://www.w3.org/1999/02/22-rdf-syntax-ns#") and
 * RSS ("http://purl.org/rss/1.0/") namespaces being defined in the root element.
 *
 * @param document document to check if it can be parsed with this parser implementation.
 * @return <b>true</b> if the document is RSS1., <b>false</b> otherwise.
 */
public boolean isMyType(Document document) {
    boolean ok = false;

    Element rssRoot = document.getRootElement();
    Namespace defaultNS = rssRoot.getNamespace();
    List additionalNSs = rssRoot.getAdditionalNamespaces();

    ok = defaultNS!=null && defaultNS.equals(getRDFNamespace());
    if (ok) {
        if (additionalNSs==null) {
            ok = false;
        }
        else {
            ok = false;
            for (int i=0;!ok && i<additionalNSs.size();i++) {
                ok = getRSSNamespace().equals(additionalNSs.get(i));
            }
        }
    }
    return ok;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:31,代碼來源:RSS10Parser.java

示例2: setMetadataXML

import org.jdom.Namespace; //導入依賴的package包/類
/**
* 	
* @param atts
* @param attribute
* @param metadata
* @param namespace
* @param type
* @return
*/
protected Object setMetadataXML(Element atts, String attribute, String metadata, Namespace namespace, Class<?> type) {
  	Element o=atts.getChild(attribute, namespace);
  	String value=null;
  	Object val=null;
      if((atts != null) && (o != null)){
      	value=o.getText();
      	if(type==String.class){
      		val=value;
      		setMetadata(metadata,(String)value);
      	}else if(type==Integer.class){
      		val=Integer.parseInt(value);
      		setMetadata(metadata, val);
      	}else if(type==Double.class){
      		val=Double.parseDouble(value);
      		setMetadata(metadata, val);
      	}else if(type==Float.class){
      		val=Float.parseFloat(value);
      		setMetadata(metadata, val);
      	}	
      }
      return val;
  }
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:32,代碼來源:SUMOMetadata.java

示例3: parseContent

import org.jdom.Namespace; //導入依賴的package包/類
private Content parseContent(Element e) {
    String value = null;
    String src = e.getAttributeValue("src");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    String type = e.getAttributeValue("type");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    type = (type!=null) ? type : Content.TEXT;
    if (type.equals(Content.TEXT)) {
        // do nothing XML Parser took care of this
        value = e.getText();
    }
    else if (type.equals(Content.HTML)) {
        value = e.getText();
    }
    else if (type.equals(Content.XHTML)) {
        XMLOutputter outputter = new XMLOutputter();
        List eContent = e.getContent();
        Iterator i = eContent.iterator();
        while (i.hasNext()) {
            org.jdom.Content c = (org.jdom.Content) i.next();
            if (c instanceof Element) {
                Element eC = (Element) c;
                if (eC.getNamespace().equals(getAtomNamespace())) {
                    ((Element)c).setNamespace(Namespace.NO_NAMESPACE);
                }
            }
        }
        value = outputter.outputString(eContent);
    }
           
    Content content = new Content();
    content.setSrc(src);
    content.setType(type);
    content.setValue(value);
    return content;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:35,代碼來源:Atom10Parser.java

示例4: isMyType

import org.jdom.Namespace; //導入依賴的package包/類
public boolean isMyType(Document document) {
    boolean ok = false;

    Element rssRoot = document.getRootElement();
    Namespace defaultNS = rssRoot.getNamespace();
    List additionalNSs = rssRoot.getAdditionalNamespaces();

    ok = defaultNS!=null && defaultNS.equals(getRDFNamespace());
    if (ok) {
        if (additionalNSs==null) {
            ok = false;
        }
        else {
            ok = false;
            for (int i=0;!ok && i<additionalNSs.size();i++) {
                ok = getRSSNamespace().equals(additionalNSs.get(i));
            }
        }
    }
    return ok;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:22,代碼來源:RSS090Parser.java

示例5: parseContent

import org.jdom.Namespace; //導入依賴的package包/類
private Content parseContent(Element e) {
    String value = null;
    String type = e.getAttributeValue("type");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    type = (type!=null) ? type : "text/plain";
    String mode = e.getAttributeValue("mode");//getAtomNamespace())); DONT KNOW WHY DOESN'T WORK
    if (mode == null) {
        mode = Content.XML; // default to xml content
    }
    if (mode.equals(Content.ESCAPED)) {
        // do nothing XML Parser took care of this
        value = e.getText();
    }
    else
    if (mode.equals(Content.BASE64)) {
            value = Base64.decode(e.getText());
    }
    else
    if (mode.equals(Content.XML)) {
        XMLOutputter outputter = new XMLOutputter();
        List eContent = e.getContent();
        Iterator i = eContent.iterator();
        while (i.hasNext()) {
            org.jdom.Content c = (org.jdom.Content) i.next();
            if (c instanceof Element) {
                Element eC = (Element) c;
                if (eC.getNamespace().equals(getAtomNamespace())) {
                    ((Element)c).setNamespace(Namespace.NO_NAMESPACE);
                }
            }
        }
        value = outputter.outputString(eContent);
    }

    Content content = new Content();
    content.setType(type);
    content.setMode(mode);
    content.setValue(value);
    return content;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:40,代碼來源:Atom03Parser.java

示例6: parseSearchResult

import org.jdom.Namespace; //導入依賴的package包/類
private LyricsInfo parseSearchResult(String xml) throws Exception {
    SAXBuilder builder = new SAXBuilder();
    Document document = builder.build(new StringReader(xml));

    Element root = document.getRootElement();
    Namespace ns = root.getNamespace();

    String lyric = StringUtils.trimToNull(root.getChildText("Lyric", ns));
    String song =  root.getChildText("LyricSong", ns);
    String artist =  root.getChildText("LyricArtist", ns);

    return new LyricsInfo(lyric, artist, song);
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:14,代碼來源:LyricsService.java

示例7: getITunesAttribute

import org.jdom.Namespace; //導入依賴的package包/類
private String getITunesAttribute(Element element, String childName, String attributeName) {
    for (Namespace ns : ITUNES_NAMESPACES) {
        Element elem = element.getChild(childName, ns);
        if (elem != null) {
            return StringUtils.trimToNull(elem.getAttributeValue(attributeName));
        }
    }
    return null;
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:10,代碼來源:PodcastService.java

示例8: export

import org.jdom.Namespace; //導入依賴的package包/類
/**
 * @param t_objdb
 * @param string
 * @throws IOException 
 * @throws SQLException 
 */
public void export(DBInterface a_objDB, String a_strFileName) throws IOException, SQLException 
{
    this.m_objDB = a_objDB;
    // Erzeugung eines XML-Dokuments
    Document t_objDocument = new Document();
    // Erzeugung des Root-XML-Elements 
    Element t_objRoot = new Element("defaults");
    Namespace xsiNS = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");        
    t_objRoot.addNamespaceDeclaration(xsiNS);
    this.exportResidues(t_objRoot);
    this.exportPersubstitutions(t_objRoot);
    this.exportIons(t_objRoot);
    this.exportDericatisation(t_objRoot);
    this.exportMolecules(t_objRoot);
    // Und jetzt haengen wir noch das Root-Element an das Dokument
    t_objDocument.setRootElement(t_objRoot);
    // Damit das XML-Dokument schoen formattiert wird holen wir uns ein Format
    Format t_objFormat = Format.getPrettyFormat();
    t_objFormat.setEncoding("iso-8859-1");
    // Erzeugung eines XMLOutputters dem wir gleich unser Format mitgeben
    XMLOutputter t_objExportXML = new XMLOutputter(t_objFormat);
    // Schreiben der XML-Datei in einen String
    FileWriter t_objWriter = new FileWriter(a_strFileName);
    t_objExportXML.output(t_objDocument, t_objWriter );
}
 
開發者ID:glycoinfo,項目名稱:eurocarbdb,代碼行數:32,代碼來源:GeneratorDefault.java

示例9: getITunesElement

import org.jdom.Namespace; //導入依賴的package包/類
private String getITunesElement(Element element, String childName) {
    for (Namespace ns : ITUNES_NAMESPACES) {
        String value = element.getChildTextTrim(childName, ns);
        if (value != null) {
            return value;
        }
    }
    return null;
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:10,代碼來源:PodcastService.java

示例10: createAnnotationSchemaObject

import org.jdom.Namespace; //導入依賴的package包/類
/** This method creates an AnnotationSchema object fom an org.jdom.Element
  * @param anElement is an XSchema element element
  */
private void createAnnotationSchemaObject(org.jdom.Element anElement, Namespace namespace){
  // Get the value of the name attribute. If this attribute doesn't exists
  // then it will receive a default one.
  annotationName = anElement.getAttributeValue("name");
  if (annotationName == null)
      annotationName = "UnknownElement";
  // See if this element has a complexType element inside it
  org.jdom.Element complexTypeElement = anElement.getChild("complexType",
                                                           namespace);
  if (complexTypeElement != null){
    List<?> complexTypeCildrenList = complexTypeElement.getChildren("attribute",
                                                                 namespace);
    Iterator<?> complexTypeCildrenIterator = complexTypeCildrenList.iterator();
    if (complexTypeCildrenIterator.hasNext())
      featureSchemaSet = new LinkedHashSet<FeatureSchema>();
    while (complexTypeCildrenIterator.hasNext()) {
      org.jdom.Element childElement =
                  (org.jdom.Element) complexTypeCildrenIterator.next();
      createAndAddFeatureSchemaObject(childElement, namespace);
    }// end while
  }// end if
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:26,代碼來源:AnnotationSchema.java

示例11: resolveURI

import org.jdom.Namespace; //導入依賴的package包/類
/** Use xml:base attributes at feed and entry level to resolve relative links */
private 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) {
        return baseURI + url;
    } else if (baseURI != null && url.startsWith("/")) {
        String hostURI = baseURI.getProtocol() + "://" + baseURI.getHost();
        if (baseURI.getPort() != baseURI.getDefaultPort()) {
            hostURI = hostURI + ":" + baseURI.getPort();
        }
        return hostURI + url;
    }
    return url;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:22,代碼來源:Atom10Parser.java

示例12: BaseWireFeedGenerator

import org.jdom.Namespace; //導入依賴的package包/類
protected BaseWireFeedGenerator(String type) {
    _type = type;
    _feedModuleGenerators = new ModuleGenerators(type+FEED_MODULE_GENERATORS_POSFIX_KEY);
    _itemModuleGenerators = new ModuleGenerators(type+ITEM_MODULE_GENERATORS_POSFIX_KEY);
    Set allModuleNamespaces = new HashSet();
    Iterator i = _feedModuleGenerators.getAllNamespaces().iterator();
    while (i.hasNext()) {
        allModuleNamespaces.add(i.next());
    }
    i = _itemModuleGenerators.getAllNamespaces().iterator();
    while (i.hasNext()) {
        allModuleNamespaces.add(i.next());
    }
    _allModuleNamespaces = new Namespace[allModuleNamespaces.size()];
    allModuleNamespaces.toArray(_allModuleNamespaces);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:17,代碼來源:BaseWireFeedGenerator.java

示例13: createRootElement

import org.jdom.Namespace; //導入依賴的package包/類
protected Element createRootElement(Feed feed) {
    Element root = new Element("feed",getFeedNamespace());
    root.addNamespaceDeclaration(getFeedNamespace());
    //Attribute version = new Attribute("version", getVersion());
    //root.setAttribute(version);
    if (feed.getXmlBase() != null) {
        root.setAttribute("base", feed.getXmlBase(), Namespace.XML_NAMESPACE);
    }
    generateModuleNamespaceDefs(root);
    return root;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:12,代碼來源:Atom10Generator.java

示例14: hasElementsFrom

import org.jdom.Namespace; //導入依賴的package包/類
private boolean hasElementsFrom(Element root,Namespace namespace) {
    boolean itHas = false;
    List children = root.getChildren();
    for (int i=0;!itHas && i<children.size();i++) {
        Element child = (Element) children.get(i);
        itHas = namespace.equals(child.getNamespace());
    }
   return itHas;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:10,代碼來源:ModuleParsers.java

示例15: isMyType

import org.jdom.Namespace; //導入依賴的package包/類
public boolean isMyType(Document document) {
    Element rssRoot = document.getRootElement();
    Namespace defaultNS = rssRoot.getNamespace();
    boolean ok = defaultNS!=null && defaultNS.equals(getRSSNamespace());
    if (ok) {
        ok = super.isMyType(document);
    }
    return ok;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:10,代碼來源:RSS20wNSParser.java


注:本文中的org.jdom.Namespace類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。