Java 类org.jdom.JDOMException 实例源码

项目:gate-core    文件:Plugin.java   
@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;
}
项目:gate-core    文件:AnnotationSchema.java   
/** Creates an AnnotationSchema object from an XSchema file
  * @param anXSchemaURL the URL where to find the XSchema file
  */
public void fromXSchema(URL anXSchemaURL)
            throws ResourceInstantiationException {
  org.jdom.Document jDom = null;
  SAXBuilder saxBuilder = new SAXBuilder(false);
  try {
  try{
    jDom = saxBuilder.build(anXSchemaURL);
  }catch(JDOMException je){
    throw new ResourceInstantiationException(je);
  }
  } catch (java.io.IOException ex) {
    throw new ResourceInstantiationException(ex);
  }
  workWithJDom(jDom);
}
项目:gate-core    文件:AnnotationSchema.java   
/** Creates an AnnotationSchema object from an XSchema file
  * @param anXSchemaInputStream the Input Stream containing the XSchema file
  */
public void fromXSchema(InputStream anXSchemaInputStream)
            throws ResourceInstantiationException {
  org.jdom.Document jDom = null;
  SAXBuilder saxBuilder = new SAXBuilder(false);
  try {
  try{
    jDom = saxBuilder.build(anXSchemaInputStream);
  }catch(JDOMException je){
    throw new ResourceInstantiationException(je);
  }
  } catch (java.io.IOException ex) {
    throw new ResourceInstantiationException(ex);
  }
  workWithJDom(jDom);
}
项目:gate-core    文件:CreoleRegisterImpl.java   
private void processFullCreoleXmlTree(Plugin plugin,
    Document jdomDoc, CreoleAnnotationHandler annotationHandler)
    throws GateException, IOException, JDOMException {
  // now we can process any annotations on the new classes
  // and augment the XML definition
  annotationHandler.processAnnotations(jdomDoc);

  // debugging
  if(DEBUG) {
    XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat());
    xmlOut.output(jdomDoc, System.out);
  }

  // finally, parse the augmented definition with the normal parser
  DefaultHandler handler =
      new CreoleXmlHandler(this, plugin);
  SAXOutputter outputter =
      new SAXOutputter(handler, handler, handler, handler);
  outputter.output(jdomDoc);
  if(DEBUG) {
    Out.prln("done parsing " + plugin);
  }
}
项目:gate-core    文件:TestResourceReference.java   
@Override
public Document getCreoleXML() throws Exception, JDOMException {
  Document doc = new Document();
  Element element = null;
  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(TestResource.class.getName());
  element.addContent(classElement);
  return doc;
}
项目:teamcity-msteams-notifier    文件:MsTeamsNotificationSettingsTest.java   
@SuppressWarnings("unchecked")
@Test
public void test_WebookConfig() throws JDOMException, IOException{
    SAXBuilder builder = new SAXBuilder();
    List<MsTeamsNotificationConfig> configs = new ArrayList<MsTeamsNotificationConfig>();
    builder.setIgnoringElementContentWhitespace(true);
        Document doc = builder.build("src/test/resources/testdoc2.xml");
        Element root = doc.getRootElement();
        if(root.getChild("msteamsNotifications") != null){
            Element child = root.getChild("msteamsNotifications");
            if ((child.getAttribute("enabled") != null) && (child.getAttribute("enabled").equals("true"))){
                List<Element> namedChildren = child.getChildren("msteamsNotification");
                for(Iterator<Element> i = namedChildren.iterator(); i.hasNext();)
                {
                    Element e = i.next();
                    MsTeamsNotificationConfig whConfig = new MsTeamsNotificationConfig(e);
                    configs.add(whConfig);
                }
            }
        }


    for (MsTeamsNotificationConfig c : configs){
        MsTeamsNotification wh = new MsTeamsNotificationImpl();
        wh.setEnabled(c.getEnabled());
        //msteamsNotification.addParams(c.getParams());
        System.out.println(wh.isEnabled().toString());

    }
}
项目:teamcity-msteams-notifier    文件:MsTeamsNotificationSettingsTest.java   
@SuppressWarnings("unchecked")
@Test
public void test_ReadXml() throws JDOMException, IOException {
    SAXBuilder builder = new SAXBuilder();
    //builder.setValidation(true);
    builder.setIgnoringElementContentWhitespace(true);

        Document doc = builder.build("src/test/resources/testdoc1.xml");
        Element root = doc.getRootElement();
        System.out.println(root.toString());
        if(root.getChild("msteamsNotifications") != null){
            Element child = root.getChild("msteamsNotifications");
            if ((child.getAttribute("enabled") != null) && (child.getAttribute("enabled").equals("true"))){
                List<Element> namedChildren = child.getChildren("msteamsNotification");
                for(Iterator<Element> i = namedChildren.iterator(); i.hasNext();)
                {
                    Element e = i.next();
                    System.out.println(e.toString() + e.getAttributeValue("url"));
                    //assertTrue(e.getAttributeValue("url").equals("http://something"));
                    if(e.getChild("parameters") != null){
                        Element eParams = e.getChild("parameters");
                        List<Element> paramsList = eParams.getChildren("param");
                        for(Iterator<Element> j = paramsList.iterator(); j.hasNext();)
                        {
                            Element eParam = j.next();
                            System.out.println(eParam.toString() + eParam.getAttributeValue("name"));
                            System.out.println(eParam.toString() + eParam.getAttributeValue("value"));
                        }
                    }
                }
            }
        }

}
项目:educational-plugin    文件:EduRemoteCourseModuleBuilder.java   
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
  throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module baseModule = super.createModule(moduleModel);
  String languageName = myCourse.getLanguageID();
  Language language = Language.findLanguageByID(languageName);
  if (language != null) {
    EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
    if (configurator != null) {
      Project project = baseModule.getProject();
      myGenerator.setSelectedCourse(myCourse);
      myGenerator.generateProject(project, project.getBaseDir());
      Course course = StudyTaskManager.getInstance(project).getCourse();
      if (course == null) {
        LOG.info("failed to generate course");
        return baseModule;
      }
      configurator.createCourseModuleContent(moduleModel, project, course, getModuleFileDirectory());
    }
  }
  return baseModule;
}
项目:educational-plugin    文件:EduModuleBuilderUtils.java   
public static void createCourseFromCourseInfo(@NotNull ModifiableModuleModel moduleModel,
                                       @NotNull Project project,
                                       @NotNull StudyProjectGenerator generator,
                                       @NotNull Course course,
                                       @Nullable String moduleDir) throws JDOMException, ModuleWithNameAlreadyExists, ConfigurationException, IOException {
  generator.setSelectedCourse(course);
  generator.generateProject(project, project.getBaseDir());
  updateAdaptiveCourseTaskFileNames(project, course);

  course = StudyTaskManager.getInstance(project).getCourse();
  if (course == null) {
    LOG.info("failed to generate course");
    return;
  }
  createCourseModuleContent(moduleModel, project, course, moduleDir);
}
项目:educational-plugin    文件:EduTaskModuleBuilder.java   
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module module = super.createModule(moduleModel);
  Course course = myTask.getLesson().getCourse();
  String directory = getModuleFileDirectory();
  if (directory == null) {
    return module;
  }
  VirtualFile moduleDir = VfsUtil.findFileByIoFile(new File(directory), true);
  if (moduleDir == null) {
    return module;
  }
  VirtualFile src = moduleDir.findChild(EduNames.SRC);
  if (src == null) {
    return module;
  }
  createTask(module.getProject(), course, src);
  ModuleRootModificationUtil.addDependency(module, myUtilModule);
  EduIntellijUtils.addJUnit(module);
  return module;
}
项目:educational-plugin    文件:EduCustomCourseModuleBuilder.java   
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
  throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module baseModule = super.createModule(moduleModel);
  if (mySelectedCourse != null) {
    String languageName = mySelectedCourse.getLanguageID();
    Language language = Language.findLanguageByID(languageName);
    if (language != null) {
      EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
      if (configurator != null) {
        myGenerator.setSelectedCourse(mySelectedCourse);
        Project project = baseModule.getProject();
        myGenerator.generateProject(project, project.getBaseDir());
        Course course = StudyTaskManager.getInstance(project).getCourse();
        if (course == null) {
          LOG.info("failed to generate course");
          return baseModule;
        }
        configurator.createCourseModuleContent(moduleModel, project, course, getModuleFileDirectory());
      }
    }
  }
  return baseModule;
}
项目:educational-plugin    文件:EduBuiltInServerUtils.java   
@Nullable
private static Element readComponent(@NotNull SAXBuilder parser, @NotNull String projectPath) {
  Element component = null;
  try {
    String studyProjectXML = projectPath + STUDY_PROJECT_XML_PATH;
    Document xmlDoc = parser.build(new File(studyProjectXML));
    Element root = xmlDoc.getRootElement();
    component = root.getChild("component");
  }
  catch (JDOMException | IOException ignored) {
  }

  return component;
}
项目:educational-plugin    文件:StudyMigrationTest.java   
private void doTest(int version) throws IOException, JDOMException, StudySerializationUtils.StudyUnrecognizedFormatException {
  final String name = PlatformTestUtil.getTestName(this.name.getMethodName(), true);
  final Path before = getTestDataPath().resolve(name + ".xml");
  final Path after = getTestDataPath().resolve(name + ".after.xml");
  Element element = JdomKt.loadElement(before);
  Element converted = element;
  switch (version) {
    case 1:
      converted = StudySerializationUtils.Xml.convertToSecondVersion(element);
      break;
    case 3:
      converted = StudySerializationUtils.Xml.convertToForthVersion(element);
      break;
    case 4:
      converted = StudySerializationUtils.Xml.convertToFifthVersion(element);
      break;
  }
  assertTrue(JDOMUtil.areElementsEqual(converted, JdomKt.loadElement(after)));
}
项目:educational-plugin    文件:EduKotlinKoansModuleBuilder.java   
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module baseModule = super.createModule(moduleModel);
  Project project = baseModule.getProject();
  EduProjectGenerator generator = new EduProjectGenerator();
  if (myCourse == null) {
    File courseRoot = StudyUtils.getBundledCourseRoot(DEFAULT_COURSE_NAME, EduKotlinKoansModuleBuilder.class);
    final Course course = generator.addLocalCourse(FileUtil.join(courseRoot.getPath(), DEFAULT_COURSE_NAME));
    if (course == null) {
      LOG.info("Failed to find course " + DEFAULT_COURSE_NAME);
      return baseModule;
    }
  }
  myCourse.setLanguage("kotlin");
  EduModuleBuilderUtils.createCourseFromCourseInfo(moduleModel, project, generator, myCourse, getModuleFileDirectory());
  return baseModule;
}
项目:LAS    文件:Confluence.java   
private String findFirstVariable(Category category, LASConfig lasConfig, HttpServletRequest request) throws JDOMException, LASException, UnsupportedEncodingException, HttpException, IOException {
    String dsid = null;     
    if ( category.hasVariableChildrenAttribute() ) {
        if ( category.getDataset() != null && category.getDataset().getID() != null ) {
            return category.getDataset().getID();
        }
        return category.getChildren_DatasetID();
    } else {
        ArrayList<Category> cats = getCategories(category.getID(), lasConfig, request, true);
        for (Iterator catIt = cats.iterator(); catIt.hasNext();) {
            Category cat = (Category) catIt.next();
            dsid = findFirstVariable(cat, lasConfig, request);
        }
    }
    return dsid;
}
项目:LAS    文件:JavaBackendService.java   
public String makeRegionIndex(String backendRequestXML, String cacheFileName) throws IOException, JDOMException {
    LASBackendRequest lasBackendRequest = new LASBackendRequest();      
    JDOMUtils.XML2JDOM(backendRequestXML, lasBackendRequest);
    LASBackendResponse lasBackendResponse = new LASBackendResponse();

    String sample = JDOMUtils.getResourcePath(this, "resources/java/xml/region_index.xml");
    String output = lasBackendRequest.getResultAsFile("index");
    copyBytes(sample, output);
    // Create the map scale XML file if requested.
    String index_filename = lasBackendRequest.getResultAsFileByType("index");
    if ( index_filename != null && !index_filename.equals("") ) {
        File index = new File(index_filename);
        LASRegionIndex lasRegionIndex = new LASRegionIndex(index);
        lasRegionIndex.write(index);
    }

    lasBackendResponse.addResponseFromRequest(lasBackendRequest);
    return lasBackendResponse.toString();
}
项目:LAS    文件:LASConfig.java   
/**
 * Get data access URL.  If fds is set to true, then the FDS URL will be
 * returned in every case.  If the fds boolean is set to false, then the
 * actual OPeNDAP URL of the remote data set will be returned where available.
 * If no remote URL is available, the the FDS URL will be returned.
 * @param xpath the XPath of the variable
 * @param fds true if FDS URL is required
 * @throws JDOMException
 * @throws LASException
 */
