Package org.jconfig

Examples of org.jconfig.DefaultConfiguration$MyCategoryListener


    public Configuration load(String configurationName) throws ConfigurationManagerException {   
        InitialDirContext ctx = getContext();
        if ( ctx == null ) {
            throw new ConfigurationManagerException("There is no connection to the LDAP server");
        }
        Configuration config = new DefaultConfiguration(null);
        getCategories(ctx,config);
        getAllProperties(ctx,config);
        return config;
    }
View Full Code Here


     *  Description of the Method
     *
     *@param  doc  Description of the Parameter
     */
    public Configuration parse(Document doc,String configName) {
        Configuration configuration = new DefaultConfiguration(configName);
        String currentCategory;
        getBaseConfigName(doc, configuration);
        getVariables(doc,configuration);
        getIncludeProperties(doc, configuration);
        // first we get all nodes where the element is category
        NodeList nl = doc.getElementsByTagName("category");
        for (int i = 0; i < nl.getLength(); i++) {
            // now we get every node from the list
            Node n = nl.item(i);
            // and get the name attribute for this category
            NamedNodeMap curAtt = n.getAttributes();
            Node curNode = curAtt.getNamedItem("name");
            currentCategory = curNode.getNodeValue();
//            System.err.println("processing for currentCategory "+currentCategory);
            configuration.setCategory(currentCategory);
            // now we process all children for this category
            for (Node child = n.getFirstChild(); child != null; child = child.getNextSibling()) {
                if (child.getNodeName().equals("property")) {
                    // we have found a property element and now we grab the name and value
                    // attributes
                    NamedNodeMap myAtt = child.getAttributes();
                    Node myNode = myAtt.getNamedItem("name");
                    if ( myNode != null ) {
                      String name = myNode.getNodeValue();
                      myNode = myAtt.getNamedItem("value");
                      if ( myNode != null ) {
                        String value = myNode.getNodeValue();
                        // if we have both then lets store it
                        if (name != null && value != null) {
                            // the key is always category/name
                            // e.g. general/congig_file
                            configuration.setProperty(name,value,currentCategory);
                        }
                      }
                      else {
                        ErrorReporter.getErrorHandler().reportError("No attribute 'value' found for property - ignoring entry");
                      }
View Full Code Here

     *  Description of the Method
     *
     *@param  doc  Description of the Parameter
     */
    public static Configuration parse(Document doc,String configName) {       
        Configuration configuration = new DefaultConfiguration(configName);
        String currentCategory;
        getVariables(doc,configuration);
        // first we get all nodes where the element is category
        NodeList nl = doc.getElementsByTagName("category");
        for (int i = 0; i < nl.getLength(); i++) {
            // now we get every node from the list
            Node n = nl.item(i);
            // and get the name attribute for this category
            NamedNodeMap curAtt = n.getAttributes();
            Node curNode = curAtt.getNamedItem("name");
            currentCategory = curNode.getNodeValue();           
            configuration.setCategory(currentCategory);
            // now we process all children for this category
            for (Node child = n.getFirstChild(); child != null; child = child.getNextSibling()) {
                if (child.getNodeName().equals("property")) {
                    // we have found a property element and now we grab the name and value
                    // attributes
                    NamedNodeMap myAtt = child.getAttributes();
                    Node myNode = myAtt.getNamedItem("name");
                    String name = myNode.getNodeValue();
                    myNode = myAtt.getNamedItem("value");
                    String value = myNode.getNodeValue();
                    // if we have both then lets store it
                    if (name != null && value != null) {
                        // the key is always category/name
                        // e.g. general/congig_file                                               
                        configuration.setProperty(name,value,currentCategory);
                    }
                }
            }
        }
        return configuration;
View Full Code Here

     *  Description of the Method
     *
     *@param  doc  Description of the Parameter
     */
    public static Configuration parse(Document doc,String configName) {       
        Configuration configuration = new DefaultConfiguration(configName);
        String currentCategory;
        getVariables(doc,configuration);
        // first we get all nodes where the element is category
        NodeList nl = doc.getElementsByTagName("category");
        for (int i = 0; i < nl.getLength(); i++) {
            // now we get every node from the list
            Node n = nl.item(i);
            // and get the name attribute for this category
            NamedNodeMap curAtt = n.getAttributes();
            Node curNode = curAtt.getNamedItem("name");
            currentCategory = curNode.getNodeValue();           
            configuration.setCategory(currentCategory);
            // now we process all children for this category
            for (Node child = n.getFirstChild(); child != null; child = child.getNextSibling()) {
                if (child.getNodeName().equals("property")) {
                    // we have found a property element and now we grab the name and value
                    // attributes
                    NamedNodeMap myAtt = child.getAttributes();
                    Node myNode = myAtt.getNamedItem("name");
                    String name = myNode.getNodeValue();
                    myNode = myAtt.getNamedItem("value");
                    String value = myNode.getNodeValue();
                    // if we have both then lets store it
                    if (name != null && value != null) {
                        // the key is always category/name
                        // e.g. general/congig_file                                               
                        configuration.setProperty(name,value,currentCategory);
                    }
                }
            }
        }
        return configuration;
View Full Code Here

     *  Description of the Method
     *
     *@param  doc  Description of the Parameter
     */
    public Configuration parse(Document doc,String configName) {       
        Configuration configuration = new DefaultConfiguration(configName);
        String currentCategory;
        getVariables(doc,configuration);
        // first we get all nodes where the element is category
        NodeList nl = doc.getElementsByTagName("category");
        for (int i = 0; i < nl.getLength(); i++) {
            // now we get every node from the list
            Node n = nl.item(i);
            // and get the name attribute for this category
            NamedNodeMap curAtt = n.getAttributes();
            Node curNode = curAtt.getNamedItem("name");
            currentCategory = curNode.getNodeValue();           
            configuration.setCategory(currentCategory);
            // now we process all children for this category
            for (Node child = n.getFirstChild(); child != null; child = child.getNextSibling()) {
                // we take the tag name as property name               
                if ( child.getNodeType() == 1 && child.getFirstChild() != null ) {
                    String name = child.getNodeName();                                 
                    String value = child.getFirstChild().getNodeValue();                   
                    if (name != null && value != null) {
                        // the key is always category/name
                        // e.g. general/congig_file                                               
                        configuration.setProperty(name,value,currentCategory);
                    }               
                }
            }
        }
        return configuration;
View Full Code Here

    public synchronized Configuration load(String configName) throws ConfigurationManagerException {
        return loadPropertiesFile(file,configName);
    }
   
    private Configuration loadPropertiesFile(File file,String configName) throws ConfigurationManagerException {
        Configuration config = new DefaultConfiguration(configName);
        if ( file == null ) {
          ErrorReporter.getErrorHandler().reportError("The file is NULL");
            throw new ConfigurationManagerException("The file is NULL");
        }
        try {
            InputStream inputStream = null;
            if(file.exists()) {
                inputStream = new FileInputStream(file);
            } else {
                ResourceLocator locator = new ResourceLocator(file.getName());
                inputStream = locator.getInputStream();
            }
            if ( inputStream == null ) {
              ErrorReporter.getErrorHandler().reportError("Cannot find the properties file");
                throw new ConfigurationManagerException("Cannot find the properties file");
            }
            Properties myProperties = new Properties();
            myProperties.load(inputStream);
            Enumeration propertyNames = myProperties.propertyNames();
            while (propertyNames.hasMoreElements()) {
                String name = (String) propertyNames.nextElement();
                String value = myProperties.getProperty(name);
                config.setProperty(name, value);
            }
        } catch (Exception e) {
          ErrorReporter.getErrorHandler().reportError("The file cannot be loaded",e);
            throw new ConfigurationManagerException("The file cannot be loaded:"+e.getMessage());
        }
        config.resetCreated();
        return config;
    }
View Full Code Here

   
    /**
     * @return
     */
    private Configuration loadConfiguration(String configurationName) throws ConfigurationManagerException {
        Configuration config = new DefaultConfiguration(configurationName);
        try {
            PreparedStatement pstmt = con.prepareStatement("SELECT OID FROM T_CONFIGURATION WHERE NAME = ?");
            pstmt.setString(1, configurationName);
            ResultSet result = pstmt.executeQuery();
            while(result.next()) {
View Full Code Here

TOP

Related Classes of org.jconfig.DefaultConfiguration$MyCategoryListener

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.