Java Code Examples for org.jdom.Element

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project AdServing, under directory /modules/tools/import/src/main/java/net/mad/ads/base/api/importer/reader/.

Source file: AdXmlReader.java

  22 
vote

private static AdDefinition processExternBannerDefinition(AdDefinition definition,Element banner){
  Element e=banner.getChild("externContent");
  if (e != null) {
    ((ExternAdDefinition)definition).setExternContent(e.getText());
  }
  return definition;
}
 

Example 2

From project agile, under directory /agile-apps/agile-app-search/src/main/java/org/headsupdev/agile/app/search/feed/.

Source file: SearchFeed.java

  22 
vote

@Override protected final void onRender(MarkupStream markupStream){
  PrintWriter writer=new PrintWriter(getResponse().getOutputStream());
  try {
    Document doc=new Document();
    Element root=new Element("searchResults");
    doc.setRootElement(root);
    populateFeed(root);
    XMLOutputter out=new XMLOutputter();
    out.output(doc,writer);
  }
 catch (  IOException e) {
    throw new RuntimeException("Error streaming feed.",e);
  }
}
 

Example 3

From project alg-vis, under directory /src/algvis/avltree/.

Source file: AVLNode.java

  22 
vote

@Override public Element getXML(){
  Element e=new Element("setBalance");
  e.setAttribute("key",Integer.toString(getKey()));
  e.setAttribute("fromBalance",Integer.toString(fromBal));
  e.setAttribute("toBalance",Integer.toString(toBal));
  return e;
}
 

Example 4

From project alg-vis, under directory /src/algvis/bst/.

Source file: BSTNode.java

  22 
vote

@Override public Element getXML(){
  Element e=new Element("setLevel");
  e.setAttribute("key",Integer.toString(getKey()));
  e.setAttribute("fromLevel",Integer.toString(fromLevel));
  e.setAttribute("toLevel",Integer.toString(toLevel));
  return e;
}
 

Example 5

From project and-bible, under directory /AndBackendTest/src/org/crosswire/jsword/index/lucene/.

Source file: PdaLuceneIndexTest.java

  22 
vote

public void testGetStrongs() throws NoSuchKeyException, BookException {
  Book book=Books.installed().getBook("KJV");
  assertTrue("Should have Strongs",book.getBookMetaData().hasFeature(FeatureType.STRONGS_NUMBERS));
  Key key=book.getKey("Gen 1:1");
  BookData data=new BookData(book,key);
  Element osis=data.getOsisFragment();
  String strongsNumbers=OSISUtil.getStrongsNumbers(osis);
  assertTrue("No Strongs in KJV",strongsNumbers.length() > 0);
}
 

Example 6

From project and-bible, under directory /IgnoreAndBibleExperiments/experiments/.

Source file: ZVerseBackendLite.java

  22 
vote

public Element getOsis(Key key,SwordBookMetaData sbmd) throws BookException {
  try {
    String plain=getRawText(key);
    StringReader in=new StringReader("<div>" + plain + "</div>");
    InputSource is=new InputSource(in);
    SAXBuilder builder=new SAXBuilder();
    Document doc=builder.build(is);
    Element div=doc.getRootElement();
    return div;
  }
 catch (  Exception e) {
    throw new BookException(UserMsg.READ_FAIL,e,new Object[]{key.getName()});
  }
}
 

Example 7

From project Application-Builder, under directory /src/main/java/org/silverpeas/applicationbuilder/.

Source file: AppDescriptor.java

  22 
vote

/** 
 * Adds a "module" tag with nested EJB JAR name within "ejb" tag example : &lt;module&gt; &lt;ejb&gt;ejb-jar-ic-forums.jar&lt;/ejb&gt; &lt;/module&gt;
 * @since 1.0/B
 * @roseuid 3AAE3C420398
 */
public void addEJBName(String ejbJarName){
  Element ejb=new Element(MOD_EJB_ELT);
  ejb.setText(ejbJarName);
  Element module=new Element(MODULE_ELT);
  module.addContent(ejb);
  getDocument().getRootElement().addContent(module);
}
 

