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