コード例 #1
0
ファイル: JdomTest.java プロジェクト: dalinhuang/jasonpros
  public void xml() {
    XmlDocument document = new XmlDocument();
    document.loadXmlString(xml);
    Element root = document.getRoot();
    Element count = document.getChildElement(root, "Count");
    Element begin = document.getChildElement(root, "Begin");
    Element end = document.getChildElement(root, "End");
    Element result = document.getChildElement(root, "Result");
    String resultText = result.getText();
    if (StringUtils.equals("OK", resultText)) {
      Element para = document.getChildElement(root, "Parameter");
      Element[] docs = document.getChildElements(para);
      for (Element doc : docs) {
        String name = doc.getName();
        System.out.println(name);
        Element[] dataDocs = document.getChildElements(doc);
        for (Element dataDoc : dataDocs) {
          String dataDocName = dataDoc.getName();
          String dataDocText = document.getText(dataDoc);
          System.out.println(dataDocName + "   dataDocText:" + dataDocText);
        }
      }
    }

    System.out.println(count.getText());
    org.jdom.Document document2 = document.getDocument();
  }
コード例 #2
0
ファイル: EditUtils.java プロジェクト: eENVplus/Geonetwork
  /**
   * Performs common editor preprocessing tasks.
   *
   * @param params
   * @param context
   * @throws Exception
   */
  public void preprocessUpdate(Element params, ServiceContext context) throws Exception {

    Dbms dbms = (Dbms) context.getResourceManager().open(Geonet.Res.MAIN_DB);
    String id = Util.getParam(params, Params.ID);

    // -----------------------------------------------------------------------
    // --- handle current tab and position

    Element elCurrTab = params.getChild(Params.CURRTAB);
    Element elCurrPos = params.getChild(Params.POSITION);

    if (elCurrTab != null) {
      session.setProperty(Geonet.Session.METADATA_SHOW, elCurrTab.getText());
    }
    if (elCurrPos != null)
      session.setProperty(Geonet.Session.METADATA_POSITION, elCurrPos.getText());

    // -----------------------------------------------------------------------
    // --- check access
    int iLocalId = Integer.parseInt(id);

    if (!dataManager.existsMetadata(dbms, iLocalId)) throw new BadParameterEx("id", id);

    if (!accessMan.canEdit(context, id)) Lib.resource.denyAccess(context);
  }
コード例 #3
0
ファイル: NameGenPanel.java プロジェクト: cpmeister/pcgen
  private String loadList(Element list) throws DataConversionException {
    pcgen.core.doomsdaybook.DDList dataList =
        new pcgen.core.doomsdaybook.DDList(
            allVars, list.getAttributeValue("title"), list.getAttributeValue("id"));
    java.util.List<?> elements = list.getChildren();

    for (final Object element : elements) {
      Element child = (Element) element;
      String elementName = child.getName();

      if (elementName.equals("VALUE")) {
        WeightedDataValue dv =
            new WeightedDataValue(child.getText(), child.getAttribute("weight").getIntValue());
        List<?> subElements = child.getChildren("SUBVALUE");

        for (final Object subElement1 : subElements) {
          Element subElement = (Element) subElement1;
          dv.addSubValue(subElement.getAttributeValue("type"), subElement.getText());
        }

        dataList.add(dv);
      }
    }

    allVars.addDataElement(dataList);

    return dataList.getId();
  }
コード例 #4
0
ファイル: MspMote.java プロジェクト: zxombie/contiki-arduino
  public boolean setConfigXML(
      Simulation simulation, Collection<Element> configXML, boolean visAvailable) {
    for (Element element : configXML) {
      String name = element.getName();

      if (name.equals("motetype_identifier")) {

        setSimulation(simulation);
        myMoteType = (MspMoteType) simulation.getMoteType(element.getText());
        getType().setIdentifier(element.getText());

        initEmulator(myMoteType.getContikiFirmwareFile());
        myMoteInterfaceHandler = createMoteInterfaceHandler();

      } else if (name.equals("interface_config")) {
        String intfClass = element.getText().trim();
        if (intfClass.equals("se.sics.cooja.mspmote.interfaces.MspIPAddress")) {
          intfClass = IPAddress.class.getName();
        }
        Class<? extends MoteInterface> moteInterfaceClass =
            simulation.getGUI().tryLoadClass(this, MoteInterface.class, intfClass);

        if (moteInterfaceClass == null) {
          logger.fatal("Could not load mote interface class: " + intfClass);
          return false;
        }

        MoteInterface moteInterface = getInterfaces().getInterfaceOfType(moteInterfaceClass);
        moteInterface.setConfigXML(element.getChildren(), visAvailable);
      }
    }

    return true;
  }