Example 8

From project Application-Builder, under directory /src/main/java/org/silverpeas/applicationbuilder/.

Source file: AppDescriptor.java

  22 
vote

/** 
 * Example : &lt;module&gt; &lt;web&gt; &lt;web-uri&gt;war-ic.war&lt;/web-uri&gt; &lt;context-root&gt;webactiv&lt;/context-root&gt; &lt;/web&gt; &lt;/module&gt;
 * @roseuid 3AAE3CF503E5
 */
public void setWARInfos(String webUri,String contextRoot){
  Element uri=new Element(MOD_WEB_URI_ELT);
  uri.setText(webUri);
  Element rootCntxt=new Element(MOD_WEB_ROOT_ELT);
  rootCntxt.setText(contextRoot);
  Element web=new Element(MOD_WEB_ELT);
  web.addContent(uri);
  web.addContent(rootCntxt);
  Element module=new Element(MODULE_ELT);
  module.addContent(web);
  getDocument().getRootElement().addContent(module);
}
 

Example 9

From project beanmill_1, under directory /src/main/java/com/traxel/lumbermill/filter/.

Source file: Tree.java

  22 
vote

/** 
 * Creates a new Tree object.
 * @param treeFilter  DOCUMENT ME!
 */
public Tree(final Element treeFilter){
  this();
  final Element rootElement=treeFilter.getChild("filternode");
  final Node n=(Node)getRoot();
  n.setSeverity(Severity.getSeverityByString(rootElement.getAttributeValue("severity")));
  final List children=rootElement.getChildren("filternode");
  for (  final Object c : children) {
    final Element childElement=(Element)c;
    final Node childNode=new Node(childElement,map);
    childNode.addFilterListener(this);
    map.put(childNode.getSourceComponents(),childNode);
    ((Node)getRoot()).add(childNode);
  }
}
 

Example 10

From project beanmill_1, under directory /src/main/java/com/traxel/lumbermill/filter/.

Source file: Tree.java

  22 
vote

/** 
 * DOCUMENT ME!
 * @return  DOCUMENT ME!
 */
public Element getXML(){
  final Element tree=new Element("treefilter");
  final Node rootNode=(Node)getRoot();
  tree.addContent(rootNode.getXMLElement());
  return tree;
}
 

Example 11

From project BeeQueue, under directory /test/beequeue/db/schema/clay/.

Source file: Clay.java

  22 
vote

public Clay(InputStream is) throws JDOMException, IOException {
  SAXBuilder parser=new SAXBuilder();
  Document doc=parser.build(is);
  Element root=doc.getRootElement();
  Element schema=root.getChild("database-model").getChild("schema-list").getChild("schema");
  Element tableList=schema.getChild("table-list");
  @SuppressWarnings("unchecked") List<Element> children=(List<Element>)tableList.getChildren();
  tables=new ClayTable[children.size()];
  for (int i=0; i < this.tables.length; i++) {
    this.tables[i]=new ClayTable(children.get(i));
  }
}
 

Example 12

From project Bio4j, under directory /src/main/java/com/era7/bioinfo/bio4j/programs/.

Source file: ImportUniprot.java

  22 
vote

private static String getProteinFullName(Element proteinElement){
  if (proteinElement == null) {
    return "";
  }
 else {
    Element recElem=proteinElement.getChild(CommonData.PROTEIN_RECOMMENDED_NAME_TAG_NAME);
    if (recElem == null) {
      return "";
    }
 else {
      return recElem.getChildText(CommonData.PROTEIN_FULL_NAME_TAG_NAME);
    }
  }
}
 

Example 13

From project Bio4j, under directory /src/main/java/com/era7/bioinfo/bio4j/programs/.

Source file: ImportUniprot.java

  22 
vote

private static String getProteinShortName(Element proteinElement){
  if (proteinElement == null) {
    return "";
  }
 else {
    Element recElem=proteinElement.getChild(CommonData.PROTEIN_RECOMMENDED_NAME_TAG_NAME);
    if (recElem == null) {
      return "";
    }
 else {
      return recElem.getChildText(CommonData.PROTEIN_SHORT_NAME_TAG_NAME);
    }
  }
}
 

