List of usage examples for java.util ListIterator hasNext
boolean hasNext();
From source file:de.codesourcery.asm.util.Disassembler.java
/** * Disassemble a method.//from w ww .j a v a2s . c o m * * @param method method to disassemble * @param includeVirtual whether to 'disassemble' virtual (ASM-generated) nodes that * have no equivalent in .class files * @param printInsnIndices * @param printInsnIndices whether to output the instruction index in front of the mnemonic * @return disassembled method */ public static String disassemble(MethodNode method, boolean includeVirtual, boolean printInsnIndices) { final StringBuilder result = new StringBuilder(); @SuppressWarnings("unchecked") final ListIterator<AbstractInsnNode> it = method.instructions.iterator(); while (it.hasNext()) { AbstractInsnNode node = it.next(); String line = disassemble(node, method, includeVirtual, printInsnIndices); if (line == null) { continue; } if (result.length() > 0) { result.append("\n"); } result.append(line); } return result.toString(); }
From source file:com.twitter.hraven.etl.FileLister.java
/** * prunes the given list/array of files based on their sizes * * @param maxFileSize -max #bytes to be stored in an hbase cell * @param origList - input list of files to be processed * @param hdfs - filesystem to be looked at * @param inputPath - root dir of the path containing history files * @return - pruned array of FileStatus of files to be processed */// w w w .j a v a 2 s. com static FileStatus[] pruneFileListBySize(long maxFileSize, FileStatus[] origList, FileSystem hdfs, Path inputPath) { LOG.info("Pruning orig list of size " + origList.length + " for source" + inputPath.toUri()); long fileSize = 0L; List<FileStatus> prunedFileList = new ArrayList<FileStatus>(); Set<String> toBeRemovedJobId = new HashSet<String>(); for (int i = 0; i < origList.length; i++) { fileSize = origList[i].getLen(); // check if hbase can store this file if yes, consider it for processing if (fileSize <= maxFileSize) { prunedFileList.add(origList[i]); } else { Path hugeFile = origList[i].getPath(); LOG.info("In getListFilesToProcess filesize " + fileSize + " has exceeded maxFileSize " + maxFileSize + " for " + hugeFile.toUri()); // note the job id so that we can remove the other file (job conf or job history) toBeRemovedJobId.add(getJobIdFromPath(hugeFile)); } } if (prunedFileList.size() == 0) { LOG.info("Found no files worth processing. Returning 0 sized array"); return new FileStatus[0]; } String jobId = null; ListIterator<FileStatus> it = prunedFileList.listIterator(); while (it.hasNext()) { if (toBeRemovedJobId.size() == 0) { // no files to remove break; } Path curFile = it.next().getPath(); jobId = getJobIdFromPath(curFile); if (toBeRemovedJobId.contains(jobId)) { LOG.info("Removing from prunedList " + curFile.toUri()); it.remove(); /* * removing the job id from the hash set since there would be only * one file with this job id in the prunedList, the other file with * this job id was huge and was already moved out */ toBeRemovedJobId.remove(jobId); } } return prunedFileList.toArray(new FileStatus[prunedFileList.size()]); }
From source file:org.apache.cxf.transport.jms.JMSOldConfigHolder.java
public static Properties getInitialContextEnv(AddressType addrType) { Properties env = new Properties(); java.util.ListIterator listIter = addrType.getJMSNamingProperty().listIterator(); while (listIter.hasNext()) { JMSNamingPropertyType propertyPair = (JMSNamingPropertyType) listIter.next(); if (null != propertyPair.getValue()) { env.setProperty(propertyPair.getName(), propertyPair.getValue()); }//from ww w.j av a 2s . com } if (LOG.isLoggable(Level.FINE)) { Enumeration props = env.propertyNames(); while (props.hasMoreElements()) { String name = (String) props.nextElement(); String value = env.getProperty(name); LOG.log(Level.FINE, "Context property: " + name + " | " + value); } } return env; }
From source file:org.mule.providers.soap.axis.wsdl.wsrf.util.AdviceAdderHelper.java
/** * addAdvisors to ProxyfactoryBean given using reflection to find Advices class * end with "Advice" suffix. All advisors are mapped on "extend*" pattern string * method refer to Target bean.//from ww w .j av a2 s. c o m * * @param targetImpl Target Object * @return new Proxy */ public static IExtendCall addAdvisorsTo(IExtendCall targetImpl) { ProxyFactory factory = new ProxyFactory(targetImpl); List l = getListAdvisorClass(); ListIterator li = l.listIterator(); Advisor advisor = null; if (order.size() == 0) { while (li.hasNext()) { advisor = (Advisor) li.next(); order.add(advisor); } } Iterator it = order.iterator(); while (it.hasNext()) { advisor = (Advisor) it.next(); factory.addAdvisor(countAdvice, advisor); Logger.getLogger(factory.getClass()).log(Level.DEBUG, factory.getClass().getName() + " : added " + advisor.getAdvice().getClass().getName() + " at index position " + countAdvice); countAdvice++; } countAdvice = 0; return (IExtendCall) factory.getProxy(); }
From source file:com.linuxbox.enkive.docsearch.indri.IndriQueryComposer.java
/** * Iterate through all the terms in the phrase and sanitize each one in * place./*from w w w . ja v a 2 s . c o m*/ * * @param phrase */ protected static void sanitizePhraseInPlace(Phrase phrase) { ListIterator<CharSequence> i = phrase.getTermsListIterator(); while (i.hasNext()) { CharSequence charSeq = i.next(); // convert to a StringBuffer if not one already StringBuffer buffer; if (!(charSeq instanceof StringBuffer)) { buffer = new StringBuffer(charSeq); } else { buffer = (StringBuffer) charSeq; } sanitizeStringBuffer(buffer); // replace term in phrase i.set(buffer); } }
From source file:com.amazonaws.hbase.kinesis.utils.EMRUtils.java
/** * Helper method to determine if HBase is installed on this cluster * @param client - The {@link AmazonElasticMapReduceClient} with read permissions * @param clusterId - unique identifier for this cluster * @return true, other throws Runtime exception *//*ww w.java2 s . c om*/ private static boolean isHBaseInstalled(AmazonElasticMapReduce client, String clusterId) { ListBootstrapActionsResult bootstrapActions = client .listBootstrapActions(new ListBootstrapActionsRequest().withClusterId(clusterId)); ListIterator<Command> iterator = bootstrapActions.getBootstrapActions().listIterator(); while (iterator.hasNext()) { Command command = iterator.next(); if (command.getName().equalsIgnoreCase("Install HBase")) return true; } throw new RuntimeException("ERROR: Apache HBase is not installed on this cluster!!"); }
From source file:be.ff.gui.web.struts.action.ActionPlugInChain.java
/** * This static method calls the <code>destroy</code> method on all <code>ActionPlugIn</code>s in the chain, * enabling them to release any referenced resources. *///from w w w.j a v a 2s. c o m protected static void destroy() { if (log.isDebugEnabled()) { log.debug("[ActionPlugInChain::init] Destroying the action plug-in chain ..."); } ListIterator iter = activeActionPlugInRegister.listIterator(); while (iter.hasNext()) { ActionPlugIn actionPlugIn = (ActionPlugIn) iter.next(); actionPlugIn.destroy(); } }
From source file:com.stratio.crossdata.sh.utils.ConsoleUtils.java
/** * This method save history extracted from the Crossdata console to be persisted in the disk. * * @param console Crossdata console created from a JLine console * @param file represents the file to be created of updated with the statements from the current * session// w w w. j a va 2s . c o m * @param sdf Simple Date Format to create dates for the history file * @throws IOException file couldn't be created or read */ public static void saveHistory(ConsoleReader console, File file, SimpleDateFormat sdf) throws IOException { boolean created = file.createNewFile(); OutputStreamWriter isr; if (created) { isr = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); } else { isr = new OutputStreamWriter(new FileOutputStream(file, true), "UTF-8"); } try (BufferedWriter bufferWriter = new BufferedWriter(isr)) { History history = console.getHistory(); ListIterator<History.Entry> histIter = history.entries(); while (histIter.hasNext()) { History.Entry entry = histIter.next(); bufferWriter.write(sdf.format(new Date())); bufferWriter.write("|"); bufferWriter.write(entry.value().toString()); bufferWriter.newLine(); } bufferWriter.flush(); } }
From source file:com.ibm.soatf.config.DirectoryStructureManager.java
/** * * @throws FrameworkConfigurationException *//*w w w . j a v a 2 s . c o m*/ public static void checkFrameworkDirectoryStructure() throws FrameworkConfigurationException { MasterConfiguration masterConfig = ConfigurationManager.getInstance().getMasterConfig(); final ListIterator<SOATestingFrameworkMasterConfiguration.Interfaces.Interface> interfaces = masterConfig .getXmlConfig().getInterfaces().getInterface().listIterator(); while (interfaces.hasNext()) { validateIfaceStructure(interfaces.next()); } }
From source file:exm.stc.ic.ICUtil.java
public static void replaceVarsInList(Map<Var, Arg> replacements, List<Var> vars, boolean removeDupes, boolean removeMapped) { // Remove new duplicates ArrayList<Var> alreadySeen = null; if (removeDupes) { alreadySeen = new ArrayList<Var>(vars.size()); }/* w w w.j a va 2 s. c o m*/ ListIterator<Var> it = vars.listIterator(); while (it.hasNext()) { Var v = it.next(); if (replacements.containsKey(v)) { Arg oa = replacements.get(v); if (oa.isVar()) { if (removeDupes && alreadySeen.contains(oa.getVar())) { it.remove(); } else { it.set(oa.getVar()); if (removeDupes) { alreadySeen.add(oa.getVar()); } } } } else { if (removeDupes) { if (alreadySeen.contains(v)) { it.remove(); } else { alreadySeen.add(v); } } } } }