コード例 #5
0
ファイル: QueryMasterProcessor.java プロジェクト: URMC/i2b2
  @SuppressWarnings("unchecked")
  public static QueryConceptTreeNodeFactoryProduct process(
      Element mainXMLElement, String originalXml) {
    ArrayList<QueryConceptTreeNodeData> newNodes = new ArrayList<QueryConceptTreeNodeData>();
    String description = null;
    List<Element> children = mainXMLElement.getChildren();
    QueryConceptTreeNodeData node = new QueryConceptTreeNodeData();
    // bugbug:  why do we need a loop? we only have one node
    for (Iterator<Element> itr = children.iterator(); itr.hasNext(); ) {
      Element element = itr.next();
      if (element.getName().equalsIgnoreCase(QUERY_MASTER_ID)) {
        node.fullname(MASTER_ID_PREFIX + element.getText().trim());
      } else if (element.getName().equalsIgnoreCase(NAME)) {
        // System.err.println("A Patient Count??");
        description = element.getText().trim();
        if (!description.startsWith(PREV_QUERY_PREFIX))
          description = PREV_QUERY_PREFIX + description;
        node.name(description);
        node.tooltip(description);
      }
    }
    node.finalizeOriginalXML(originalXml);
    node.visualAttribute(PQ);

    newNodes.add(node);
    return new QueryConceptTreeNodeFactoryProduct(newNodes);
  }
コード例 #6
0
ファイル: EnumXMLHandler.java プロジェクト: ajaybhaga/commonj
 @SuppressWarnings("unchecked")
 public Object fromXML(Class<?> c, Element element, PersistenceInstance pi) {
   if (element.getText().length() == 0) {
     return null;
   }
   return Enum.valueOf((Class<Enum>) c, element.getText());
 }
コード例 #7
0
ファイル: SiteData.java プロジェクト: rya/cms-ce
 public ResourceKey getLocaleResolver() {
   Element element = getAndEnsureElement(getAndEnsureRootElement(), LOCALE_RESOLVER_ELEMENT_NAME);
   if (element.getText() == null || element.getText().length() == 0) {
     return null;
   }
   return new ResourceKey(element.getText());
 }
コード例 #8
0
 @Override
 protected void extractValidationRules(Element validationElement) {
   super.extractValidationRules(validationElement);
   String maxLength = this.extractValue(validationElement, "maxlength");
   if (null != maxLength) {
     this.setMaxLength(Integer.parseInt(maxLength));
   }
   String minLength = this.extractValue(validationElement, "minlength");
   if (null != minLength) {
     this.setMinLength(Integer.parseInt(minLength));
   }
   String regexp = this.extractValue(validationElement, "regexp");
   if (null != regexp && regexp.trim().length() > 0) {
     this.setRegexp(regexp);
   }
   Element valueElement = validationElement.getChild("value");
   if (null != valueElement) {
     this.setValue(valueElement.getText());
     this.setValueAttribute(valueElement.getAttributeValue("attribute"));
   }
   Element rangeStartElement = validationElement.getChild("rangestart");
   if (null != rangeStartElement) {
     this.setRangeStart(rangeStartElement.getText());
     this.setRangeStartAttribute(rangeStartElement.getAttributeValue("attribute"));
   }
   Element rangeEndElement = validationElement.getChild("rangeend");
   if (null != rangeEndElement) {
     this.setRangeEnd(rangeEndElement.getText());
     this.setRangeEndAttribute(rangeEndElement.getAttributeValue("attribute"));
   }
 }