Example 14

From project bpelunit, under directory /net.bpelunit.framework/src/main/java/net/bpelunit/framework/control/deploy/ode/.

Source file: ODEDeployment.java

  22 
vote

private Element constructInvokeElement(){
  Element invoke=new Element("invoke",DESCRIPTOR_NS);
  invoke.setAttribute(PARTNERLINK_ATTR,CoverageConstants.PARTNERLINK_NAME);
  Element service=new Element(SERVICE_ATTR,DESCRIPTOR_NS);
  String serviceName=CoverageConstants.COVERAGETOOL_NAMESPACE.getPrefix() + ":" + CoverageConstants.SERVICE_NAME;
  service.setAttribute(NAME_ATTR,serviceName);
  service.setAttribute(PORT_ATTR,CoverageConstants.PORT_OF_SERVICE);
  invoke.addContent(service);
  return invoke;
}
 

Example 15

From project bpelunit, under directory /net.bpelunit.framework/src/main/java/net/bpelunit/framework/coverage/annotation/.

Source file: Instrumenter.java

  22 
vote

/** 
 * Executes instrumentation of the BPEL file
 * @param document BPEL process
 * @param metricManager
 * @return instrumentated BPEL-Prozess
 * @throws BpelException
 */
public Document insertAnnotations(Document document,MetricsManager metricManager) throws BpelException {
  Element processElement=document.getRootElement();
  checkVersion(processElement);
  initializeBPELTools(processElement);
  if (metricManager.hasMetric(FaultMetric.METRIC_NAME) || metricManager.hasMetric(CompensationMetric.METRIC_NAME)) {
    replaceInlineHandler(processElement);
  }
  List<IMetric> metrics=metricManager.getMetrics();
  saveOriginalBPELElements(metrics,processElement);
  executeInstrumentation(metrics);
  createReportInvokesFromCoverageLabels(processElement);
  return document;
}
 

Example 16

From project build-info, under directory /build-info-extractor-maven3/src/main/java/org/jfrog/build/extractor/maven/transformer/.

Source file: PomTransformer.java

  22 
vote

private void changeParentVersion(Element root,Namespace ns){
  Element parentElement=root.getChild("parent",ns);
  if (parentElement == null) {
    return;
  }
  ModuleName parentName=extractModuleName(parentElement,ns);
  if (versionsByModule.containsKey(parentName)) {
    setVersion(parentElement,ns,versionsByModule.get(parentName));
  }
  verifyNonSnapshotVersion(parentName,parentElement,ns);
}
 

Example 17

From project build-info, under directory /build-info-extractor-maven3/src/main/java/org/jfrog/build/extractor/maven/transformer/.

Source file: PomTransformer.java

  22 
vote

private void changeDependencyManagementVersions(Element rootElement,Namespace ns){
  Element dependencyManagement=rootElement.getChild("dependencyManagement",ns);
  if (dependencyManagement == null) {
    return;
  }
  Element dependenciesElement=dependencyManagement.getChild("dependencies",ns);
  if (dependenciesElement == null) {
    return;
  }
  List<Element> dependencies=dependenciesElement.getChildren("dependency",ns);
  for (  Element dependency : dependencies) {
    changeDependencyVersion(ns,dependency);
  }
}
 

Example 18

From project Carolina-Digital-Repository, under directory /access/src/main/java/edu/unc/lib/dl/ui/service/.

Source file: RssParserService.java

  22 
vote

private static String getValueOfChildElement(Element parentElement,String tagName){
  Element childElement=null;
  String tagValue=null;
  childElement=parentElement.getChild(tagName);
  tagValue=(null != childElement) ? childElement.getValue().trim() : null;
  return (tagValue);
}
 

Example 19

From project AdServing, under directory /modules/tools/import/src/main/java/net/mad/ads/base/api/importer/reader/.

Source file: AdXmlReader.java

  21 
vote

