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;
}
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);
}
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);
}
}
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() + ")");
}
}
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.");
}
Aggregations