コード例 #9
0
ファイル: SiteData.java プロジェクト: rya/cms-ce
 public ResourceKey getDeviceClassResolver() {
   Element element =
       getAndEnsureElement(getAndEnsureRootElement(), DEVICE_CLASS_RESOLVER_ELEMENT_NAME);
   if (element.getText() == null || element.getText().length() == 0) {
     return null;
   }
   return new ResourceKey(element.getText());
 }
コード例 #10
0
ファイル: SiteData.java プロジェクト: rya/cms-ce
 public ResourceKey getDefaultLocalizationResource() {
   Element element =
       getAndEnsureElement(getAndEnsureRootElement(), DEFAULT_LOCALIZATION_RESOURCE_ELMENT_NAME);
   if (element.getText() == null || element.getText().length() == 0) {
     return null;
   }
   return new ResourceKey(element.getText());
 }
コード例 #11
0
ファイル: SiteData.java プロジェクト: rya/cms-ce
 public ResourceKey getPathToResources() {
   Element element =
       getAndEnsureElement(getAndEnsureRootElement(), PATH_TO_HOME_RESOURCES_ELEMENT_NAME);
   if (element.getText() == null || element.getText().length() == 0) {
     return null;
   }
   return new ResourceKey(element.getText());
 }
コード例 #12
0
ファイル: draw.java プロジェクト: bossiernesto/jvmbytecodes
  private void load_snap_from_xml(Element snap, StructureCollection structs, LinkedList tempList)
      throws VisualizerLoadException {
    Iterator iterator = snap.getChildren().iterator();

    if (!iterator.hasNext()) throw new VisualizerLoadException("Ran out of elements");

    structs.loadTitle((Element) (iterator.next()), tempList, this);
    structs.calcDimsAndStartPts(tempList, this);

    if (!iterator.hasNext()) return;
    Element child = (Element) iterator.next();

    if (child.getName().compareTo("doc_url") == 0) {
      // load the doc_url
      add_a_documentation_URL(child.getText().trim());
      if (!iterator.hasNext()) return;
      child = (Element) iterator.next();
    }

    if (child.getName().compareTo("pseudocode_url") == 0) {
      // load the psuedocode_url
      add_a_pseudocode_URL(child.getText().trim());
      if (!iterator.hasNext()) return;
      child = (Element) iterator.next();
    }

    if (child.getName().compareTo("audio_text") == 0) {
      // load the psuedocode_url
      add_audio_text(child.getText().trim());
      if (!iterator.hasNext()) return;
      child = (Element) iterator.next();
    }

    // create & load the individual structures, hooking them into the StructureCollection.
    // linespernode : calculate it at end of loadStructure call
    while (child.getName().compareTo("question_ref") != 0) {
      StructureType child_struct = assignStructureType(child);
      child_struct.loadStructure(child, tempList, this);
      structs.addChild(child_struct);

      if (!iterator.hasNext()) return;
      child = (Element) iterator.next();
    }

    if (child.getName().compareTo("question_ref") == 0) {
      // set up question ref
      add_a_question_xml(child.getAttributeValue("ref"));
    } else
      // should never happen
      throw new VisualizerLoadException(
          "Expected question_ref element, but found " + child.getName());

    if (iterator.hasNext()) {
      child = (Element) iterator.next();
      throw new VisualizerLoadException(
          "Found " + child.getName() + " when expecting end of snap.");
    }
  } // load_snap_from_xml