public static AdDefinition readBannerDefinition(String filename) throws IOException {
  SAXBuilder builder=new SAXBuilder();
  Document doc;
  try {
    doc=builder.build(new File(filename));
    Element root=doc.getRootElement();
    String type=root.getAttributeValue("type");
    AdDefinition banner=AdTypeMapping.getInstance().getDefinition(type);
    banner.setId(root.getAttributeValue("id"));
    Element fe=root.getChild("format");
    banner.setFormat(AdFormats.forCompoundName(fe.getAttributeValue("name")));
    fe=root.getChild("targetUrl");
    banner.setTargetUrl(fe.getTextTrim());
    fe=root.getChild("linkTarget");
    if (fe != null) {
      banner.setLinkTarget(fe.getTextTrim());
    }
    fe=root.getChild("linkTitle");
    if (fe != null) {
      banner.setLinkTitle(fe.getTextTrim());
    }
    fe=root.getChild("product");
    if (fe != null) {
      banner.setProduct(fe.getTextTrim());
    }
    banner=ConditionReader.processConditions(banner,root.getChild("condition"));
    banner=processBannerType(banner,root);
    return banner;
  }
 catch (  JDOMException e) {
    e.printStackTrace();
  }
  return null;
}
 

Example 20

From project agile, under directory /agile-apps/agile-app-search/src/main/java/org/headsupdev/agile/app/search/feed/.

Source file: SearchFeed.java

  21 
vote

protected void populateFeed(Element root){
  String query=parameters.getString("query");
  List<Object[]> results=new LinkedList<Object[]>();
  Session session=((HibernateStorage)Manager.getStorageInstance()).getHibernateSession();
  FullTextSession fullTextSession=org.hibernate.search.Search.createFullTextSession(((SessionProxy)session).getRealSession());
  MultiFieldQueryParser parser=new MultiFieldQueryParser(new ArrayList<String>(HibernateUtil.getSearchFields()).toArray(new String[0]),new StandardAnalyzer());
  try {
    Query q=parser.parse(query);
    FullTextQuery textQuery=fullTextSession.createFullTextQuery(q);
    textQuery.setProjection(FullTextQuery.SCORE,FullTextQuery.THIS);
    textQuery.setMaxResults(25);
    results=textQuery.list();
  }
 catch (  Exception e) {
    Manager.getLogger(getClass().getName()).error("Failed to run search",e);
  }
  for (  Object[] o : results) {
    Element node=new Element("result");
    int relevance=(int)(((Float)o[0]) * 100);
    String title=o[1].toString();
    String link="";
    if (o[1] instanceof SearchResult) {
      link=((SearchResult)o[1]).getLink();
    }
    node.addContent(new Element("title").addContent(title));
    node.addContent(new Element("relevance").addContent(relevance + "%"));
    node.addContent(new Element("link").addContent(storage.getGlobalConfiguration().getFullUrl(link)));
    String image=Search.getClassImageName(o[1]);
    node.addContent(new Element("icon").addContent(storage.getGlobalConfiguration().getFullUrl("resources/org.headsupdev.agile.HeadsUpResourceMarker/" + image)));
    root.addContent(node);
  }
}
 

Example 21

From project BeeQueue, under directory /test/beequeue/db/schema/clay/.

Source file: ClayTable.java

  21 
vote

public ClayTable(Element e){
  name=e.getAttributeValue("name");
  primaryKey=new ClayPrimaryKey(e.getChild("primary-key"));
  @SuppressWarnings("unchecked") List<Element> columnList=(List<Element>)(e.getChild("column-list").getChildren());
  columns=new ClayColumn[columnList.size()];
  for (int i=0; i < this.columns.length; i++) {
    this.columns[i]=new ClayColumn(columnList.get(i));
  }
  Element foreignKeysList=e.getChild("foreign-key-list");
  if (foreignKeysList != null) {
    @SuppressWarnings("unchecked") List<Element> foreignKeyList=(List<Element>)(foreignKeysList.getChildren());
    foreignKeys=new ClayForegnKey[foreignKeyList.size()];
    for (int i=0; i < this.foreignKeys.length; i++) {
      this.foreignKeys[i]=new ClayForegnKey(foreignKeyList.get(i));
    }
  }
}
 