public String getDataAccessURL(String xpath, boolean fds) throws LASException, JDOMException {
    String url = "";
    String dataObjectURL = getDataObjectURL(xpath);
    if (dataObjectURL == null || dataObjectURL.equals("")) {
        return url;
    }
    // If this is a local data set then fds must be set to true.
    if ( !dataObjectURL.startsWith("http:")) {
        fds = true;
    }
    if (fds) {
        url = getFTDSURL(xpath);
    } else {
        url = dataObjectURL;
    }
    return url;
}
项目:intellij-ce-playground    文件:JpsLoaderBase.java   
private static Element tryLoadRootElement(File file) throws IOException, JDOMException {
  for (int i = 0; i < MAX_ATTEMPTS - 1; i++) {
    try {
      return JDOMUtil.loadDocument(file).getRootElement();
    }
    catch (Exception e) {
      LOG.info("Loading attempt #" + i + " failed", e);
    }
    //most likely configuration file is being written by IDE so we'll wait a little
    try {
      //noinspection BusyWait
      Thread.sleep(300);
    }
    catch (InterruptedException ignored) { }
  }
  return JDOMUtil.loadDocument(file).getRootElement();
}
项目:LAS    文件:LASConfig.java   
/**
 * Get all of the attributes from the parent data set element.
 * @param varXPath the variable whose parent data set will be used
 * @return the attributes
 * @throws JDOMException
 */