コード例 #13
0
  private void processImage(Element element, IFeed feed) {
    IImage image = Owl.getModelFactory().createImage(feed);

    /* Check wether the Attributes are to be processed by a Contribution */
    processNamespaceAttributes(element, image);

    /* Interpret Children */
    List<?> imageChilds = element.getChildren();
    for (Iterator<?> iter = imageChilds.iterator(); iter.hasNext(); ) {
      Element child = (Element) iter.next();
      String name = child.getName().toLowerCase();

      /* Check wether this Element is to be processed by a Contribution */
      if (processElementExtern(child, image)) continue;

      /* URL */
      else if ("url".equals(name)) { // $NON-NLS-1$
        URI uri = URIUtils.createURI(child.getText());
        if (uri != null) image.setLink(uri);
        processNamespaceAttributes(child, image);
      }

      /* Title */
      else if ("title".equals(name)) { // $NON-NLS-1$
        image.setTitle(child.getText());
        processNamespaceAttributes(child, image);
      }

      /* Link */
      else if ("link".equals(name)) { // $NON-NLS-1$
        URI uri = URIUtils.createURI(child.getText());
        if (uri != null) image.setHomepage(uri);
        processNamespaceAttributes(child, image);
      }

      /* Description */
      else if ("description".equals(name)) { // $NON-NLS-1$
        image.setDescription(child.getText());
        processNamespaceAttributes(child, image);
      }

      /* Width */
      else if ("width".equals(name)) { // $NON-NLS-1$
        int width = StringUtils.stringToInt(child.getTextNormalize());
        if (width >= 0) image.setWidth(width);
        processNamespaceAttributes(child, image);
      }

      /* Height */
      else if ("height".equals(name)) { // $NON-NLS-1$
        int height = StringUtils.stringToInt(child.getTextNormalize());
        if (height >= 0) image.setHeight(height);
        processNamespaceAttributes(child, image);
      }
    }
  }
コード例 #14
0
 @SuppressWarnings("unchecked")
 @Override
 public void parse() throws Exception {
   List<Element> tutorials = rootElement.getChildren();
   for (Element tutorial : tutorials) {
     if (urlRoot.toString().endsWith("/"))
       tutorialList.add(new URL(urlRoot.toString() + tutorial.getText()));
     else tutorialList.add(new URL(urlRoot.toString() + "/" + tutorial.getText()));
   }
 }
コード例 #15
0
  @SuppressWarnings("unchecked")
  private void parseStageRepositoryDetails(
      final String profileId, final Map<String, StageRepository> repoStubs, boolean filterUser)
      throws RESTLightClientException {
    // System.out.println( repoStubs );

    Document doc = get(PROFILE_REPOS_PATH_PREFIX + profileId);

    // System.out.println( new XMLOutputter().outputString( doc ) );

    XPath repoXPath = newXPath(STAGE_REPO_DETAIL_XPATH);

    List<Element> repoDetails;
    try {
      repoDetails = repoXPath.selectNodes(doc.getRootElement());
    } catch (JDOMException e) {
      throw new RESTLightClientException(
          "Failed to select detail sections for staging-profile repositories.", e);
    }

    if (repoDetails != null && !repoDetails.isEmpty()) {
      for (Element detail : repoDetails) {
        String repoId = detail.getChild(REPO_ID_ELEMENT).getText();
        String key = profileId + "/" + repoId;

        StageRepository repo = repoStubs.get(key);

        if (repo == null) {
          continue;
        }

        Element uid = detail.getChild(USER_ID_ELEMENT);
        if (uid != null && getUser() != null && getUser().equals(uid.getText().trim())) {
          repo.setUser(uid.getText().trim());
        } else {
          if (filterUser) {
            repoStubs.remove(key);
          }
        }

        Element url = detail.getChild(REPO_URI_ELEMENT);
        if (url != null) {
          repo.setUrl(url.getText());
        }

        Element desc = detail.getChild(REPO_DESCRIPTION_ELEMENT);
        if (desc != null) {
          repo.setDescription(desc.getText());
        }
      }
    }
  }
コード例 #16
0
  private void addEpisodesTo(
      ItvProgramme program, HtmlNavigator htmlNavigator, List<Element> content) {

    for (Element element : content) {

      Element link = htmlNavigator.firstElementOrNull("./h3/a", element);
      String episodePage = link.getAttributeValue("href");
      Element description = htmlNavigator.firstElementOrNull("./p[@class='progDesc']", element);
      Element date = htmlNavigator.firstElementOrNull("./p[@class='date']", element);

      program.addEpisode(new ItvEpisode(date.getText(), description.getText(), episodePage));
    }
  }
