Package org.apache.commons.digester

Examples of org.apache.commons.digester.Digester


    public ValidatorResources(InputStream[] streams)
            throws IOException, SAXException {

        super();

        Digester digester = initDigester();
        for (int i = 0; i < streams.length; i++) {
            digester.push(this);
            digester.parse(streams[i]);
        }

        this.process();
    }
View Full Code Here


    public ValidatorResources(String[] uris)
            throws IOException, SAXException {

        super();

        Digester digester = initDigester();
        for (int i = 0; i < uris.length; i++) {
            digester.push(this);
            digester.parse(uris[i]);
        }

        this.process();
    }   
View Full Code Here

    public ValidatorResources(URL[] urls)
            throws IOException, SAXException {

        super();

        Digester digester = initDigester();
        for (int i = 0; i < urls.length; i++) {
            digester.push(this);
            InputStream stream = null;
            try {
                stream = urls[i].openStream();
                org.xml.sax.InputSource source =
                     new org.xml.sax.InputSource(urls[i].toExternalForm());
                source.setByteStream(stream);
                digester.parse(source);
            } finally {
                if (stream != null) {
                    try {
                        stream.close();
                    } catch (IOException e) {
View Full Code Here

            rulesUrl = ValidatorResources.class.getResource(VALIDATOR_RULES);
        }
        if (getLog().isDebugEnabled()) {
            getLog().debug("Loading rules from '" + rulesUrl + "'");
        }
        Digester digester = DigesterLoader.createDigester(rulesUrl);
        digester.setNamespaceAware(true);
        digester.setValidating(true);
        digester.setUseContextClassLoader(true);

        // Add rules for arg0-arg3 elements
        addOldArgRules(digester);

        // register DTDs
        for (int i = 0; i < REGISTRATIONS.length; i += 2) {
            URL url = this.getClass().getResource(REGISTRATIONS[i + 1]);
            if (url != null) {
                digester.register(REGISTRATIONS[i], url.toString());
            }
        }
        return digester;
    }
View Full Code Here

  public TobagoConfig parse(ServletContext context)
      throws IOException, SAXException, FacesException {

    TobagoConfig tobagoConfig = new TobagoConfig();
    Digester digester = configure(tobagoConfig);
    parse(context, digester);
    return tobagoConfig;
  }
View Full Code Here

    parse(context, digester);
    return tobagoConfig;
  }

  private Digester configure(TobagoConfig config) {
    Digester digester = new Digester();
    digester.setUseContextClassLoader(true);
    digester.push(config);
    digester.setValidating(true);

    // theme-config
    digester.addCallMethod("tobago-config/theme-config/default-theme", "setDefaultThemeName", 0);
    digester.addCallMethod("tobago-config/theme-config/supported-theme", "addSupportedThemeName", 0);

    // mapping rules
    digester.addObjectCreate("tobago-config/mapping-rule", MappingRule.class);
    digester.addSetNext("tobago-config/mapping-rule", "addMappingRule");
    digester.addCallMethod(
        "tobago-config/mapping-rule/request-uri", "setRequestUri", 0);
    digester.addCallMethod(
        "tobago-config/mapping-rule/forward-uri", "setForwardUri", 0);
    digester.addObjectCreate(
        "tobago-config/mapping-rule/attribute", Attribute.class);
    digester.addSetNext(
        "tobago-config/mapping-rule/attribute", "addAttribute");
    digester.addCallMethod(
        "tobago-config/mapping-rule/attribute/key", "setKey", 0);
    digester.addCallMethod(
        "tobago-config/mapping-rule/attribute/value", "setValue", 0);

    // XXX: deprecated! will ever be true (will be removed in next release after 1.0.7)
    digester.addCallMethod("tobago-config/load-theme-resources-from-classpath", "setLoadThemesFromClasspath", 0);

    // resource dirs
    digester.addCallMethod("tobago-config/resource-dir", "addResourceDir", 0);

    // enable ajax
    digester.addCallMethod("tobago-config/ajax-enabled", "setAjaxEnabled", 0);

    // see bug TOBAGO-912
    digester.addCallMethod("tobago-config/fix-resource-order", "setFixResourceOrder", 0);

    // see bug TOBAGO-916
    digester.addCallMethod("tobago-config/fix-layout-transparency", "setFixLayoutTransparency", 0);

    digester.addObjectCreate("tobago-config/renderers", RenderersConfigImpl.class);
    digester.addSetNext("tobago-config/renderers", "setRenderersConfig");
    digester.addObjectCreate("tobago-config/renderers/renderer", RendererConfig.class);
    digester.addSetNext("tobago-config/renderers/renderer", "addRenderer");
    digester.addCallMethod("tobago-config/renderers/renderer/name", "setName", 0);
    digester.addObjectCreate("tobago-config/renderers/renderer/supported-markup", MarkupConfig.class);
    digester.addSetNext("tobago-config/renderers/renderer/supported-markup", "setMarkupConfig");
    digester.addCallMethod("tobago-config/renderers/renderer/supported-markup/markup", "addMarkup", 0);

    return digester;
  }
View Full Code Here

    @SuppressWarnings("rawtypes")
    public ExtractChangeLogSet parse(AbstractBuild build, InputStream changeLogStream) throws IOException, SAXException {

        ArrayList<ExtractChangeLogEntry> changeLog = new ArrayList<ExtractChangeLogEntry>();

        Digester digester = new Digester();
        digester.setClassLoader(ExtractChangeLogSet.class.getClassLoader());
        digester.push(changeLog);
        digester.addObjectCreate("*/extractChanges/entry", ExtractChangeLogEntry.class);

        digester.addBeanPropertySetter("*/extractChanges/entry/zipFile");

        digester.addObjectCreate("*/extractChanges/entry/file",
                FileInZip.class);
        digester.addBeanPropertySetter("*/extractChanges/entry/file/fileName");
        digester.addSetNext("*/extractChanges/entry/file", "addFile");
        digester.addSetNext("*/extractChanges/entry", "add");

        digester.parse(changeLogStream);

        return new ExtractChangeLogSet(build, changeLog);
    }
View Full Code Here

      }
      if (resource == null)
      {
         throw new IllegalArgumentException("Input stream must not be null.");
      }
      final Digester digester = configureDigester(new Digester());

      ConvertUtils.register(caseConverter, Case.class);
      ConvertUtils.register(trailingSlashConverter, TrailingSlash.class);
      ConvertUtils.register(phaseIdConverter, PhaseId.class);
      ConvertUtils.register(redirectConverter, Redirect.class);

      digester.push(builder);
      digester.parse(resource);
   }
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  public List<ParameterList> createParameters(InputStream xmlInput)
      throws Exception {
    // Step 1 - Create the digester
    Digester digester = new Digester();
    digester.setValidating(false);

    // Step 2 - Register rules

    registerBaseRules(digester);
    registerValueObjectRules(digester);
    registerCollectionRules(digester);

    // Step 3 - Run the digester against the given input file
    List<ParameterList> generatedParamSets = (List<ParameterList>) digester
        .parse(xmlInput);

    return generatedParamSets;
  }
View Full Code Here

{
    private Digester digester;

    public DigesterFacesConfigUnmarshallerImpl(ExternalContext externalContext)
    {
        digester = new Digester();
        // TODO: validation set to false during implementation of 1.2
        digester.setValidating(false);
        digester.setNamespaceAware(true);
        digester.setEntityResolver(new FacesConfigEntityResolver(externalContext));
        //digester.setUseContextClassLoader(true);
View Full Code Here

TOP

Related Classes of org.apache.commons.digester.Digester

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.