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


Java Document.getRootElement方法代码示例

本文整理汇总了Java中org.jdom.Document.getRootElement方法的典型用法代码示例。如果您正苦于以下问题:Java Document.getRootElement方法的具体用法?Java Document.getRootElement怎么用?Java Document.getRootElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jdom.Document的用法示例。


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

示例1: isMyType

import org.jdom.Document; //导入方法依赖的package包/类
public boolean isMyType(Document document) {
    boolean ok = false;

    Element rssRoot = document.getRootElement();
    Namespace defaultNS = rssRoot.getNamespace();
    List additionalNSs = rssRoot.getAdditionalNamespaces();

    ok = defaultNS!=null && defaultNS.equals(getRDFNamespace());
    if (ok) {
        if (additionalNSs==null) {
            ok = false;
        }
        else {
            ok = false;
            for (int i=0;!ok && i<additionalNSs.size();i++) {
                ok = getRSSNamespace().equals(additionalNSs.get(i));
            }
        }
    }
    return ok;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:RSS090Parser.java

示例2: createService

import org.jdom.Document; //导入方法依赖的package包/类
@Override
public GoogleAccountsService createService(final HttpServletRequest request) {
    final String relayState = request.getParameter(SamlProtocolConstants.PARAMETER_SAML_RELAY_STATE);

    final String xmlRequest = this.googleSaml20ObjectBuilder.decodeSamlAuthnRequest(
            request.getParameter(SamlProtocolConstants.PARAMETER_SAML_REQUEST));

    if (StringUtils.isBlank(xmlRequest)) {
        LOGGER.trace("SAML AuthN request not found in the request");
        return null;
    }

    final Document document = this.googleSaml20ObjectBuilder.constructDocumentFromXml(xmlRequest);
    if (document == null) {
        return null;
    }

    final Element root = document.getRootElement();
    final String assertionConsumerServiceUrl = root.getAttributeValue("AssertionConsumerServiceURL");
    final String requestId = root.getAttributeValue("ID");
    final GoogleAccountsService s = new GoogleAccountsService(assertionConsumerServiceUrl, relayState, requestId);
    s.setLoggedOutAlready(true);
    return s;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:25,代码来源:GoogleAccountsServiceFactory.java

示例3: doGet

import org.jdom.Document; //导入方法依赖的package包/类
@SuppressWarnings("nls")
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
	resp.setContentType("application/x-java-jnlp-file");
	resp.setHeader("Cache-Control", "private, max-age=5, must-revalidate");
	Document locJnlpDocument = (Document) this.jnlpDocument.clone();
	Element jnlpElem = locJnlpDocument.getRootElement();
	String instUrl = institutionService.getInstitutionUrl().toString();
	jnlpElem.setAttribute("codebase", instUrl);
	Element resources = jnlpElem.getChild("resources");

	String token = userService.getGeneratedToken(Constants.APPLET_SECRET_ID, CurrentUser.getUsername());

	String tokenEncoded = Base64.encodeBase64String(token.getBytes("UTF-8")).replace("\r", "").replace("\n", "");
	resources.addContent(createJar(resourcesService.getUrl("com.tle.web.adminconsole", "adminconsole.jar")));
	resources.addContent(createProperty(Bootstrap.TOKEN_PARAMETER, tokenEncoded));
	resources.addContent(createProperty(Bootstrap.ENDPOINT_PARAMETER, instUrl));
	resources.addContent(createProperty(Bootstrap.LOCALE_PARAMETER, CurrentLocale.getLocale().toString()));
	resources.addContent(createProperty(Bootstrap.INSTITUTION_NAME_PARAMETER, CurrentInstitution.get().getName()));
	xmlOut.output(locJnlpDocument, resp.getWriter());
}
 
开发者ID:equella,项目名称:Equella,代码行数:23,代码来源:TleJnlpDownloadServlet.java

示例4: createResourceElementsForDirInfo

import org.jdom.Document; //导入方法依赖的package包/类
/**
 * Fetches the directory information for this handler's creole plugin and adds
 * additional RESOURCE elements to the given JDOM document so that it contains
 * a RESOURCE for every resource type defined in the plugin's directory info.
 * 
 * @param jdomDoc
 *          JDOM document which should be the parsed creole.xml that this
 *          handler was configured for.
 */
public void createResourceElementsForDirInfo(Document jdomDoc)
    throws MalformedURLException {
  Element jdomElt = jdomDoc.getRootElement();
  //URL directoryUrl = new URL(creoleFileUrl, ".");
  //DirectoryInfo dirInfo = Gate.getDirectoryInfo(directoryUrl,jdomDoc);
  //if(dirInfo != null) {
    Map<String, Element> resourceElements = new HashMap<String, Element>();
    findResourceElements(resourceElements, jdomElt);
    for(ResourceInfo resInfo : plugin
        .getResourceInfoList()) {
      if(!resourceElements.containsKey(resInfo.getResourceClassName())) {
        // no existing RESOURCE element for this resource type (so it
        // was
        // auto-discovered from a <JAR SCAN="true">), so add a minimal
        // RESOURCE element which will be filled in by the annotation
        // processor.
        jdomElt.addContent(new Element("RESOURCE").addContent(new Element(
            "CLASS").setText(resInfo.getResourceClassName())));
      }
    }
  //}

}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:33,代码来源:CreoleAnnotationHandler.java

示例5: isMyType

import org.jdom.Document; //导入方法依赖的package包/类
public boolean isMyType(Document document) {
    Element rssRoot = document.getRootElement();
    Namespace defaultNS = rssRoot.getNamespace();
    boolean ok = defaultNS!=null && defaultNS.equals(getRSSNamespace());
    if (ok) {
        ok = super.isMyType(document);
    }
    return ok;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:RSS20wNSParser.java

示例6: test_WebookConfig

import org.jdom.Document; //导入方法依赖的package包/类
@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());

	}
}
 