public HashMap <String, String> getDatasetAttributes(String varXPath) throws JDOMException {
    HashMap<String, String> attrs = new HashMap<String, String>();
    if (!varXPath.contains("@ID")) {
        String[] parts = varXPath.split("/");
        // Throw away index 0 since the string has a leading "/".
        varXPath = "/"+parts[1]+"/"+parts[2]+"/dataset[@ID='"+parts[3]+"']/"+parts[4]+"/variable[@ID='"+parts[5]+"']";
    }

    Element variable = getElementByXPath(varXPath);
    Element dataset = variable.getParentElement().getParentElement();
    List attributes = dataset.getAttributes();
    for (Iterator iter = attributes.iterator(); iter.hasNext();) {
        Attribute attr = (Attribute) iter.next();
        String name = attr.getName();
        String value = attr.getValue();
        if ( name != null && value != null && !name.equals("") && !value.equals("") ) {
           attrs.put(name, value );
        }
    }
    return attrs;
}
项目:zap-maven-plugin    文件:AlertsFile.java   
public static List<Alert> getAlertsFromFile(File file, String alertType) throws JDOMException, IOException {
    List<Alert> alerts =  new ArrayList<>();
    SAXBuilder parser = new SAXBuilder();
    Document alertsDoc = parser.build(file);
    @SuppressWarnings("unchecked")
    List<Element> alertElements = alertsDoc.getRootElement().getChildren(alertType);
    for (Element element: alertElements){
        Alert alert = new Alert(
                element.getAttributeValue("alert"),
                element.getAttributeValue("url"),
                element.getAttributeValue("risk"),
                element.getAttributeValue("confidence"),
                element.getAttributeValue("param"),
                element.getAttributeValue("other"));
        alerts.add(alert);
    }
    return alerts;
}
项目:LAS    文件:LASConfig.java   
private Grid fillGrid(String ID) throws JDOMException, LASException {
    Element gridE = null;
    ArrayList<Element> axes_list = new ArrayList<Element>();
    Element gt = getElementByXPath("/lasdata/grids/grid[@ID='"+ID+"']");
    if ( gt == null ) return null;
    gridE = (Element) gt.clone();
    List axes = gridE.getChildren("axis");
    for (Iterator axisIt = axes.iterator(); axisIt.hasNext();) {
        Element axis_ref = (Element) axisIt.next();
        String axisID = axis_ref.getAttributeValue("IDREF");
        Element axisE = (Element) getElementByXPath("/lasdata/axes/axis[@ID='"+axisID+"']").clone();
        String type = axisE.getAttributeValue("type");
        axes_list.add(axisE);
    }
    // Replace the references with the actual axis definition.
    if ( gridE != null ) {
        gridE.setContent(axes_list);
        return new Grid(gridE);
    } else {
        return null;
    }
}
项目:LAS    文件:LASConfig.java   
/**
 * Get the grid_type for the variable (regular, scattered, ...)
 * @param dsID
 * @param varID
 * @throws JDOMException
 */
