Search in sources :

Example 36 with Iterator

use of java.util.Iterator in project lombok by rzwitserloot.

the class WebUpToDate method eval.

/**
	 * Evaluate (all) target and source file(s) to
	 * see if the target(s) is/are up-to-date.
	 * @return true if the target(s) is/are up-to-date
	 */
public boolean eval() {
    if (sourceFileSets.size() == 0 && sourceResources.size() == 0 && sourceFile == null) {
        throw new BuildException("At least one srcfile or a nested <srcfiles> or <srcresources> element must be set.");
    }
    if ((sourceFileSets.size() > 0 || sourceResources.size() > 0) && sourceFile != null) {
        throw new BuildException("Cannot specify both the srcfile attribute and a nested <srcfiles> or <srcresources> element.");
    }
    if (urlbase == null) {
        throw new BuildException("The urlbase attribute must be set.");
    }
    // if the source file isn't there, throw an exception
    if (sourceFile != null && !sourceFile.exists()) {
        throw new BuildException(sourceFile.getAbsolutePath() + " not found.");
    }
    boolean upToDate = true;
    if (sourceFile != null) {
        Resource fileResource = new FileResource(sourceFile);
        upToDate = isUpToDate(fileResource);
    }
    if (upToDate) {
        Enumeration e = sourceFileSets.elements();
        while (upToDate && e.hasMoreElements()) {
            FileSet fs = (FileSet) e.nextElement();
            Iterator it = fs.iterator();
            while (upToDate && it.hasNext()) {
                Resource r = (Resource) it.next();
                upToDate = isUpToDate(r);
            }
        }
    }
    if (upToDate) {
        Resource[] r = sourceResources.listResources();
        for (int i = 0; upToDate && i < r.length; i++) {
            upToDate = isUpToDate(r[i]);
        }
    }
    return upToDate;
}
Also used : Enumeration(java.util.Enumeration) FileSet(org.apache.tools.ant.types.FileSet) Resource(org.apache.tools.ant.types.Resource) FileResource(org.apache.tools.ant.types.resources.FileResource) URLResource(org.apache.tools.ant.types.resources.URLResource) FileResource(org.apache.tools.ant.types.resources.FileResource) Iterator(java.util.Iterator) BuildException(org.apache.tools.ant.BuildException)

Example 37 with Iterator

use of java.util.Iterator in project core by s4.

the class Adapter method main.

public static void main(String[] args) {
    Options options = new Options();
    options.addOption(OptionBuilder.withArgName("corehome").hasArg().withDescription("core home").create("c"));
    options.addOption(OptionBuilder.withArgName("instanceid").hasArg().withDescription("instance id").create("i"));
    options.addOption(OptionBuilder.withArgName("configtype").hasArg().withDescription("configuration type").create("t"));
    options.addOption(OptionBuilder.withArgName("userconfig").hasArg().withDescription("user-defined legacy data adapter configuration file").create("d"));
    CommandLineParser parser = new GnuParser();
    CommandLine commandLine = null;
    try {
        commandLine = parser.parse(options, args);
    } catch (ParseException pe) {
        System.err.println(pe.getLocalizedMessage());
        System.exit(1);
    }
    int instanceId = -1;
    if (commandLine.hasOption("i")) {
        String instanceIdStr = commandLine.getOptionValue("i");
        try {
            instanceId = Integer.parseInt(instanceIdStr);
        } catch (NumberFormatException nfe) {
            System.err.println("Bad instance id: %s" + instanceIdStr);
            System.exit(1);
        }
    }
    if (commandLine.hasOption("c")) {
        coreHome = commandLine.getOptionValue("c");
    }
    String configType = "typical";
    if (commandLine.hasOption("t")) {
        configType = commandLine.getOptionValue("t");
    }
    String userConfigFilename = null;
    if (commandLine.hasOption("d")) {
        userConfigFilename = commandLine.getOptionValue("d");
    }
    File userConfigFile = new File(userConfigFilename);
    if (!userConfigFile.isFile()) {
        System.err.println("Bad user configuration file: " + userConfigFilename);
        System.exit(1);
    }
    File coreHomeFile = new File(coreHome);
    if (!coreHomeFile.isDirectory()) {
        System.err.println("Bad core home: " + coreHome);
        System.exit(1);
    }
    if (instanceId > -1) {
        System.setProperty("instanceId", "" + instanceId);
    } else {
        System.setProperty("instanceId", "" + S4Util.getPID());
    }
    String configBase = coreHome + File.separatorChar + "conf" + File.separatorChar + configType;
    String configPath = configBase + File.separatorChar + "adapter_conf.xml";
    File configFile = new File(configPath);
    if (!configFile.exists()) {
        System.err.printf("adapter config file %s does not exist\n", configPath);
        System.exit(1);
    }
    // load adapter config xml
    ApplicationContext coreContext;
    coreContext = new FileSystemXmlApplicationContext("file:" + configPath);
    ApplicationContext context = coreContext;
    Adapter adapter = (Adapter) context.getBean("adapter");
    ApplicationContext appContext = new FileSystemXmlApplicationContext(new String[] { "file:" + userConfigFilename }, context);
    Map listenerBeanMap = appContext.getBeansOfType(EventProducer.class);
    if (listenerBeanMap.size() == 0) {
        System.err.println("No user-defined listener beans");
        System.exit(1);
    }
    EventProducer[] eventListeners = new EventProducer[listenerBeanMap.size()];
    int index = 0;
    for (Iterator it = listenerBeanMap.keySet().iterator(); it.hasNext(); index++) {
        String beanName = (String) it.next();
        System.out.println("Adding producer " + beanName);
        eventListeners[index] = (EventProducer) listenerBeanMap.get(beanName);
    }
    adapter.setEventListeners(eventListeners);
}
Also used : Options(org.apache.commons.cli.Options) GnuParser(org.apache.commons.cli.GnuParser) EventProducer(io.s4.listener.EventProducer) FileSystemXmlApplicationContext(org.springframework.context.support.FileSystemXmlApplicationContext) CommandLine(org.apache.commons.cli.CommandLine) FileSystemXmlApplicationContext(org.springframework.context.support.FileSystemXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) Iterator(java.util.Iterator) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) File(java.io.File) Map(java.util.Map)