开发者ID:spyder007,项目名称:teamcity-msteams-notifier,代码行数:31,代码来源:MsTeamsNotificationSettingsTest.java

示例7: test_ReadXml

import org.jdom.Document; //导入方法依赖的package包/类
@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"));
						}
					}
	            }
			}
		}

}
 
开发者ID:spyder007,项目名称:teamcity-msteams-notifier,代码行数:35,代码来源:MsTeamsNotificationSettingsTest.java

示例8: createService

import org.jdom.Document; //导入方法依赖的package包/类
@Override
public GoogleAccountsService createService(final HttpServletRequest request) {

    if (this.publicKey == null || this.privateKey == null) {
        logger.debug("{} will not turn on because private/public keys are not configured",
                getClass().getName());
        return null;
    }

    final String relayState = request.getParameter(SamlProtocolConstants.PARAMETER_SAML_RELAY_STATE);

    final String xmlRequest = BUILDER.decodeSamlAuthnRequest(
            request.getParameter(SamlProtocolConstants.PARAMETER_SAML_REQUEST));

    if (!StringUtils.hasText(xmlRequest)) {
        logger.trace("SAML AuthN request not found in the request");
        return null;
    }

    final Document document = BUILDER.constructDocumentFromXml(xmlRequest);

    if (document == null) {
        return null;
    }

    final Element root = document.getRootElement();
    final String assertionConsumerServiceUrl = root.getAttributeValue("AssertionConsumerServiceURL");
    final String requestId = root.getAttributeValue("ID");

    final GoogleAccountsServiceResponseBuilder builder =
        new GoogleAccountsServiceResponseBuilder(this.privateKey, this.publicKey, BUILDER);
    builder.setSkewAllowance(this.skewAllowance);
    return new GoogleAccountsService(assertionConsumerServiceUrl, relayState, requestId, builder);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:35,代码来源:GoogleAccountsServiceFactory.java

示例9: isMyType

import org.jdom.Document; //导入方法依赖的package包/类
public boolean isMyType(Document document) {
    Element rssRoot = document.getRootElement();
    Namespace defaultNS = rssRoot.getNamespace();
    return (defaultNS!=null) && defaultNS.equals(getAtomNamespace());
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:6,代码来源:Atom03Parser.java

示例10: importPlanning

import org.jdom.Document; //导入方法依赖的package包/类
@Action
public void importPlanning() {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileFilter(new FileNameExtensionFilter("Planning File Filter", "xml"));
    fileChooser.showDialog(this, "Import Planning File");
    File imageplanningFile = fileChooser.getSelectedFile();
    // check file format
    try {
        // create xml reader
        SAXBuilder builder = new SAXBuilder();
        Document doc;
        doc = builder.build(imageplanningFile);
        Element atts = doc.getRootElement();
        if(atts.getName().equalsIgnoreCase("XMLExport"))
        {
            imageplanningFile = convertEOLISAImagePlanning(imageplanningFile);
        }
        H2Fetcher.addImagePlanning("SUMODB", imageplanningFile);
    } catch (Exception ex) {
        Utilities.errorWindow("Problem importing planner");
    }
    updateAcquisitionTree();
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:24,代码来源:PlanningPanel.java

示例11: ClassPathXmlApplicationContext

import org.jdom.Document; //导入方法依赖的package包/类
public ClassPathXmlApplicationContext() throws Exception {
    SAXBuilder builder = new SAXBuilder();

    String basedir = this.getClass().getClassLoader().getResource("/").getPath();

    File xmlFile = new File(basedir + "beans.xml");
    // 构造文档对象
    Document document = builder.build(xmlFile);
    // 获取根元素
    Element root = document.getRootElement();
    // 取到根元素所有元素
    List list = root.getChildren();

    setBeans(list);
}
 
开发者ID:xujiajun,项目名称:tastjava,代码行数:16,代码来源:ClassPathXmlApplicationContext.java

示例12: parse

import org.jdom.Document; //导入方法依赖的package包/类
public WireFeed parse(Document document, boolean validate) throws IllegalArgumentException,FeedException {
    if (validate) {
        validateFeed(document);
    }
    Element rssRoot = document.getRootElement();
    return parseChannel(rssRoot);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:8,代码来源:RSS090Parser.java

示例13: processResource

import org.jdom.Document; //导入方法依赖的package包/类
public void processResource( String resource, InputStream is, List<Relocator> relocators )
    throws IOException
{
    Document r;
    try
    {
        SAXBuilder builder = new SAXBuilder( false );
        builder.setExpandEntities( false );
        if ( ignoreDtd )
        {
            builder.setEntityResolver( new EntityResolver()
            {
                public InputSource resolveEntity( String publicId, String systemId )
                    throws SAXException, IOException
                {
                    return new InputSource( new StringReader( "" ) );
                }
            } );
        }
        r = builder.build( is );
    }
    catch ( JDOMException e )
    {
        throw new RuntimeException( "Error processing resource " + resource + ": " + e.getMessage(), e );
    }

    if ( doc == null )
    {
        doc = r;
    }
    else
    {
        Element root = r.getRootElement();

        for ( @SuppressWarnings( "unchecked" )
        Iterator<Attribute> itr = root.getAttributes().iterator(); itr.hasNext(); )
        {
            Attribute a = itr.next();
            itr.remove();

            Element mergedEl = doc.getRootElement();
            Attribute mergedAtt = mergedEl.getAttribute( a.getName(), a.getNamespace() );
            if ( mergedAtt == null )
            {
                mergedEl.setAttribute( a );
            }
        }

        for ( @SuppressWarnings( "unchecked" )
        Iterator<Content> itr = root.getChildren().iterator(); itr.hasNext(); )
        {
            Content n = itr.next();
            itr.remove();

            doc.getRootElement().addContent( n );
        }
    }
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:59,代码来源:XmlAppendingTransformer.java

示例14: suggest

import org.jdom.Document; //导入方法依赖的package包/类
@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;
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:46,代码来源:UpgradeXGAPP.java

示例15: parse

import org.jdom.Document; //导入方法依赖的package包/类
public WireFeed parse(Document document, boolean validate) throws IllegalArgumentException,FeedException {
    if (validate) {
        validateFeed(document);
    }
    Element rssRoot = document.getRootElement();
    return parseFeed(rssRoot);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:8,代码来源:Atom03Parser.java


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