public String getGridType(String dsID, String varID) throws JDOMException {
    String grid_type="";

    // Try to get a variable with this ID:

    String varXPath = "/lasdata/datasets/dataset[@ID='"+dsID+"']/variables/variable[@ID='"+varID+"']";
    Element var = getElementByXPath(varXPath);

    // If it's null try to get a composite with this ID.
    if ( var == null ) {
        varXPath = "/lasdata/datasets/dataset[@ID='"+dsID+"']/composite/variable[@ID='"+varID+"']";
        var = getElementByXPath(varXPath);
    }
    if ( var != null ) {
        grid_type = var.getAttributeValue("grid_type");
        if ( grid_type == null ) {
            grid_type = "";
        }
    }
    return grid_type;
}
项目:teamcity-telegram-plugin    文件:TelegramSettingsManager.java   
private synchronized void reloadConfiguration() throws JDOMException, IOException {
  LOG.info("Loading configuration file: " + configFile);
  Document document = JDOMUtil.loadDocument(configFile.toFile());

  Element root = document.getRootElement();

  TelegramSettings newSettings = new TelegramSettings();
  newSettings.setBotToken(unscramble(root.getAttributeValue(BOT_TOKEN_ATTR)));
  newSettings.setPaused(Boolean.parseBoolean(root.getAttributeValue(PAUSE_ATTR)));
  newSettings.setUseProxy(Boolean.parseBoolean(root.getAttributeValue(USE_PROXY_ATTR)));
  newSettings.setProxyServer(root.getAttributeValue(PROXY_SERVER_ATTR));
  newSettings.setProxyPort(restoreInteger(root.getAttributeValue(PROXY_PORT_ATTR)));
  newSettings.setProxyUsername(root.getAttributeValue(PROXY_PASSWORD_ATTR));
  newSettings.setProxyPassword(unscramble(root.getAttributeValue(PROXY_PASSWORD_ATTR)));

  settings = newSettings;
  botManager.reloadIfNeeded(settings);
}
项目:intellij-ce-playground    文件:ModuleBuilder.java   
@NotNull
public Module createAndCommitIfNeeded(@NotNull Project project, @Nullable ModifiableModuleModel model, boolean runFromProjectWizard)
  throws InvalidDataException, ConfigurationException, IOException, JDOMException, ModuleWithNameAlreadyExists {
  final ModifiableModuleModel moduleModel = model != null ? model : ModuleManager.getInstance(project).getModifiableModel();
  final Module module = createModule(moduleModel);
  if (model == null) moduleModel.commit();

  if (runFromProjectWizard) {
    StartupManager.getInstance(module.getProject()).runWhenProjectIsInitialized(new DumbAwareRunnable() {
      @Override
      public void run() {
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          @Override
          public void run() {
            onModuleInitialized(module);
          }
        });
      }
    });
  }
  else {
    onModuleInitialized(module);
  }
  return module;
}
项目:intellij-ce-playground    文件:ProjectFromSourcesBuilderImpl.java   
@Nullable
private static ModuleType getModuleType(ModuleDescriptor moduleDescriptor) throws InvalidDataException, JDOMException, IOException {
  if (moduleDescriptor.isReuseExistingElement()) {
    final File file = new File(moduleDescriptor.computeModuleFilePath());
    if (file.exists()) {
      final Element rootElement = JDOMUtil.loadDocument(file).getRootElement();
      final String type = rootElement.getAttributeValue("type");
      if (type != null) {
        return ModuleTypeManager.getInstance().findByID(type);
      }
    }
    return null;
  }
  else {
    return moduleDescriptor.getModuleType();
  }
}
项目:LAS    文件:LASConfig.java   
/**
 * Get time selector object the specified variable
 * @param varpath XPath to the variable
 * @throws LASException
 *
 */
