Search in sources :

Example 51 with ListIterator

use of java.util.ListIterator in project vcell by virtualcell.

the class ListPolynomial method divide.

public Polynomial divide(Monomial monomial) throws ArithmeticException {
    if (monomial.degree() == 0)
        return this;
    if (mutable) {
        ListIterator it = content.listIterator();
        while (it.hasNext()) it.set(((Term) it.next()).divide(monomial));
        degree -= monomial.degree();
        sugar -= monomial.degree();
        return this;
    } else
        return copy().divide(monomial);
}
Also used : ListIterator(java.util.ListIterator)

Example 52 with ListIterator

use of java.util.ListIterator in project drools by kiegroup.

the class ExtensibleXmlParser method getParent.

public Object getParent(final Class parent) {
    final ListIterator it = this.parents.listIterator(this.parents.size());
    Object node = null;
    while (it.hasPrevious()) {
        node = it.previous();
        if (parent.isInstance(node)) {
            break;
        }
    }
    return node;
}
Also used : ListIterator(java.util.ListIterator)

Example 53 with ListIterator

use of java.util.ListIterator in project Payara by payara.

the class JdbcConnectionPoolDeployer method getMCFConfigProperties.

/**
 * Pull out the MCF configuration properties and return them as an array
 * of ConnectorConfigProperty
 *
 * @param adminPool   - The JdbcConnectionPool to pull out properties from
 * @param conConnPool - ConnectorConnectionPool which will be used by Resource Pool
 * @param connDesc    - The ConnectorDescriptor for this JDBC RA
 * @return ConnectorConfigProperty [] array of MCF Config properties specified
 *         in this JDBC RA
 */