コード例 #17
0
ファイル: ExecuteJAR.java プロジェクト: vjutvik/Contiki-IPsec
  private static void handleExportAttributesFromJAR(Element e, File config, File toDir) {
    for (Element c : ((List<Element>) e.getChildren()).toArray(new Element[0])) {
      Attribute a = c.getAttribute("EXPORT");
      if (a != null && a.getValue().equals("copy")) {
        /* Copy file from JAR */
        File file = GUI.restoreConfigRelativePath(config, new File(c.getText()));
        InputStream inputStream = GUI.class.getResourceAsStream("/" + file.getName());
        if (inputStream == null) {
          throw new RuntimeException("Could not unpack file: " + file);
        }
        byte[] fileData = ArrayUtils.readFromStream(inputStream);
        if (fileData == null) {
          logger.info("Failed unpacking file");
          throw new RuntimeException("Could not unpack file: " + file);
        }
        if (OVERWRITE || !file.exists()) {
          boolean ok = ArrayUtils.writeToFile(file, fileData);
          if (!ok) {
            throw new RuntimeException("Failed unpacking file: " + file);
          }
          logger.info("Unpacked file from JAR: " + file.getName());
        } else if (OVERWRITE) {
          logger.info("Skip: unpack file from JAR: " + file.getName());
        }
      }

      /* Recursive search */
      handleExportAttributesFromJAR(c, config, toDir);
    }
  }
コード例 #18
0
  /**
   * Creates this from a JDOM element.
   *
   * @param jdom input
   */
  public UserQueryInput(Element jdom) {

    // Done in LuceneSearcher#computeQuery
    // protectRequest(jdom);

    for (Object e : jdom.getChildren()) {
      if (e instanceof Element) {
        Element node = (Element) e;
        String nodeName = node.getName();
        String nodeValue = StringUtils.trim(node.getText());
        if (SearchParameter.SIMILARITY.equals(nodeName)) {
          setSimilarity(jdom.getChildText(SearchParameter.SIMILARITY));
        } else {
          if (StringUtils.isNotBlank(nodeValue)) {

            if (SECURITY_FIELDS.contains(nodeName) || nodeName.contains("_op")) {
              addValues(searchPrivilegeCriteria, nodeName, nodeValue);
            } else if (RESERVED_FIELDS.contains(nodeName)) {
              searchOption.put(nodeName, nodeValue);
            } else {
              // addValues(searchCriteria, nodeName, nodeValue);
              // Rename search parameter to lucene index field
              // when needed
              addValues(
                  searchCriteria,
                  (searchParamToLuceneField.containsKey(nodeName)
                      ? searchParamToLuceneField.get(nodeName)
                      : nodeName),
                  nodeValue);
            }
          }
        }
      }
    }
  }