public TimeAxis getTime(String varpath) throws JDOMException, LASException {

    /*
     * We know this is a variable XPath.  If it's "old style" fix it.
     */
    if (!varpath.contains("@ID")) {
        String[] parts = varpath.split("/");
        // Throw away index 0 since the string has a leading "/".
        varpath = "/"+parts[1]+"/"+parts[2]+"/dataset[@ID='"+parts[3]+"']/"+parts[4]+"/variable[@ID='"+parts[5]+"']";
    }

    Element variable = getElementByXPath(varpath);
    return getTime(variable);

}
项目:LAS    文件:LASConfig.java   
public Variable getVariableByXPath(String xpath) throws JDOMException {
    String dsid;
    if (!xpath.contains("@ID")) {
        String[] parts = xpath.split("/");
        // Throw away index 0 since the string has a leading "/".
        xpath = "/"+parts[1]+"/"+parts[2]+"/dataset[@ID='"+parts[3]+"']/"+parts[4]+"/variable[@ID='"+parts[5]+"']";
        dsid = parts[3];
    } else {
        dsid = xpath.substring(xpath.indexOf("dataset[@ID='")+13,xpath.indexOf("']"));
    }
    Element variable = getElementByXPath(xpath);
    if ( variable != null ) {
        return new Variable(variable, dsid);
    } else {
        return null;
    }
}
项目:LAS    文件:LASConfig.java   
/**
 * Extract a property value from a variable element
 * Array List of NameValueBeans
 * @param xpathValue The XPath of the variable to find.
 * @return value the property value
 *
 */
public String getVariablePropertyValue(Element variable, String group, String property) throws JDOMException {
    if ( variable != null ) {
        List propGroups = variable.getChild("properties").getChildren("property_group");
        for (Iterator pgIt = propGroups.iterator(); pgIt.hasNext();) {
            Element propGroupE = (Element) pgIt.next();
            if ( propGroupE.getAttributeValue("type").equals(group )) {
                List props = propGroupE.getChildren("property");
                for (Iterator pIt = props.iterator(); pIt.hasNext();) {
                    Element prop  = (Element) pIt.next();
                    String name = prop.getChildText("name");
                    String value = prop.getChildText("value");
                    if (name.equals(property)) {
                        return value;
                    }
                }
            }
        }
    }
    return "";
}
项目:LAS    文件:LASConfig.java   
/**
 * Returns list of variables in given a dataset as pmel.tmap.las.util.Dataset objects.
 * @param dsID ID of the dataset for which variables should be listed.
 * @return variables Array list of variables
 */