Example 22

From project Carolina-Digital-Repository, under directory /access/src/main/java/edu/unc/lib/dl/ui/service/.

Source file: RssParserService.java

  21 
vote

private static RssFeedBean buildRssFeed(Document document,int maxResults) throws Exception {
  RssFeedBean rssFeed=new RssFeedBean();
  Element rootElement=null;
  Element channelElement=null;
  String rssFeedVersion=null;
  if (null == document)   throw new Exception("Empty document");
  rootElement=document.getRootElement();
  if (!"rss".equalsIgnoreCase(rootElement.getName()))   throw new Exception("Invalid XML");
  rssFeedVersion=rootElement.getAttributeValue("version");
  channelElement=rootElement.getChild("channel");
  if (null == channelElement)   throw new Exception("Empty feed");
  rssFeed=getHeader(channelElement);
  rssFeed.setVersion(rssFeedVersion);
  addFeedItems(channelElement,rssFeed,maxResults);
  return (rssFeed);
}
 

Example 23

From project BG7, under directory /src/com/era7/bioinfo/annotation/gb/.

Source file: ControlGenBankFilesQuality.java

  19 
vote

private static boolean controlaCalidadFiles(File gbFile,File xmlFile){
  System.out.println("xmlFile.getName() = " + xmlFile.getName());
  System.out.println("gbFile.getName() = " + gbFile.getName());
  BufferedReader reader=null;
  boolean noError=true;
  try {
    Annotation gbAnnotation=ImportGenBankFiles.importGenBankFile(gbFile);
    reader=new BufferedReader(new FileReader(xmlFile));
    StringBuilder stBuilder=new StringBuilder();
    String line=null;
    while ((line=reader.readLine()) != null) {
      stBuilder.append(line);
    }
    reader.close();
    Annotation xmlAnnotation=new Annotation(stBuilder.toString());
    PredictedGenes gbPredictedGenes=new PredictedGenes(gbAnnotation.asJDomElement().getChild(PredictedGenes.TAG_NAME));
    PredictedRnas gbPredictedRnas=new PredictedRnas(gbAnnotation.asJDomElement().getChild(PredictedRnas.TAG_NAME));
    PredictedGenes xmlPredictedGenes=new PredictedGenes(xmlAnnotation.asJDomElement().getChild(PredictedGenes.TAG_NAME));
    PredictedRnas xmlPredictedRnas=new PredictedRnas(xmlAnnotation.asJDomElement().getChild(PredictedRnas.TAG_NAME));
    System.out.println("Checking contig genes....");
    List<Element> xmlContigs=xmlPredictedGenes.asJDomElement().getChildren(ContigXML.TAG_NAME);
    List<Element> gbContigs=gbPredictedGenes.asJDomElement().getChildren(ContigXML.TAG_NAME);
    noError=noError && checkGenesContigs(xmlContigs,gbContigs);
    System.out.println("Checking contig rnas....");
    List<Element> xmlContigsRnas=xmlPredictedRnas.asJDomElement().getChildren(ContigXML.TAG_NAME);
    List<Element> gbContigsRnas=gbPredictedRnas.asJDomElement().getChildren(ContigXML.TAG_NAME);
    noError=noError && checkRnasContigs(xmlContigsRnas,gbContigsRnas);
  }
 catch (  Exception ex) {
    Logger.getLogger(ControlGenBankFilesQuality.class.getName()).log(Level.SEVERE,null,ex);
    noError=false;
  }
  return noError;
}
 

Example 24

From project bioportal-service, under directory /src/main/java/edu/mayo/cts2/framework/plugin/service/bioportal/rest/.

Source file: BioportalRssModuleParser.java

  19 
vote

public Module parse(Element element){
  Namespace ns=Namespace.getNamespace(NS_URI);
  String date=element.getChildText("date",ns);
  DateFormat formatter=new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy");
  try {
    return new DateModule(formatter.parse(date));
  }
 catch (  ParseException e) {
    throw new RuntimeException(e);
  }
}