private ConnectorConfigProperty[] getMCFConfigProperties(JdbcConnectionPool adminPool, ConnectorConnectionPool conConnPool, ConnectorDescriptor connDesc) {
    ArrayList propList = new ArrayList();
    if (adminPool.getResType() != null) {
        if (ConnectorConstants.JAVA_SQL_DRIVER.equals(adminPool.getResType())) {
            propList.add(new ConnectorConfigProperty("ClassName", adminPool.getDriverClassname() == null ? "" : adminPool.getDriverClassname(), "The driver class name", "java.lang.String"));
        } else {
            propList.add(new ConnectorConfigProperty("ClassName", adminPool.getDatasourceClassname() == null ? "" : adminPool.getDatasourceClassname(), "The datasource class name", "java.lang.String"));
        }
    } else {
        // When resType is null, one of these classnames would be specified
        if (adminPool.getDriverClassname() != null) {
            propList.add(new ConnectorConfigProperty("ClassName", adminPool.getDriverClassname() == null ? "" : adminPool.getDriverClassname(), "The driver class name", "java.lang.String"));
        } else if (adminPool.getDatasourceClassname() != null) {
            propList.add(new ConnectorConfigProperty("ClassName", adminPool.getDatasourceClassname() == null ? "" : adminPool.getDatasourceClassname(), "The datasource class name", "java.lang.String"));
        }
    }
    propList.add(new ConnectorConfigProperty("ConnectionValidationRequired", adminPool.getIsConnectionValidationRequired() + "", "Is connection validation required", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("ValidationMethod", adminPool.getConnectionValidationMethod() == null ? "" : adminPool.getConnectionValidationMethod(), "How the connection is validated", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("ValidationTableName", adminPool.getValidationTableName() == null ? "" : adminPool.getValidationTableName(), "Validation Table name", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("ValidationClassName", adminPool.getValidationClassname() == null ? "" : adminPool.getValidationClassname(), "Validation Class name", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("TransactionIsolation", adminPool.getTransactionIsolationLevel() == null ? "" : adminPool.getTransactionIsolationLevel(), "Transaction Isolatin Level", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("GuaranteeIsolationLevel", adminPool.getIsIsolationLevelGuaranteed() + "", "Transaction Isolation Guarantee", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("StatementWrapping", adminPool.getWrapJdbcObjects() + "", "Statement Wrapping", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("LogJdbcCalls", adminPool.getLogJdbcCalls() + "", "Log JDBC Calls", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("SlowQueryThresholdInSeconds", adminPool.getSlowQueryThresholdInSeconds() + "", "Slow Query Threshold In Seconds", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("StatementTimeout", adminPool.getStatementTimeoutInSeconds() + "", "Statement Timeout", "java.lang.String"));
    PoolInfo poolInfo = conConnPool.getPoolInfo();
    propList.add(new ConnectorConfigProperty("PoolMonitoringSubTreeRoot", ConnectorsUtil.getPoolMonitoringSubTreeRoot(poolInfo, true) + "", "Pool Monitoring Sub Tree Root", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("PoolName", poolInfo.getName() + "", "Pool Name", "java.lang.String"));
    if (poolInfo.getApplicationName() != null) {
        propList.add(new ConnectorConfigProperty("ApplicationName", poolInfo.getApplicationName() + "", "Application Name", "java.lang.String"));
    }
    if (poolInfo.getModuleName() != null) {
        propList.add(new ConnectorConfigProperty("ModuleName", poolInfo.getModuleName() + "", "Module name", "java.lang.String"));
    }
    propList.add(new ConnectorConfigProperty("StatementCacheSize", adminPool.getStatementCacheSize() + "", "Statement Cache Size", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("StatementCacheType", adminPool.getStatementCacheType() + "", "Statement Cache Type", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("InitSql", adminPool.getInitSql() + "", "InitSql", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("SqlTraceListeners", adminPool.getSqlTraceListeners() + "", "Sql Trace Listeners", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("StatementLeakTimeoutInSeconds", adminPool.getStatementLeakTimeoutInSeconds() + "", "Statement Leak Timeout in seconds", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("StatementLeakReclaim", adminPool.getStatementLeakReclaim() + "", "Statement Leak Reclaim", "java.lang.String"));
    // dump user defined poperties into the list
    Set connDefDescSet = connDesc.getOutboundResourceAdapter().getConnectionDefs();
    // since this a 1.0 RAR, we will have only 1 connDefDesc
    if (connDefDescSet.size() != 1) {
        throw new MissingResourceException("Only one connDefDesc present", null, null);
    }
    Iterator iter = connDefDescSet.iterator();
    // Now get the set of MCF config properties associated with each
    // connection-definition . Each element here is an EnviromnentProperty
    Set mcfConfigProps = null;
    while (iter.hasNext()) {
        mcfConfigProps = ((ConnectionDefDescriptor) iter.next()).getConfigProperties();
    }
    if (mcfConfigProps != null) {
        Map mcfConPropKeys = new HashMap();
        Iterator mcfConfigPropsIter = mcfConfigProps.iterator();
        while (mcfConfigPropsIter.hasNext()) {
            String key = ((ConnectorConfigProperty) mcfConfigPropsIter.next()).getName();
            mcfConPropKeys.put(key.toUpperCase(locale), key);
        }
        String driverProperties = "";
        for (Property rp : adminPool.getProperty()) {
            if (rp == null) {
                continue;
            }
            String name = rp.getName();
            // making it easy to compare in the event of a reconfig
            if ("MATCHCONNECTIONS".equals(name.toUpperCase(locale))) {
                // JDBC - matchConnections if not set is decided by the ConnectionManager
                // so default is false
                conConnPool.setMatchConnections(toBoolean(rp.getValue(), false));
                logFine("MATCHCONNECTIONS");
            } else if ("ASSOCIATEWITHTHREAD".equals(name.toUpperCase(locale))) {
                conConnPool.setAssociateWithThread(toBoolean(rp.getValue(), false));
                logFine("ASSOCIATEWITHTHREAD");
            } else if ("LAZYCONNECTIONASSOCIATION".equals(name.toUpperCase(locale))) {
                ConnectionPoolObjectsUtils.setLazyEnlistAndLazyAssocProperties(rp.getValue(), adminPool.getProperty(), conConnPool);
                logFine("LAZYCONNECTIONASSOCIATION");
            } else if ("LAZYCONNECTIONENLISTMENT".equals(name.toUpperCase(Locale.getDefault()))) {
                conConnPool.setLazyConnectionEnlist(toBoolean(rp.getValue(), false));
                logFine("LAZYCONNECTIONENLISTMENT");
            } else if ("POOLDATASTRUCTURE".equals(name.toUpperCase(Locale.getDefault()))) {
                conConnPool.setPoolDataStructureType(rp.getValue());
                logFine("POOLDATASTRUCTURE");
            } else if (ConnectorConstants.DYNAMIC_RECONFIGURATION_FLAG.equals(name.toLowerCase(locale))) {
                String value = rp.getValue();
                try {
                    conConnPool.setDynamicReconfigWaitTimeout(Long.parseLong(rp.getValue()) * 1000L);
                    logFine(ConnectorConstants.DYNAMIC_RECONFIGURATION_FLAG);
                } catch (NumberFormatException nfe) {
                    _logger.log(Level.WARNING, "Invalid value for " + "'" + ConnectorConstants.DYNAMIC_RECONFIGURATION_FLAG + "' : " + value);
                }
            } else if ("POOLWAITQUEUE".equals(name.toUpperCase(locale))) {
                conConnPool.setPoolWaitQueue(rp.getValue());
                logFine("POOLWAITQUEUE");
            } else if ("DATASTRUCTUREPARAMETERS".equals(name.toUpperCase(locale))) {
                conConnPool.setDataStructureParameters(rp.getValue());
                logFine("DATASTRUCTUREPARAMETERS");
            } else if ("USERNAME".equals(name.toUpperCase(Locale.getDefault())) || "USER".equals(name.toUpperCase(locale))) {
                propList.add(new ConnectorConfigProperty("User", (String) TranslatedConfigView.getTranslatedValue(rp.getValue()), "user name", "java.lang.String"));
            } else if ("PASSWORD".equals(name.toUpperCase(locale))) {
                propList.add(new ConnectorConfigProperty("Password", (String) TranslatedConfigView.getTranslatedValue(rp.getValue()), "Password", "java.lang.String"));
            } else if ("JDBC30DATASOURCE".equals(name.toUpperCase(locale))) {
                propList.add(new ConnectorConfigProperty("JDBC30DataSource", rp.getValue(), "JDBC30DataSource", "java.lang.String"));
            } else if ("PREFER-VALIDATE-OVER-RECREATE".equals(name.toUpperCase(Locale.getDefault()))) {
                String value = rp.getValue();
                conConnPool.setPreferValidateOverRecreate(toBoolean(value, false));
                logFine("PREFER-VALIDATE-OVER-RECREATE : " + value);
            } else if ("STATEMENT-CACHE-TYPE".equals(name.toUpperCase(Locale.getDefault()))) {
                if (adminPool.getStatementCacheType() != null) {
                    propList.add(new ConnectorConfigProperty("StatementCacheType", rp.getValue(), "StatementCacheType", "java.lang.String"));
                }
            } else if ("NUMBER-OF-TOP-QUERIES-TO-REPORT".equals(name.toUpperCase(Locale.getDefault()))) {
                propList.add(new ConnectorConfigProperty("NumberOfTopQueriesToReport", rp.getValue(), "NumberOfTopQueriesToReport", "java.lang.String"));
            } else if ("TIME-TO-KEEP-QUERIES-IN-MINUTES".equals(name.toUpperCase(Locale.getDefault()))) {
                propList.add(new ConnectorConfigProperty("TimeToKeepQueriesInMinutes", rp.getValue(), "TimeToKeepQueriesInMinutes", "java.lang.String"));
            } else if ("MAXCACHESIZE".equals(name.toUpperCase(Locale.getDefault())) || "MAX-CACHE-SIZE".equals(name.toUpperCase(Locale.getDefault()))) {
                propList.add(new ConnectorConfigProperty("MaxCacheSize", rp.getValue(), "MaxCacheSize", "java.lang.String"));
            } else if (mcfConPropKeys.containsKey(name.toUpperCase(Locale.getDefault()))) {
                propList.add(new ConnectorConfigProperty((String) mcfConPropKeys.get(name.toUpperCase(Locale.getDefault())), rp.getValue() == null ? "" : (String) TranslatedConfigView.getTranslatedValue(rp.getValue()), "Some property", "java.lang.String"));
            } else {
                driverProperties = driverProperties + "set" + escape(name) + "#" + escape((String) TranslatedConfigView.getTranslatedValue(rp.getValue())) + "##";
            }
        }
        if (!driverProperties.equals("")) {
            propList.add(new ConnectorConfigProperty("DriverProperties", driverProperties, "some proprietarty properties", "java.lang.String"));
        }
    }
    propList.add(new ConnectorConfigProperty("Delimiter", "#", "delim", "java.lang.String"));
    propList.add(new ConnectorConfigProperty("EscapeCharacter", "\\", "escapeCharacter", "java.lang.String"));
    // create an array of EnvironmentProperties from above list
    ConnectorConfigProperty[] eProps = new ConnectorConfigProperty[propList.size()];
    ListIterator propListIter = propList.listIterator();
    for (int i = 0; propListIter.hasNext(); i++) {
        eProps[i] = (ConnectorConfigProperty) propListIter.next();
    }
    return eProps;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) MissingResourceException(java.util.MissingResourceException) ArrayList(java.util.ArrayList) ListIterator(java.util.ListIterator) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) Map(java.util.Map) HashMap(java.util.HashMap) Property(org.jvnet.hk2.config.types.Property) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty)

Example 54 with ListIterator

use of java.util.ListIterator in project Payara by payara.

the class TableHandlers method getProperties.

/**
 * <p> This handler converts the table List to a Properties map.
 *
 *	@param	handlerCtx	The HandlerContext.
 */
@Handler(id = "getProperties", input = { @HandlerInput(name = "NewList", type = List.class, required = true) }, output = { @HandlerOutput(name = "AddProps", type = Map.class) })
public static void getProperties(HandlerContext handlerCtx) {
    List newList = (List) handlerCtx.getInputValue("NewList");
    ListIterator li = newList.listIterator();
    Map addProps = new Properties();
    while (li.hasNext()) {
        Map props = (Map) li.next();
        String name = (String) props.get("name");
        if (name != null && (!name.trim().equals(""))) {
            String value = (String) props.get("value");
            if (value != null && (!value.trim().equals(""))) {
                addProps.put(name, value);
            }
        }
    }
    handlerCtx.setOutputValue("AddProps", addProps);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ListIterator(java.util.ListIterator) Properties(java.util.Properties) HashMap(java.util.HashMap) Map(java.util.Map) Handler(com.sun.jsftemplating.annotation.Handler)

Example 55 with ListIterator

use of java.util.ListIterator in project Payara by payara.

the class TableHandlers method addRowToTable.

/**
 *	<p> This handler adds one row to  table
 *  <p> Input  value: "TableRowGroup" -- Type: <code> com.sun.webui.jsf.component.TableRowGroup</code></p>
 *  <p> Input value: "NameList" -- Type:<code>java.util.List</code></p>
 *  <p> Input value: "DefaultValueList" -- Type:<code>java.util.List</code></p>
 *  <p> Input value: "HasSelected" -- Type:<code>java.lang.Boolean</code></p>
 *	@param	handlerCtx	The HandlerContext.
 */
@Handler(id = "addRowToTable", input = { @HandlerInput(name = "TableRowGroup", type = TableRowGroup.class, required = true), @HandlerInput(name = "NameList", type = List.class), @HandlerInput(name = "HasSelected", type = Boolean.class), @HandlerInput(name = "DefaultValueList", type = List.class) })
public static void addRowToTable(HandlerContext handlerCtx) {
    TableRowGroup trg = (TableRowGroup) handlerCtx.getInputValue("TableRowGroup");
    List names = (List) handlerCtx.getInputValue("NameList");
    List defaults = (List) handlerCtx.getInputValue("DefaultValueList");
    Boolean hasSelected = (Boolean) handlerCtx.getInputValue("HasSelected");
    MultipleListDataProvider dp = (MultipleListDataProvider) trg.getSourceData();
    List data = dp.getLists();
    ListIterator li = data.listIterator();
    if (li.hasNext()) {
        // Get the first List and create a new Map to represent the row
        List list = (List) li.next();
        Map<String, Object> map = new HashMap<String, Object>();
        if (names != null) {
            // Fill it up...
            if (defaults != null) {
                if (names.size() != defaults.size()) {
                    throw new IllegalArgumentException("NameList.size(" + names.size() + ") does not match DefaultValueList.size(" + defaults.size() + ")!");
                }
                ListIterator ni = names.listIterator();
                ListIterator dv = defaults.listIterator();
                while (ni.hasNext() && dv.hasNext()) {
                    String name = (String) ni.next();
                    String value = (String) dv.next();
                    if ("#{true}".equals(value)) {
                        map.put(name, true);
                    } else if ("#{false}".equals(value)) {
                        map.put(name, false);
                    } else {
                        map.put(name, value);
                    }
                }
            } else {
                ListIterator ni = names.listIterator();
                while (ni.hasNext()) {
                    String name = (String) ni.next();
                    map.put(name, "");
                }
            }
        } else if (defaults == null) {
            // Use a simple name/value default...
            map.put("name", "");
            map.put("value", "");
        }
        // Add the Map to the List
        list.add(0, map);
        // See if we have more lists of map... if so put selected in it
        if (li.hasNext()) {
            list = (List) li.next();
            map = new HashMap<String, Object>();
            list.add(0, map);
        }
        // Add selected column (either to the 1st or 2nd map)
        if (hasSelected == null) {
            map.put("selected", false);
        } else {
            if (hasSelected.booleanValue()) {
                map.put("selected", false);
            }
        }
        // Add something to the remaining Maps (if any)
        while (li.hasNext()) {
            list = (List) li.next();
            map = new HashMap<String, Object>();
            list.add(0, map);
        }
    }
}
Also used : HashMap(java.util.HashMap) MultipleListDataProvider(com.sun.jsftemplating.component.dataprovider.MultipleListDataProvider) ArrayList(java.util.ArrayList) List(java.util.List) TableRowGroup(com.sun.webui.jsf.component.TableRowGroup) ListIterator(java.util.ListIterator) Handler(com.sun.jsftemplating.annotation.Handler)

Aggregations

ListIterator (java.util.ListIterator)121 ArrayList (java.util.ArrayList)42 List (java.util.List)41 LinkedList (java.util.LinkedList)26 Iterator (java.util.Iterator)21 Map (java.util.Map)12 Handler (com.sun.jsftemplating.annotation.Handler)8 AbstractList (java.util.AbstractList)7 HashMap (java.util.HashMap)7 AbstractSequentialList (java.util.AbstractSequentialList)6 IOException (java.io.IOException)5 RandomAccess (java.util.RandomAccess)5 SelectResults (org.apache.geode.cache.query.SelectResults)5 Test (org.junit.Test)5 File (java.io.File)4 HashSet (java.util.HashSet)4 NoSuchElementException (java.util.NoSuchElementException)4 SipURI (javax.sip.address.SipURI)4 ArgumentIntKey (lucee.runtime.type.scope.ArgumentIntKey)4 StructTypeImpl (org.apache.geode.cache.query.internal.types.StructTypeImpl)4