public ArrayList<Variable> getVariables(String dsID) throws JDOMException {
    ArrayList<Variable> variables = new ArrayList<Variable>();
    Element dataset = getElementByXPath("/lasdata/datasets/dataset[@ID='"+dsID+"']");
    if ( dataset != null ) {
        List variablesElements = dataset.getChildren("variables");
        for (Iterator vseIt = variablesElements.iterator(); vseIt.hasNext();) {
            Element variablesElement = (Element) vseIt.next();
            List vars = variablesElement.getChildren("variable");
            for (Iterator varIt = vars.iterator(); varIt.hasNext();) {
                Element variable = (Element) varIt.next();
                Variable var = new Variable(variable, dsID, dsID, dataset.getAttributeValue("name"));
                variables.add(var);
            }
        }
    }
    return variables;
}
项目:LAS    文件:LASConfig.java   
public String resolveURLS(LASUIRequest lasRequest) throws JDOMException, LASException {
    // Start looping on the args in the request
    List vars = lasRequest.getRootElement().getChild("args").getChildren("link");
       for (Iterator varIt = vars.iterator(); varIt.hasNext();) {
           Element var = (Element) varIt.next();
           String varXPath = var.getAttributeValue("match");
           String url = getFTDSURL(varXPath);
           if ( url != null && !url.equals("") ) {
               var.setAttribute("ftds_url", url);
               var.setAttribute("var_name", getVariableName(varXPath));
               var.setAttribute("var_title", getVariableTitle(varXPath));
               Variable varContainer = getVariableByXPath(varXPath);
               var.setAttribute("dsid", varContainer.getDSID());
               var.setAttribute("gridid", varContainer.getGridID());
           }
       }
       return lasRequest.toCompactString();
}
项目:LAS    文件:LASConfig.java   
/**
 * Returns list of variables give a dataset
 * @param dsID ID of the dataset for which variables should be listed.
 * @return variables Array list of variables
 */
public ArrayList<NameValuePair> getVariablesAsNameValueBeans(String dsID) throws JDOMException {
    ArrayList<NameValuePair> variables = new ArrayList<NameValuePair>();
    Element dataset = getElementByXPath("/lasdata/datasets/dataset[@ID='"+dsID+"']");
    List variablesElements = dataset.getChildren("variables");
    for (Iterator vseIt = variablesElements.iterator(); vseIt.hasNext();) {
        Element variablesElement = (Element) vseIt.next();
        List vars = variablesElement.getChildren("variable");
        for (Iterator varIt = vars.iterator(); varIt.hasNext();) {
            Element variable = (Element) varIt.next();
            String name = variable.getAttributeValue("name");
            String value = variable.getAttributeValue("ID");
            variables.add(new NameValuePair(name, value));
        }
    }
    return variables;
}
项目:intellij-ce-playground    文件:EclipseClasspathTest.java   
static void checkModule(String path, Module module) throws IOException, JDOMException, ConversionException {
  final File classpathFile1 = new File(path, EclipseXml.DOT_CLASSPATH_EXT);
  if (!classpathFile1.exists()) return;
  String fileText1 = FileUtil.loadFile(classpathFile1).replaceAll("\\$ROOT\\$", module.getProject().getBaseDir().getPath());
  if (!SystemInfo.isWindows) {
    fileText1 = fileText1.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL);
  }

  Element classpathElement1 = JDOMUtil.loadDocument(fileText1).getRootElement();
  ModuleRootModel model = ModuleRootManager.getInstance(module);
  Element resultClasspathElement = new EclipseClasspathWriter().writeClasspath(classpathElement1, model);

  String resulted = new String(JDOMUtil.printDocument(new Document(resultClasspathElement), "\n"));
  assertTrue(resulted.replaceAll(StringUtil.escapeToRegexp(module.getProject().getBaseDir().getPath()), "\\$ROOT\\$"),
             JDOMUtil.areElementsEqual(classpathElement1, resultClasspathElement));
}
项目:sumo    文件:ReadTest.java   
public void parseProductXML(File productxml)  {
    try {
        SAXBuilder builder = new SAXBuilder();
        doc = builder.build(productxml);
        Element atts = doc.getRootElement().getChild("productInfo");

    } catch (JDOMException|IOException ex) {
        logger.error(ex.getMessage(),ex);
    }
}
项目:gate-core    文件:Parser.java   
/**
 * Given xml representation of HIT converts them into an array of hits
 * @throws IOException
 */
