当前位置: 首页>>代码示例>>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;未经允许,请勿转载。