当前位置: 首页>>代码示例>>Java>>正文


Java Element类代码示例

本文整理汇总了Java中org.jdom.Element的典型用法代码示例。如果您正苦于以下问题:Java Element类的具体用法?Java Element怎么用?Java Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Element类属于org.jdom包,在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseContent

import org.jdom.Element; //导入依赖的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

示例2: parseItem

import org.jdom.Element; //导入依赖的package包/类
/**
 * Parses an item element of an RSS document looking for item information.
 * <p/>
 * It reads title and link out of the 'item' element.
 * <p/>
 *
 * @param rssRoot the root element of the RSS document in case it's needed for context.
 * @param eItem the item element to parse.
 * @return the parsed RSSItem bean.
 */
protected Item parseItem(Element rssRoot,Element eItem) {
    Item item = new Item();
    Element e = eItem.getChild("title",getRSSNamespace());
    if (e!=null) {
        item.setTitle(e.getText());
    }
    e = eItem.getChild("link",getRSSNamespace());
    if (e!=null) {
        item.setLink(e.getText());
    }
    
    item.setModules(parseItemModules(eItem));

    return item;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:RSS090Parser.java

示例3: parsePerson

import org.jdom.Element; //导入依赖的package包/类
private Person parsePerson(URL baseURI, Element ePerson) {
    Person person = new Person();
    Element e = ePerson.getChild("name",getAtomNamespace());
    if (e!=null) {
        person.setName(e.getText());
    }
    e = ePerson.getChild("uri",getAtomNamespace());
    if (e!=null) {
        person.setUri(resolveURI(baseURI, ePerson, e.getText()));
    }
    e = ePerson.getChild("email",getAtomNamespace());
    if (e!=null) {
        person.setEmail(e.getText());
    }
    return person;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:Atom10Parser.java

示例4: parseLinks

import org.jdom.Element; //导入依赖的package包/类
private List parseLinks(List eLinks,boolean alternate) {
    List links = new ArrayList();
    for (int i=0;i<eLinks.size();i++) {
        Element eLink = (Element) eLinks.get(i);
        //Namespace ns = getAtomNamespace();
        String rel = eLink.getAttributeValue("rel");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
        if (alternate) {
            if ("alternate".equals(rel)) {
                links.add(parseLink(eLink));
            }
        }
        else {
            if (!("alternate".equals(rel))) {
                links.add(parseLink(eLink));
            }
        }
    }
    return (links.size()>0) ? links : null;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:Atom03Parser.java

示例5: parseSearchResult

import org.jdom.Element; //导入依赖的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

示例6: getITunesAttribute

import org.jdom.Element; //导入依赖的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

示例7: getCreoleXML

import org.jdom.Element; //导入依赖的package包/类
@Override
public Document getCreoleXML() throws Exception, JDOMException {
  Document doc = new Document();
  Element element;
  doc.addContent(element = new Element("CREOLE-DIRECTORY"));
  element.addContent(element = new Element("CREOLE"));
  element.addContent(element = new Element("RESOURCE"));
  Element classElement  = new Element("CLASS");
  classElement.setText(resourceClass.getName());
  element.addContent(classElement);
  
  return doc;
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:14,代码来源:Plugin.java

示例8: processAnnotationsForResource

import org.jdom.Element; //导入依赖的package包/类
/**
 * Process the given RESOURCE element, adding extra elements to it based on
 * the annotations on the resource class.
 * 
 * @param element
 *          the RESOURCE element to process.
 */
private void processAnnotationsForResource(Element element)
    throws GateException {
  String className = element.getChildTextTrim("CLASS");
  if(className == null) { throw new GateException(
      "\"CLASS\" element not found for resource in " + plugin); }
  Class<?> resourceClass = null;
  try {
    resourceClass = Gate.getClassLoader().loadClass(className);
  } catch(ClassNotFoundException e) {
    log.debug("Couldn't load class " + className + " for resource in "
        + plugin, e);
    throw new GateException("Couldn't load class " + className
        + " for resource in " + plugin);
  }

  processCreoleResourceAnnotations(element, resourceClass);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:25,代码来源:CreoleAnnotationHandler.java

示例9: determineCollectionElementType

import org.jdom.Element; //导入依赖的package包/类
/**
 * Given a single-argument method whose parameter is a {@link Collection}, use
 * the method's generic type information to determine the collection element
 * type and store it as the ITEM_CLASS_NAME attribute of the given Element.
 * 
 * @param method
 *          the setter method
 * @param paramElt
 *          the PARAMETER element
 */
private void determineCollectionElementType(AnnotatedElement method,
    Type paramType, Element paramElt) {
  if(paramElt.getAttributeValue("ITEM_CLASS_NAME") == null) {
    Class<?> elementType;
    CreoleParameter paramAnnot = method.getAnnotation(CreoleParameter.class);
    if(paramAnnot != null
        && paramAnnot.collectionElementType() != CreoleParameter.NoElementType.class) {
      elementType = paramAnnot.collectionElementType();
    } else {
      elementType = findCollectionElementType(paramType);
    }
    if(elementType != null) {
      paramElt.setAttribute("ITEM_CLASS_NAME", elementType.getName());
    }
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:27,代码来源:CreoleAnnotationHandler.java

示例10: readFrom

import org.jdom.Element; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void readFrom(Element rootElement)
/* Is passed an Element by TC, and is expected to persist it to the settings object.
 * Old settings should be overwritten.
 */
{
    if(msteamsNotificationMainConfig.getConfigFileExists()){
        // The MainConfigProcessor approach has been deprecated.
        // Instead we will use our own config file so we have better control over when it is persisted
        return;
    }
	Loggers.SERVER.info("MsTeamsNotificationMainSettings: re-reading main settings using old-style MainConfigProcessor. From now on we will use the msteams/msteams-config.xml file instead of main-config.xml");
	Loggers.SERVER.debug(NAME + ":readFrom :: " + rootElement.toString());
	MsTeamsNotificationMainConfig tempConfig = new MsTeamsNotificationMainConfig(serverPaths);
	Element msteamsNotificationsElement = rootElement.getChild("msteamsnotifications");
    tempConfig.readConfigurationFromXmlElement(msteamsNotificationsElement);
    this.msteamsNotificationMainConfig = tempConfig;
    tempConfig.save();
}
 
开发者ID:spyder007,项目名称:teamcity-msteams-notifier,代码行数:21,代码来源:MsTeamsNotificationMainSettings.java

示例11: updateNetbeansActionMapping

import org.jdom.Element; //导入依赖的package包/类
/**
 * Method updateNetbeansActionMapping.
 * 
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updateNetbeansActionMapping(NetbeansActionMapping value, String xmlTag, Counter counter, Element element)
{
    Element root = element;
    Counter innerCount = new Counter(counter.getDepth() + 1);
    findAndReplaceSimpleElement(innerCount, root,  "actionName", value.getActionName(), null);
    findAndReplaceSimpleElement(innerCount, root,  "displayName", value.getDisplayName(), null);
    findAndReplaceSimpleElement(innerCount, root,  "basedir", value.getBasedir(), null);
    findAndReplaceSimpleElement(innerCount, root,  "reactor", value.getReactor(), null);
    findAndReplaceSimpleElement(innerCount, root,  "preAction", value.getPreAction(), null);
    findAndReplaceSimpleElement(innerCount, root,  "recursive", value.isRecursive() == true ? null : String.valueOf( value.isRecursive() ), "true");
    findAndReplaceSimpleLists(innerCount, root, value.getPackagings(), "packagings", "packaging");
    findAndReplaceSimpleLists(innerCount, root, value.getGoals(), "goals", "goal");
    findAndReplaceProperties(innerCount, root,  "properties", value.getProperties());
    findAndReplaceSimpleLists(innerCount, root, value.getActivatedProfiles(), "activatedProfiles", "activatedProfile");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:NetbeansBuildActionJDOMWriter.java

示例12: convertToThirdVersion

import org.jdom.Element; //导入依赖的package包/类
public static Element convertToThirdVersion(Element state, Project project) throws StudyUnrecognizedFormatException {
  Element taskManagerElement = state.getChild(MAIN_ELEMENT);
  XMLOutputter outputter = new XMLOutputter();

  Map<String, String> placeholderTextToStatus = fillStatusMap(taskManagerElement, STUDY_STATUS_MAP, outputter);
  Map<String, String> taskFileToStatusMap = fillStatusMap(taskManagerElement, TASK_STATUS_MAP, outputter);

  Element courseElement = getChildWithName(taskManagerElement, COURSE).getChild(COURSE_TITLED);
  for (Element lesson : getChildList(courseElement, LESSONS)) {
    int lessonIndex = getAsInt(lesson, INDEX);
    for (Element task : getChildList(lesson, TASK_LIST)) {
      String taskStatus = null;
      int taskIndex = getAsInt(task, INDEX);
      Map<String, Element> taskFiles = getChildMap(task, TASK_FILES);
      for (Map.Entry<String, Element> entry : taskFiles.entrySet()) {
        Element taskFileElement = entry.getValue();
        String taskFileText = outputter.outputString(taskFileElement);
        String taskFileStatus = taskFileToStatusMap.get(taskFileText);
        if (taskFileStatus != null && (taskStatus == null || taskFileStatus.equals(StudyStatus.Failed.toString()))) {
          taskStatus = taskFileStatus;
        }
        Document document = StudyUtils.getDocument(project.getBasePath(), lessonIndex, taskIndex, entry.getKey());
        if (document == null) {
          continue;
        }
        for (Element placeholder : getChildList(taskFileElement, ANSWER_PLACEHOLDERS)) {
          taskStatus = addStatus(outputter, placeholderTextToStatus, taskStatus, placeholder);
          addOffset(document, placeholder);
          addInitialState(document, placeholder);
        }
      }
      if (taskStatus != null) {
        addChildWithName(task, STATUS, taskStatus);
      }
    }
  }
  return state;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:39,代码来源:StudySerializationUtils.java

示例13: processModule

import org.jdom.Element; //导入依赖的package包/类
private void processModule(Element module, String path, Properties props) {
    if (!"module".equals(module.getName())) {
        return;
    }
    String moduleName = module.getAttributeValue("name");
    @SuppressWarnings("unchecked")
    List<Element> propElements = module.getChildren("property");
    Map<String, String> moduleProps = new HashMap<String, String>();
    for (Element prp : propElements) {
        String name = prp.getAttributeValue("name");
        String value = prp.getAttributeValue("value");
        assert name != null && value != null;
        moduleProps.put(name, value);
    }
    String modulePath = path + "/" + moduleName;
    checkRules(modulePath, moduleProps, props);
    //now check child modules..
    @SuppressWarnings("unchecked")
    List<Element> childs = module.getChildren("module");
    for (Element child : childs) {
        processModule(child, modulePath, props);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ModuleConvertor.java

示例14: getListCellRendererComponent

import org.jdom.Element; //导入依赖的package包/类
/**
 * @param list
 * @param value
 * @param index
 * @param isSelected
 * @param cellHasFocus
 * @return
 */
public Component getListCellRendererComponent( final JList list,
                                               final Object value,
                                               final int index,
                                               final boolean isSelected,
                                               boolean cellHasFocus ) {
    return new JPanel() {
        public void paintComponent( Graphics g ) {
            super.paintComponent( g );
            Element e = ( Element ) value;
            String title = e.getAttributeValue( "title" );
            String text = e.getText().trim();

            g.setColor( isSelected ? COLOR_SELECTED : index % 2 == 0 ? COLOR_EVEN : COLOR_ODD );
            g.fillRect( 0, 0, getWidth(), getHeight() );

            g.setColor( isSelected ? Color.WHITE : list.getForeground() );
            g.setFont( new Font( Font.SANS_SERIF, Font.BOLD, 12 ) );
            g.drawString( ( index + 1 ) + ". " + title, 5, 16 );
            g.setFont( new Font( Font.SANS_SERIF, Font.PLAIN, 12 ) );

            if ( text.indexOf( "\n" ) != -1 ) {
                text = text.substring( 0, text.indexOf( "\n" ) );
            }
            g.drawString( text, 20, 32 );
        }

        public Dimension getPreferredSize() {
            return new Dimension( 200, 40 );
        }
    };
}
 
开发者ID:jrana,项目名称:quicknotes,代码行数:40,代码来源:NoteListRenderer.java

示例15: parseLink

import org.jdom.Element; //导入依赖的package包/类
private Link parseLink(Feed feed , Entry entry, URL baseURI, Element eLink) {
    Link link = new Link();
    String att = eLink.getAttributeValue("rel");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    if (att!=null) {
        link.setRel(att);
    }
    att = eLink.getAttributeValue("type");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    if (att!=null) {
        link.setType(att);
    }
    att = eLink.getAttributeValue("href");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    if (att!=null) {
        if (isRelativeURI(att)) { //
            link.setHref(resolveURI(baseURI, eLink, ""));
        } else {
            link.setHref(att);
        }
    }
    att = eLink.getAttributeValue("hreflang");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    if (att!=null) {
        link.setHreflang(att);
    }
    att = eLink.getAttributeValue("length");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
    if (att!=null) {
        link.setLength(Long.parseLong(att));
    }
    return link;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:29,代码来源:Atom10Parser.java


注:本文中的org.jdom.Element类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。