Package org.apache.avalon.framework.configuration

Examples of org.apache.avalon.framework.configuration.Configuration


    public static Map buildFilterMapFromConfiguration(Configuration cfg)
                throws ConfigurationException {
        Map filterMap = new java.util.HashMap();
        Configuration[] filterLists = cfg.getChildren("filterList");
        for (int i = 0; i < filterLists.length; i++) {
            Configuration filters = filterLists[i];
            String type = filters.getAttribute("type", null);
            Configuration[] filt = filters.getChildren("value");
            List filterList = new java.util.ArrayList();
            for (int j = 0; j < filt.length; j++) {
                String name = filt[j].getValue();
                filterList.add(name);
            }
View Full Code Here


     * @param renderer PCL renderer
     * @throws FOPException fop exception
     * @see org.apache.fop.render.PrintRendererConfigurator#configure(Renderer)
     */
    public void configure(Renderer renderer) throws FOPException {
        Configuration cfg = super.getRendererConfig(renderer);
        if (cfg != null) {
            PCLRenderer pclRenderer = (PCLRenderer)renderer;
            String rendering = cfg.getChild("rendering").getValue(null);
            if ("quality".equalsIgnoreCase(rendering)) {
                pclRenderer.setQualityBeforeSpeed(true);
            } else if ("speed".equalsIgnoreCase(rendering)) {
                pclRenderer.setQualityBeforeSpeed(false);
            } else if (rendering != null) {
                throw new FOPException(
                        "Valid values for 'rendering' are 'quality' and 'speed'. Value found: "
                            + rendering);
            }
            String textRendering = cfg.getChild("text-rendering").getValue(null);
            if ("bitmap".equalsIgnoreCase(textRendering)) {
                pclRenderer.setAllTextAsBitmaps(true);
            } else if ("auto".equalsIgnoreCase(textRendering)) {
                pclRenderer.setAllTextAsBitmaps(false);
            } else if (textRendering != null) {
View Full Code Here

     */
    private Configuration getHandlerConfig(Configuration cfg, String namespace) {
        if (cfg == null || namespace == null) {
            return null;
        }
        Configuration handlerConfig = null;

        Configuration[] children = cfg.getChildren("xml-handler");
        for (int i = 0; i < children.length; ++i) {
            try {
                if (children[i].getAttribute("namespace").equals(namespace)) {
View Full Code Here

     * @param ns the Namespace of the foreign object
     * @throws FOPException if configuring the target objects fails
     */
    public void configure(RendererContext context, String ns) throws FOPException {
        //Optional XML handler configuration
        Configuration cfg = getRendererConfig(context.getRenderer());
        if (cfg != null) {
            cfg = getHandlerConfig(cfg, ns);
            if (cfg != null) {
                context.setProperty(RendererContextConstants.HANDLER_CONFIGURATION, cfg);
            }
View Full Code Here

     *
     * @param renderer print renderer
     * @throws FOPException if something's wrong with the config data
     */
    public void configure(Renderer renderer) throws FOPException {
        Configuration cfg = getRendererConfig(renderer);
        if (cfg == null) {
            return;
        }

        PrintRenderer printRenderer = (PrintRenderer)renderer;
View Full Code Here

    public static List buildFontListFromConfiguration(Configuration cfg,
            String fontBaseURL, FontResolver fontResolver,
            boolean strict, FontCache fontCache) throws FOPException {
        List fontInfoList = new java.util.ArrayList();

        Configuration fonts = cfg.getChild("fonts");
        if (fonts != null) {
            long start = 0;
            if (log.isDebugEnabled()) {
                log.debug("Starting font configuration...");
                start = System.currentTimeMillis();
            }
           
            // native o/s search (autodetect) configuration
            boolean autodetectFonts = (fonts.getChild("auto-detect", false) != null);
            if (!autodetectedFonts && autodetectFonts) {
                // search in font base if it is defined and
                // is a directory but don't recurse
                FontFileFinder fontFileFinder = new FontFileFinder();
                if (fontBaseURL != null) {
                    try {
                        File fontBase = FileUtils.toFile(new URL(fontBaseURL));
                        if (fontBase != null) {
                            //Can only use the font base URL if it's a file URL
                            addFontInfoListFromFileList(
                                    fontFileFinder.find(fontBase.getAbsolutePath()),
                                    fontInfoList,
                                    fontResolver,
                                    fontCache
                            );
                        }
                    } catch (IOException e) {
                        LogUtil.handleException(log, e, strict);
                    }
                }

                // native o/s font directory finder
                try {
                    addFontInfoListFromFileList(
                            fontFileFinder.find(),
                            fontInfoList,
                            fontResolver,
                            fontCache
                    );
                } catch (IOException e) {
                    LogUtil.handleException(log, e, strict);
                }
                autodetectedFonts = true;
            }

            // directory (multiple font) configuration
            Configuration[] directories = fonts.getChildren("directory");
            for (int i = 0; i < directories.length; i++) {
                boolean recursive = directories[i].getAttributeAsBoolean("recursive", false);
                String directory = null;
                try {
                    directory = directories[i].getValue();
                } catch (ConfigurationException e) {
                    LogUtil.handleException(log, e, strict);
                    continue;
                }
                if (directory == null) {
                    LogUtil.handleException(log,
                            new FOPException("directory defined without value"), strict);
                    continue;
                }
                FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1);
                try {
                    addFontInfoListFromFileList(
                            fontFileFinder.find(directory),
                            fontInfoList,
                            fontResolver,
                            fontCache
                    );
                } catch (IOException e) {
                    LogUtil.handleException(log, e, strict);
                }
            }
           
            // font file (singular) configuration
            Configuration[] font = fonts.getChildren("font");
            for (int i = 0; i < font.length; i++) {
                EmbedFontInfo fontInfo = getFontInfoFromConfiguration(
                        font[i], fontResolver, strict, fontCache);
                if (fontInfo != null) {
                    fontInfoList.add(fontInfo);
View Full Code Here

     * Returns the configuration subtree for a specific renderer.
     * @param renderer the renderer
     * @return the requested configuration subtree, null if there's no configuration
     */
    protected Configuration getRendererConfig(Renderer renderer) {
        Configuration cfg = userAgent.getFactory().getUserConfig();
        if (cfg == null) {
            if (log.isDebugEnabled()) {
                log.debug("userconfig is null");
            }
            return null;           
        }
   
        String mimeType = renderer.getMimeType();
        if (mimeType == null) {
            if (log.isInfoEnabled()) {
                log.info("renderer mimeType is null");
            }
            return null;
        }
       
        Configuration userRendererConfig = null;
   
        Configuration[] cfgs
            = cfg.getChild("renderers").getChildren("renderer");
        for (int i = 0; i < cfgs.length; ++i) {
            Configuration child = cfgs[i];
            try {
                if (child.getAttribute("mime").equals(mimeType)) {
                    userRendererConfig = child;
                    break;
                }
            } catch (ConfigurationException e) {
                // silently pass over configurations without mime type
View Full Code Here

     * Configure the PS renderer.
     * @param renderer TXT renderer
     * @throws FOPException fop exception
     */
    public void configure(Renderer renderer) throws FOPException {
        Configuration cfg = super.getRendererConfig(renderer);
        if (cfg != null) {
            TXTRenderer txtRenderer = (TXTRenderer)renderer;
            txtRenderer.setEncoding(cfg.getChild("encoding", true).getValue(null));
        }
    }
View Full Code Here

     * Configure the Java 2D renderer.
     * @param renderer java 2d renderer
     * @throws FOPException fop exception
     */
    public void configure(Renderer renderer) throws FOPException {
        Configuration cfg = super.getRendererConfig(renderer);
        if (cfg != null) {
            Java2DRenderer java2dRenderer = (Java2DRenderer)renderer;
            String value = cfg.getChild(
                    Java2DRenderer.JAVA2D_TRANSPARENT_PAGE_BACKGROUND, true).getValue(null);
            if (value != null) {
                java2dRenderer.setTransparentPageBackground("true".equalsIgnoreCase(value));
            }
        }
View Full Code Here

     * Configure the PS renderer.
     * @param renderer postscript renderer
     * @throws FOPException fop exception
     */
    public void configure(Renderer renderer) throws FOPException {
        Configuration cfg = super.getRendererConfig(renderer);
        if (cfg != null) {
            super.configure(renderer);

            PSRenderer psRenderer = (PSRenderer)renderer;
            psRenderer.setAutoRotateLandscape(
                cfg.getChild("auto-rotate-landscape").getValueAsBoolean(false));
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.configuration.Configuration

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.