public static Hit[] fromXML(String xml) throws IOException, JDOMException {
  SAXBuilder saxBuilder = new SAXBuilder(false);
  org.jdom.Document jdomDoc = saxBuilder.build(new StringReader(xml));
  Element rootElement = jdomDoc.getRootElement();
  if(!rootElement.getName().equalsIgnoreCase(HITS)) {
    throw new IOException("Root element must be " + HITS);
  }

  // rootElement is HITS
  // this will internally contains instances of HIT
  List<?> hitsChildren = rootElement.getChildren(HIT);
  Hit[] hits = new Hit[hitsChildren.size()];

  for(int i = 0; i < hitsChildren.size(); i++) {
    Element hitElem = (Element)hitsChildren.get(i);
    int startOffset = Integer.parseInt(hitElem.getChildText(START_OFFSET));
    int endOffset = Integer.parseInt(hitElem.getChildText(END_OFFSET));
    String docID = hitElem.getChildText(DOC_ID);
    String annotationSetName = hitElem.getChildText(ANNOTATION_SET_NAME);
    String queryString = hitElem.getChildText(QUERY);

    Element patternAnnotations = hitElem.getChild(PATTERN_ANNOTATIONS);
    if(patternAnnotations == null) {
      hits[i] = new Hit(docID, annotationSetName, startOffset, endOffset, queryString);
      continue;
    }

    List<?> patAnnots = patternAnnotations.getChildren(PATTERN_ANNOTATION);
    List<PatternAnnotation> patAnnotsList = new ArrayList<PatternAnnotation>();
    for(int j = 0; j < patAnnots.size(); j++) {
      Element patAnnot = (Element)patAnnots.get(j);
      PatternAnnotation pa = new PatternAnnotation();
      pa.setStOffset(Integer.parseInt(patAnnot.getChildText(START)));
      pa.setEnOffset(Integer.parseInt(patAnnot.getChildText(END)));
      pa.setPosition(Integer.parseInt(patAnnot.getChildText(POSITION)));
      pa.setText(patAnnot.getChildText(TEXT));
      pa.setType(patAnnot.getChildText(TYPE));

      // we need to find out its features
      Element featuresElem = patAnnot.getChild(FEATURES);
      // more than one features possible
      List<?> featuresElemsList = featuresElem.getChildren(FEATURE);
      for(int k = 0; k < featuresElemsList.size(); k++) {
        Element featureElem = (Element)featuresElemsList.get(k);
        String key = featureElem.getChildText(KEY);
        String value = featureElem.getChildText(VALUE);
        pa.addFeature(key, value);
      }
      patAnnotsList.add(pa);
    }

    String patternText = hitElem.getChildText(PATTERN_TEXT);
    int leftCSO = Integer.parseInt(hitElem
            .getChildText(LEFT_CONTEXT_START_OFFSET));
    int rightCEO = Integer.parseInt(hitElem
            .getChildText(RIGHT_CONTEXT_END_OFFSET));

    hits[i] = new Pattern(docID, annotationSetName, patternText, startOffset, endOffset,
            leftCSO, rightCEO, patAnnotsList, queryString);
  }
  return hits;
}
项目:gate-core    文件:CreoleRegisterImpl.java   
/**
 * Parse a directory file (represented as an open stream), adding resource
 * data objects to the CREOLE register as they occur. If the resource is from
 * a URL then that location is passed (otherwise null).
 */
protected void parseDirectory(Plugin plugin, Document jdomDoc,
    URL directoryUrl, URL creoleFileUrl) throws GateException {
  // create a handler for the directory file and parse it;
  // this will create ResourceData entries in the register
  try {

    CreoleAnnotationHandler annotationHandler =
        new CreoleAnnotationHandler(plugin);

    GateClassLoader gcl = Gate.getClassLoader()
        .getDisposableClassLoader(creoleFileUrl.toExternalForm());

    // Add any JARs from the creole.xml to the GATE ClassLoader
    annotationHandler.addJarsToClassLoader(gcl, jdomDoc);

    // Make sure there is a RESOURCE element for every resource type the
    // directory defines
    annotationHandler.createResourceElementsForDirInfo(jdomDoc);

    processFullCreoleXmlTree(plugin, jdomDoc,
        annotationHandler);
  } catch(IOException e) {
    throw (new GateException(e));
  } catch(JDOMException je) {
    if(DEBUG) je.printStackTrace(Err.getPrintWriter());
    throw (new GateException(je));
  }

}
项目:gate-core    文件:CreoleAnnotationHandler.java   
/**
  * Extract all JAR elements from the given JDOM document and add the jars they
  * reference to the GateClassLoader.
  * 
  * @param jdomDoc
  *          JDOM document representing a parsed creole.xml file.
  */
