Example usage for java.util Properties elements

List of usage examples for java.util Properties elements

Introduction

In this page you can find the example usage for java.util Properties elements.

Prototype

@Override
    public Enumeration<Object> elements() 

Source Link

Usage

From source file:Main.java

public static void saveAttributesToNode(Node node, Properties props) {
    Document doc = node.getOwnerDocument();
    Element elem;/*from ww w . ja va2s.c  o m*/
    Enumeration keys = props.keys();
    Enumeration elems = props.elements();
    while (keys.hasMoreElements()) {
        String s;
        s = keys.nextElement().toString() + "=" + elems.nextElement().toString();
        addTextTag(node, TAG_ATTR, s);
    }

}

From source file:com.ikon.principal.UsersRolesPrincipalAdapter.java

@Override
public List<String> getRoles() throws PrincipalAdapterException {
    log.debug("getRoles()");
    List<String> list = new ArrayList<String>();
    Properties prop = new Properties();

    try {//from   w  ww. j  ava 2  s  .co m
        prop.load(new FileInputStream(Config.HOME_DIR + "/server/default/conf/props/openkm-roles.properties"));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    for (Enumeration<Object> e = prop.elements(); e.hasMoreElements();) {
        for (StringTokenizer st = new StringTokenizer((String) e.nextElement(), ","); st.hasMoreTokens();) {
            String role = st.nextToken();

            if (!Config.DEFAULT_ADMIN_ROLE.equals(role) && !list.contains(role)) {
                list.add(role);
            }
        }
    }

    log.debug("getRoles: {}", list);
    return list;
}

From source file:com.arcbees.plugin.velocity.RuntimeInstanceCustom.java

/**
 * This methods initializes all the directives
 * that are used by the Velocity Runtime. The
 * directives to be initialized are listed in
 * the RUNTIME_DEFAULT_DIRECTIVES properties
 * file./*from   w  w w.  j av  a 2  s  .c  o  m*/
 *
 * @throws Exception
 */
private void initializeDirectives() throws Exception {
    /*
     * Initialize the runtime directive table.
     * This will be used for creating parsers.
     */
    runtimeDirectives = new Hashtable();

    Properties directiveProperties = new Properties();

    /*
     * Grab the properties file with the list of directives
     * that we should initialize.
     */

    InputStream inputStream = null;

    try {
        inputStream = getClass().getResourceAsStream('/' + DEFAULT_RUNTIME_DIRECTIVES);

        if (inputStream == null) {
            throw new Exception(
                    "Error loading directive.properties! " + "Something is very wrong if these properties "
                            + "aren't being located. Either your Velocity "
                            + "distribution is incomplete or your Velocity " + "jar file is corrupted!");
        }

        directiveProperties.load(inputStream);

    } catch (IOException ioe) {
        log.error("Error while loading directive properties!", ioe);
    } finally {
        try {
            if (inputStream != null) {
                inputStream.close();
            }
        } catch (IOException ioe) {
            log.error("Cannot close directive properties!", ioe);
        }
    }

    /*
     * Grab all the values of the properties. These
     * are all class names for example:
     *
     * org.apache.velocity.runtime.directive.Foreach
     */
    Enumeration directiveClasses = directiveProperties.elements();

    while (directiveClasses.hasMoreElements()) {
        String directiveClass = (String) directiveClasses.nextElement();
        loadDirective(directiveClass);
        log.debug("Loaded System Directive: " + directiveClass);
    }

    /*
     *  now the user's directives
     */

    String[] userdirective = configuration.getStringArray("userdirective");

    for (int i = 0; i < userdirective.length; i++) {
        loadDirective(userdirective[i]);
        if (log.isInfoEnabled()) {
            log.info("Loaded User Directive: " + userdirective[i]);
        }
    }

}

From source file:com.github.pfmiles.org.apache.velocity.runtime.RuntimeInstance.java

/**
 * This methods initializes all the directives that are used by the Velocity
 * Runtime. The directives to be initialized are listed in the
 * RUNTIME_DEFAULT_DIRECTIVES properties file.
 *//*  www .ja v a 2 s  .  c  om*/
private void initializeDirectives() {
    Properties directiveProperties = new Properties();

    /*
     * Grab the properties file with the list of directives that we should
     * initialize.
     */

    InputStream inputStream = null;

    try {
        inputStream = getClass().getResourceAsStream('/' + DEFAULT_RUNTIME_DIRECTIVES);

        if (inputStream == null) {
            throw new VelocityException(
                    "Error loading directive.properties! " + "Something is very wrong if these properties "
                            + "aren't being located. Either your Velocity "
                            + "distribution is incomplete or your Velocity " + "jar file is corrupted!");
        }

        directiveProperties.load(inputStream);

    } catch (IOException ioe) {
        String msg = "Error while loading directive properties!";
        log.error(msg, ioe);
        throw new RuntimeException(msg, ioe);
    } finally {
        try {
            if (inputStream != null) {
                inputStream.close();
            }
        } catch (IOException ioe) {
            String msg = "Cannot close directive properties!";
            log.error(msg, ioe);
            throw new RuntimeException(msg, ioe);
        }
    }

    /*
     * Grab all the values of the properties. These are all class names for
     * example:
     * 
     * org.apache.velocity.runtime.directive.Foreach
     */
    Enumeration directiveClasses = directiveProperties.elements();

    while (directiveClasses.hasMoreElements()) {
        String directiveClass = (String) directiveClasses.nextElement();
        loadDirective(directiveClass);
        log.debug("Loaded System Directive: " + directiveClass);
    }

    /*
     * now the user's directives
     */

    String[] userdirective = configuration.getStringArray("userdirective");

    for (int i = 0; i < userdirective.length; i++) {
        loadDirective(userdirective[i]);
        if (log.isDebugEnabled()) {
            log.debug("Loaded User Directive: " + userdirective[i]);
        }
    }

}

From source file:bboss.org.apache.velocity.runtime.RuntimeInstance.java

/**
 * This methods initializes all the directives
 * that are used by the Velocity Runtime. The
 * directives to be initialized are listed in
 * the RUNTIME_DEFAULT_DIRECTIVES properties
 * file./*from   ww w. j  av a 2 s .co  m*/
 */
private void initializeDirectives() {
    Properties directiveProperties = new Properties();

    /*
     * Grab the properties file with the list of directives
     * that we should initialize.
     */

    InputStream inputStream = null;

    try {
        inputStream = getClass().getResourceAsStream('/' + DEFAULT_RUNTIME_DIRECTIVES);

        if (inputStream == null) {
            throw new VelocityException(
                    "Error loading directive.properties! " + "Something is very wrong if these properties "
                            + "aren't being located. Either your Velocity "
                            + "distribution is incomplete or your Velocity " + "jar file is corrupted!");
        }

        directiveProperties.load(inputStream);

    } catch (IOException ioe) {
        String msg = "Error while loading directive properties!";
        log.error(msg, ioe);
        throw new RuntimeException(msg, ioe);
    } finally {
        try {
            if (inputStream != null) {
                inputStream.close();
            }
        } catch (IOException ioe) {
            String msg = "Cannot close directive properties!";
            log.error(msg, ioe);
            throw new RuntimeException(msg, ioe);
        }
    }

    /*
     * Grab all the values of the properties. These
     * are all class names for example:
     *
     * bboss.org.apache.velocity.runtime.directive.Foreach
     */
    Enumeration directiveClasses = directiveProperties.elements();

    while (directiveClasses.hasMoreElements()) {
        String directiveClass = (String) directiveClasses.nextElement();
        loadDirective(directiveClass);
        log.debug("Loaded System Directive: " + directiveClass);
    }

    /*
     *  now the user's directives
     */

    String[] userdirective = configuration.getStringArray("userdirective");

    for (int i = 0; i < userdirective.length; i++) {
        loadDirective(userdirective[i]);
        if (log.isDebugEnabled()) {
            log.debug("Loaded User Directive: " + userdirective[i]);
        }
    }

}

From source file:org.apache.flex.forks.velocity.runtime.RuntimeInstance.java

/**
 * This methods initializes all the directives
 * that are used by the Velocity Runtime. The
 * directives to be initialized are listed in
 * the RUNTIME_DEFAULT_DIRECTIVES properties
 * file.//from   w w  w  .java 2  s.c  om
 *
 * @throws Exception
 */
private void initializeDirectives() throws Exception {
    /*
     * Initialize the runtime directive table.
     * This will be used for creating parsers.
     */
    runtimeDirectives = new Hashtable();

    Properties directiveProperties = new Properties();

    /*
     * Grab the properties file with the list of directives
     * that we should initialize.
     */
    InputStream inputStream = null;
    try {
        inputStream = getClass().getResourceAsStream('/' + DEFAULT_RUNTIME_DIRECTIVES);

        if (inputStream == null)
            throw new Exception(
                    "Error loading directive.properties! " + "Something is very wrong if these properties "
                            + "aren't being located. Either your Velocity "
                            + "distribution is incomplete or your Velocity " + "jar file is corrupted!");

        directiveProperties.load(inputStream);
    } catch (IOException ioe) {
        String msg = "Error while loading directive properties!";
        error(msg);
        throw new Exception(msg, ioe);
    } finally {
        try {
            if (inputStream != null) {
                inputStream.close();
            }
        } catch (IOException ioe) {
            String msg = "Cannot close directive properties!";
            debug(msg);
        }
    }

    /*
     * Grab all the values of the properties. These
     * are all class names for example:
     *
     * org.apache.flex.forks.velocity.runtime.directive.Foreach
     */
    Enumeration directiveClasses = directiveProperties.elements();

    while (directiveClasses.hasMoreElements()) {
        String directiveClass = (String) directiveClasses.nextElement();
        loadDirective(directiveClass, "System");
    }

    /*
     *  now the user's directives
     */

    String[] userdirective = configuration.getStringArray("userdirective");

    for (int i = 0; i < userdirective.length; i++) {
        loadDirective(userdirective[i], "User");
    }

}

From source file:org.apache.velocity.runtime.RuntimeInstance.java

/**
 * This methods initializes all the directives
 * that are used by the Velocity Runtime. The
 * directives to be initialized are listed in
 * the RUNTIME_DEFAULT_DIRECTIVES properties
 * file./*from  ww w. j  a  v  a 2 s  .c  om*/
 */
private void initializeDirectives() {
    Properties directiveProperties = new Properties();

    /*
     * Grab the properties file with the list of directives
     * that we should initialize.
     */

    InputStream inputStream = null;

    try {
        inputStream = getClass().getResourceAsStream('/' + DEFAULT_RUNTIME_DIRECTIVES);

        if (inputStream == null) {
            throw new VelocityException(
                    "Error loading directive.properties! " + "Something is very wrong if these properties "
                            + "aren't being located. Either your Velocity "
                            + "distribution is incomplete or your Velocity " + "jar file is corrupted!");
        }

        directiveProperties.load(inputStream);

    } catch (IOException ioe) {
        String msg = "Error while loading directive properties!";
        Logger.error(this, msg, ioe);
        throw new RuntimeException(msg, ioe);
    } finally {
        try {
            if (inputStream != null) {
                inputStream.close();
            }
        } catch (IOException ioe) {
            String msg = "Cannot close directive properties!";
            Logger.error(this, msg, ioe);
            throw new RuntimeException(msg, ioe);
        }
    }

    /*
     * Grab all the values of the properties. These
     * are all class names for example:
     *
     * org.apache.velocity.runtime.directive.Foreach
     */
    Enumeration directiveClasses = directiveProperties.elements();

    while (directiveClasses.hasMoreElements()) {
        String directiveClass = (String) directiveClasses.nextElement();
        loadDirective(directiveClass);
        Logger.debug(this, "Loaded System Directive: " + directiveClass);
    }

    /*
     *  now the user's directives
     */

    String[] userdirective = configuration.getStringArray("userdirective");

    for (int i = 0; i < userdirective.length; i++) {
        loadDirective(userdirective[i]);
        if (Logger.isDebugEnabled(this.getClass())) {
            Logger.debug(this, "Loaded User Directive: " + userdirective[i]);
        }
    }

}

From source file:org.springmodules.template.engine.velocity.extended.ExtendedRuntimeInstance.java

/**
 * This methods initializes all the directives
 * that are used by the Velocity Runtime. The
 * directives to be initialized are listed in
 * the RUNTIME_DEFAULT_DIRECTIVES properties
 * file.//from   w ww.j  a  v  a2  s.c  o m
 *
 * @throws Exception
 */
private void initializeDirectives() throws Exception {
    /*
     * Initialize the runtime directive table.
     * This will be used for creating parsers.
     */
    runtimeDirectives = new Hashtable();

    Properties directiveProperties = new Properties();

    /*
     * Grab the properties file with the list of directives
     * that we should initialize.
     */

    InputStream inputStream = null;

    try {
        inputStream = getClass().getResourceAsStream('/' + DEFAULT_RUNTIME_DIRECTIVES);

        if (inputStream == null) {
            throw new Exception(
                    "Error loading directive.properties! " + "Something is very wrong if these properties "
                            + "aren't being located. Either your Velocity "
                            + "distribution is incomplete or your Velocity " + "jar file is corrupted!");
        }

        directiveProperties.load(inputStream);

    } catch (IOException ioe) {
        log.error("Error while loading directive properties!", ioe);
    } finally {
        try {
            if (inputStream != null) {
                inputStream.close();
            }
        } catch (IOException ioe) {
            log.error("Cannot close directive properties!", ioe);
        }
    }

    /*
    * Grab all the values of the properties. These
    * are all class names for example:
    *
    * org.apache.velocity.runtime.directive.Foreach
    */
    Enumeration directiveClasses = directiveProperties.elements();

    while (directiveClasses.hasMoreElements()) {
        String directiveClass = (String) directiveClasses.nextElement();
        loadDirective(directiveClass);
        log.debug("Loaded System Directive: " + directiveClass);
    }

    /*
     *  now the user's directives
     */

    String[] userdirective = configuration.getStringArray("userdirective");

    for (int i = 0; i < userdirective.length; i++) {
        loadDirective(userdirective[i]);
        if (log.isInfoEnabled()) {
            log.info("Loaded User Directive: " + userdirective[i]);
        }
    }

}