コード例 #19
0
  /*
   * Liest die Scenario Informationen in die entsprechenden Objekte
   * und gibt eine Liste davon zurueck. Siehe dazu auch MeteringProcessStorage.java.
   * @param fileName Dateiname der Storagedatei
   * @return Liste mit den Scenario-Objekte.
   */
  public List getList() {
    List scenariosList = new ArrayList();
    try {
      SAXBuilder builder = new SAXBuilder();
      StorageDoc = builder.build(appPath + storageFileName);
      Root = StorageDoc.getRootElement();
      List scenarioChildren = Root.getChildren("scenario", ipfixConfigNS);
      Iterator listIterator = scenarioChildren.iterator();
      Element currentElement;

      while (listIterator.hasNext()) {
        currentElement = (Element) listIterator.next();
        Scenario currentScenario = new Scenario();
        // currentscenario.setId(Integer.valueOf(currentElement.getAttributeValue("id")));
        currentScenario.setName(currentElement.getChildText("name", ipfixConfigNS));
        currentScenario.setDescription(currentElement.getChildText("descript", ipfixConfigNS));
        List deviceList = new ArrayList();
        Element devices = currentElement.getChild("devices", ipfixConfigNS);
        List childList = devices.getChildren("device", ipfixConfigNS);
        Iterator devicesIterator = childList.iterator();
        while (devicesIterator.hasNext()) {
          Element currentDevice = (Element) devicesIterator.next();
          deviceList.add(currentDevice.getText());
        }
        currentScenario.setDeviceList(deviceList);
        scenariosList.add(currentScenario);
      }

    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return scenariosList;
  }
コード例 #20
0
ファイル: DBXML.java プロジェクト: rsyuxiangyang/haiercard
  public String SqlExcute(String xmlStr) {
    String outstr = "false";
    Document doc;
    Element rootNode;
    String intStr = Basic.decode(xmlStr);

    try {
      Reader reader = new StringReader(intStr);
      SAXBuilder ss = new SAXBuilder();
      doc = ss.build(reader);

      rootNode = doc.getRootElement();

      List list = rootNode.getChildren();

      DBTable datatable = new DBTable();

      for (int i = 0; i < list.size(); i++) {
        Element childRoot = (Element) list.get(i);
        // System.out.print(childRoot.getText());
        outstr = String.valueOf(datatable.SaveDateStr(childRoot.getText()));
      }

    } catch (JDOMException ex) {
      System.out.print(ex.getMessage());
    }
    return outstr;
  }
コード例 #21
0
  public DataSource createDataSource() {

    SAXBuilder sb = new SAXBuilder();
    DataSource dataSource = null;
    try {
      Document xmlDoc = sb.build("config/data.xml");
      Element root = xmlDoc.getRootElement();
      Element url = root.getChild("url");

      dataSource = new DataSource();
      dataSource.setHost(url.getText());
      dataSource.setDbName(root.getChild("database").getText());
      dataSource.setDriverClass(root.getChildText("driver-class"));
      dataSource.setPort(root.getChildText("port"));
      dataSource.setUserLogin(root.getChildText("login"));
      dataSource.setUserPwd(root.getChildText("password"));

    } catch (JDOMException e) {
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return dataSource;
  }
コード例 #22
0
  private static void bindElement(Element parent, Configuration config, String name) {
    Element child = parent.getChild(name);

    if (child != null) {
      config.put(new PropertySimple(name, child.getText()));
    }
  }
コード例 #23
0
ファイル: DAVItem.java プロジェクト: edina-jorum/Jorum-DSpace
  /* (non-Javadoc)
   * @see org.dspace.app.dav.DAVResource#proppatchInternal(int, org.jdom.Element)
   */
  @Override
  protected int proppatchInternal(int action, Element prop)
      throws SQLException, AuthorizeException, IOException, DAVStatusException {
    // Don't need any authorization checks since the Item layer
    // checks authorization for write and delete.

    Namespace ns = prop.getNamespace();
    String propName = prop.getName();

    // "submitter" is the only Item-specific mutable property, rest are
    // live and unchangeable.
    if (ns != null && ns.equals(DAV.NS_DSPACE) && propName.equals("submitter")) {
      if (action == DAV.PROPPATCH_REMOVE) {
        throw new DAVStatusException(DAV.SC_CONFLICT, "The submitter property cannot be removed.");
      }
      String newName = prop.getText();
      EPerson ep = EPerson.findByEmail(this.context, newName);
      if (ep == null) {
        throw new DAVStatusException(
            DAV.SC_CONFLICT,
            "Cannot set submitter, no EPerson found for email address: " + newName);
      }
      this.item.setSubmitter(ep);
      this.item.update();
      return HttpServletResponse.SC_OK;
    }
    throw new DAVStatusException(
        DAV.SC_CONFLICT, "The " + prop.getName() + " property cannot be changed.");
  }
コード例 #24
0
ファイル: QuestManager.java プロジェクト: teeppiphat/scald
  public String[] loadOneDependencie(Element element) {

    // get the children to a list
    List list = element.getChildren();

    // allocate the array according to the size
    String[] names = new String[list.size()];

    // create the iterator to access the list
    Iterator i = list.iterator();
    int cont = 0;

    // temporary element used to get the elements
    Element temp;

    // get the elements from the list
    while (i.hasNext()) {
      // get the first object
      temp = (Element) i.next();
      // put the object in the array
      names[cont] = temp.getText();
      // increase
      cont++;
    }

    // return the array
    return names;
  }
コード例 #25
0
  @Test
  public void containsFilterDepthTest() {
    LOGGER.info("STARTING-> containsFilterDepthTest");

    final List<Element> list = ElementUtils.search(this.root, filter, 0);
    Assert.assertEquals(1, list.size());

    final List<Element> list2 = ElementUtils.search(this.root, filter, 6);
    Assert.assertEquals(maxDepth, list2.size());

    final Filter myFilter =
        new Filter() {
          public boolean matches(Object obj) {
            if (obj instanceof Element) {
              final Element el = ((Element) obj);
              if (el.getName().equals(NAME)) {
                if (el.getText().equals("1") || el.getText().equals("3")) return true;
              }
            }
            return false;
          }
        };
    final List<Element> list3 = ElementUtils.search(this.root, myFilter, 3);
    Assert.assertEquals(2, list3.size());
    final Iterator<?> it = list3.iterator();
    while (it.hasNext()) {
      final Object obj = it.next();
      if (obj instanceof Element) {
        final Element el = (Element) obj;
        LOGGER.info("LOCATED-> " + el.getName() + " level " + el.getText());
      }
    }
  }
コード例 #26
0
 @Override
 public synchronized void fromElement(Element element) {
   props.clear();
   for (Element child : (List<Element>) element.getChildren()) {
     props.put(child.getName(), child.getText());
   }
 }
コード例 #27
0
  /*
   * (non-Javadoc)
   *
   * @see com.sun.syndication.io.ModuleParser#parse(org.jdom.Element)
   */
  public Module parse(Element element) {
    GeoRSSModule geoRSSModule = null;
    new SimpleModuleImpl();

    Element pointElement = element.getChild("point", GeoRSSModule.SIMPLE_NS);
    Element lineElement = element.getChild("line", GeoRSSModule.SIMPLE_NS);
    Element polygonElement = element.getChild("polygon", GeoRSSModule.SIMPLE_NS);
    Element boxElement = element.getChild("box", GeoRSSModule.SIMPLE_NS);
    if (pointElement != null) {
      geoRSSModule = new SimpleModuleImpl();
      String coordinates = pointElement.getText();
      String[] coord = coordinates.trim().split(" ");
      Position pos = new Position(Double.parseDouble(coord[1]), Double.parseDouble(coord[0]));
      geoRSSModule.setGeometry(new Point(pos));
    } else if (lineElement != null) {
      geoRSSModule = new SimpleModuleImpl();
      PositionList posList = parsePosList(lineElement);
      geoRSSModule.setGeometry(new LineString(posList));
    } else if (polygonElement != null) {
      geoRSSModule = new SimpleModuleImpl();
      PositionList posList = parsePosList(polygonElement);
      Polygon poly = new Polygon();
      poly.setExterior(new LinearRing(posList));
      geoRSSModule.setGeometry(poly);
    } else {
      geoRSSModule = (GeoRSSModule) GMLParser.parseGML(element);
    }

    return geoRSSModule;
  }
コード例 #28
0
ファイル: MspMoteID.java プロジェクト: leoqin/Contiki-leo
 public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
   for (Element element : configXML) {
     if (element.getName().equals("id")) {
       setMoteID(Integer.parseInt(element.getText()));
     }
   }
 }
コード例 #29
0
ファイル: QServer.java プロジェクト: Zengwn/jPOS
 private LocalSpace grabSpace(Element e) throws ConfigurationException {
   String uri = e != null ? e.getText() : "";
   Space sp = SpaceFactory.getSpace(uri);
   if (sp instanceof LocalSpace) {
     return (LocalSpace) sp;
   }
   throw new ConfigurationException("Invalid space " + uri);
 }
コード例 #30
0
ファイル: C4AtomApi.java プロジェクト: Reedyuk/atlas
 public static Map<String, String> foreignElementLookup(Iterable<Element> foreignMarkup) {
   Map<String, String> foreignElementLookup = Maps.newHashMap();
   for (Element element : foreignMarkup) {
     foreignElementLookup.put(
         element.getNamespacePrefix() + ":" + element.getName(), element.getText());
   }
   return foreignElementLookup;
 }