public void addJarsToClassLoader(GateClassLoader gcl, Document jdomDoc) throws IOException {
    try {
        XPath jarXPath = XPath.newInstance("//*[translate(local-name(), 'ivy', 'IVY') = 'IVY']");
        if (jarXPath.selectNodes(jdomDoc).size() > 0) {
            throw new IOException("Using Ivy for dependency management is no longer supported");
        }
    } catch (JDOMException e) {
        throw new IOException("Unable to load plugin", e);
    }

    addJarsToClassLoader(gcl, jdomDoc.getRootElement());
}
项目:gate-core    文件:UpgradeXGAPP.java   
@SuppressWarnings("unchecked")
public static List<UpgradePath> suggest(Document doc)
    throws IOException, JDOMException {

  List<UpgradePath> upgrades = new ArrayList<UpgradePath>();

  Element root = doc.getRootElement();

  Element pluginList = root.getChild("urlList").getChild("localList");

  List<Element> plugins = pluginList.getChildren();

  Iterator<Element> it = plugins.iterator();
  while(it.hasNext()) {
    Element plugin = it.next();
    switch(plugin.getName()){
      case "gate.util.persistence.PersistenceManager-URLHolder":
        String urlString = plugin.getChild("urlString").getValue();
        String[] parts = urlString.split("/");

        String oldName = parts[parts.length - 1];
        String newName = oldName.toLowerCase().replaceAll("[\\s_]+", "-");

        VersionRangeResult versions =
            getPluginVersions("uk.ac.gate.plugins", newName);

        if(versions != null) {

          upgrades
              .add(new UpgradePath(plugin, urlString, "uk.ac.gate.plugins",
                  newName, versions, versions.getHighestVersion()));

          break;
        }
      case "gate.creole.Plugin-Maven":
        // TODO check to see if there is a newer version of the plugin to use
        break;
      default:
        // some unknown plugin type
        break;
    }
  }

  return upgrades;
}
项目:teamcity-msteams-notifier    文件:MsTeamsNotificationConfigTest.java   
@Before
public void setup() throws JDOMException, IOException{

    msteamsnotificationAllEnabled  = ConfigLoaderUtil.getFirstMsTeamsNotificationInConfig(new File("src/test/resources/project-settings-test-all-states-enabled.xml"));
    msteamsnotificationAllDisabled = ConfigLoaderUtil.getFirstMsTeamsNotificationInConfig(new File("src/test/resources/project-settings-test-all-states-disabled.xml"));
    msteamsnotificationDisabled    = ConfigLoaderUtil.getFirstMsTeamsNotificationInConfig(new File("src/test/resources/project-settings-test-msteamsnotifications-disabled.xml"));
    msteamsnotificationMostEnabled = ConfigLoaderUtil.getFirstMsTeamsNotificationInConfig(new File("src/test/resources/project-settings-test-all-but-respchange-states-enabled.xml"));
       msteamsnotificationCustomContent = ConfigLoaderUtil.getFirstMsTeamsNotificationInConfig(new File("src/test/resources/project-settings-test-custom-content.xml"));
}
项目:teamcity-msteams-notifier    文件:ProjectMsTeamsNotificationsBeanTest.java   
@Test
public void JsonSerialisationTest() throws JDOMException, IOException {
       ServerPaths serverPaths = mock(ServerPaths.class);
       MsTeamsNotificationMainSettings myMainSettings = new MsTeamsNotificationMainSettings(sBuildServer, serverPaths);
       framework = MsTeamsNotificationMockingFrameworkImpl.create(BuildStateEnum.BUILD_FINISHED);
    framework.loadMsTeamsNotificationProjectSettingsFromConfigXml(new File("../tcmsteamsbuildnotifier-core/src/test/resources/project-settings-test-all-states-enabled-with-specific-builds.xml"));
    ProjectMsTeamsNotificationsBean msteamsnotificationsConfig = ProjectMsTeamsNotificationsBean.build(framework.getMsTeamsNotificationProjectSettings() , framework.getServer().getProjectManager().findProjectById("project01"), myMainSettings);
    System.out.println(ProjectMsTeamsNotificationsBeanJsonSerialiser.serialise(msteamsnotificationsConfig));
}
项目:teamcity-msteams-notifier    文件:ProjectMsTeamsNotificationsBeanTest.java   
@Test
public void JsonBuildSerialisationTest() throws JDOMException, IOException {
       ServerPaths serverPaths = mock(ServerPaths.class);
       MsTeamsNotificationMainSettings myMainSettings = new MsTeamsNotificationMainSettings(sBuildServer, serverPaths);
       framework = MsTeamsNotificationMockingFrameworkImpl.create(BuildStateEnum.BUILD_FINISHED);
    framework.loadMsTeamsNotificationProjectSettingsFromConfigXml(new File("../tcmsteamsbuildnotifier-core/src/test/resources/project-settings-test-all-states-enabled-with-specific-builds.xml"));
    ProjectMsTeamsNotificationsBean msteamsnotificationsConfig = ProjectMsTeamsNotificationsBean.build(framework.getMsTeamsNotificationProjectSettings() ,framework.getSBuildType() ,framework.getServer().getProjectManager().findProjectById("project01"), myMainSettings);
    System.out.println(ProjectMsTeamsNotificationsBeanJsonSerialiser.serialise(msteamsnotificationsConfig));
}