當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。