Example 38 with Iterator

use of java.util.Iterator in project core by s4.

the class LoadGenerator method createEventTypeInfo.

@SuppressWarnings("unchecked")
public void createEventTypeInfo(JSONObject classInfo) {
    String className = "";
    try {
        for (Iterator it = classInfo.keys(); it.hasNext(); ) {
            className = (String) it.next();
            JSONObject jsonEventTypeInfo = classInfo.getJSONObject(className);
            int classIndex = (Integer) jsonEventTypeInfo.getInt("classIndex");
            String streamName = jsonEventTypeInfo.getString("streamName");
            Class clazz = Class.forName(className);
            Schema schema = new Schema(clazz);
            eventTypeInfoMap.put(classIndex, new EventTypeInfo(schema, streamName));
        }
    } catch (JSONException je) {
        je.printStackTrace();
    } catch (ClassNotFoundException cnfe) {
        System.err.println("Count not locate class " + className);
    }
}
Also used : BigInteger(java.math.BigInteger) JSONObject(org.json.JSONObject) Schema(io.s4.schema.Schema) Iterator(java.util.Iterator) JSONException(org.json.JSONException)

Example 39 with Iterator

use of java.util.Iterator in project jadx by skylot.

the class AnnotationGen method encodeValue.

// TODO: refactor this boilerplate code
public void encodeValue(CodeWriter code, Object val) {
    if (val == null) {
        code.add("null");
        return;
    }
    if (val instanceof String) {
        code.add(getStringUtils().unescapeString((String) val));
    } else if (val instanceof Integer) {
        code.add(TypeGen.formatInteger((Integer) val));
    } else if (val instanceof Character) {
        code.add(getStringUtils().unescapeChar((Character) val));
    } else if (val instanceof Boolean) {
        code.add(Boolean.TRUE.equals(val) ? "true" : "false");
    } else if (val instanceof Float) {
        code.add(TypeGen.formatFloat((Float) val));
    } else if (val instanceof Double) {
        code.add(TypeGen.formatDouble((Double) val));
    } else if (val instanceof Long) {
        code.add(TypeGen.formatLong((Long) val));
    } else if (val instanceof Short) {
        code.add(TypeGen.formatShort((Short) val));
    } else if (val instanceof Byte) {
        code.add(TypeGen.formatByte((Byte) val));
    } else if (val instanceof ArgType) {
        classGen.useType(code, (ArgType) val);
        code.add(".class");
    } else if (val instanceof FieldInfo) {
        // must be a static field
        FieldInfo field = (FieldInfo) val;
        InsnGen.makeStaticFieldAccess(code, field, classGen);
    } else if (val instanceof Iterable) {
        code.add('{');
        Iterator<?> it = ((Iterable) val).iterator();
        while (it.hasNext()) {
            Object obj = it.next();
            encodeValue(code, obj);
            if (it.hasNext()) {
                code.add(", ");
            }
        }
        code.add('}');
    } else if (val instanceof Annotation) {
        formatAnnotation(code, (Annotation) val);
    } else {
        // TODO: also can be method values
        throw new JadxRuntimeException("Can't decode value: " + val + " (" + val.getClass() + ")");
    }
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) Annotation(jadx.core.dex.attributes.annotations.Annotation) Iterator(java.util.Iterator) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) FieldInfo(jadx.core.dex.info.FieldInfo)

Example 40 with Iterator

use of java.util.Iterator in project AsmackService by rtreffer.

the class ResponseAuth method checkSemantics.

/**
     * Checks the semantics of the directives in the directive list as parsed
     * from the digest challenge byte array.
     *
     * @param dirList  the list of directives parsed from the digest challenge
     *
     * @exception SaslException   If a semantic error occurs
     */
void checkSemantics(DirectiveList dirList) throws SaslException {
    Iterator directives = dirList.getIterator();
    ParsedDirective directive;
    String name;
    while (directives.hasNext()) {
        directive = (ParsedDirective) directives.next();
        name = directive.getName();
        if (name.equals("rspauth"))
            m_responseValue = directive.getValue();
    }
    /* post semantic check */
    if (m_responseValue == null)
        throw new SaslException("Missing response-auth directive.");
}
Also used : Iterator(java.util.Iterator) SaslException(org.apache.harmony.javax.security.sasl.SaslException)

Aggregations

Iterator (java.util.Iterator)8930 ArrayList (java.util.ArrayList)2267 Set (java.util.Set)1895 HashMap (java.util.HashMap)1828 Map (java.util.Map)1714 List (java.util.List)1622 HashSet (java.util.HashSet)1602 Test (org.junit.Test)624 IOException (java.io.IOException)524 Collection (java.util.Collection)377 Region (org.apache.geode.cache.Region)240 SSOException (com.iplanet.sso.SSOException)227 File (java.io.File)216 LinkedList (java.util.LinkedList)213 TreeSet (java.util.TreeSet)191 LinkedHashMap (java.util.LinkedHashMap)181 Entry (java.util.Map.Entry)174 SMSException (com.sun.identity.sm.SMSException)169 ListIterator (java.util.ListIterator)146 TreeMap (java.util.TreeMap)145