List of usage examples for java.util List listIterator
ListIterator<E> listIterator();
From source file:org.apache.axis.utils.WSDLUtils.java
/** * Return the endpoint address from a <soap:address location="..."> tag *//*from w w w . java2s . c o m*/ public static String getAddressFromPort(Port p) { // Get the endpoint for a port List extensibilityList = p.getExtensibilityElements(); for (ListIterator li = extensibilityList.listIterator(); li.hasNext();) { Object obj = li.next(); if (obj instanceof SOAPAddress) { return ((SOAPAddress) obj).getLocationURI(); } else if (obj instanceof UnknownExtensibilityElement) { //TODO: After WSDL4J supports soap12, change this code UnknownExtensibilityElement unkElement = (UnknownExtensibilityElement) obj; QName name = unkElement.getElementType(); if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP) && name.getLocalPart().equals("address")) { return unkElement.getElement().getAttribute("location"); } } } // didn't find it return null; }
From source file:Main.java
/** * Keeps and returns the original list./*from w w w . j a v a 2s . com*/ * * @param <T> * @param list * @return removes any duplicates in the list. Keeps the first occurrence of duplicates. */ public static <T> List<T> removeDuplicates(List<T> list) { HashSet<T> set = new HashSet<T>(list.size()); ListIterator<T> i = list.listIterator(); while (i.hasNext()) { T cur = i.next(); if (set.contains(cur)) { i.remove(); } else { set.add(cur); } } return list; }
From source file:Main.java
/** * Parses the XPath expression in a string array containing the XPath elements. The expressiong must be a simple /a/b/c for * and it cannot contain any wild-cards or attributes. * //from w w w .ja v a 2 s.c o m * @param sPath Path to be parsed. * @return The XPath expression in a string array. * @throws IllegalArgumentException Thrown if the parsing failed. */ public static String[] parsePath(String sPath) throws IllegalArgumentException { if (sPath.indexOf("//") >= 0) { throw new IllegalArgumentException("Destination path cannot have wild-cards."); } List<String> lElemList = new LinkedList<String>(Arrays.asList(sPath.split("/"))); for (ListIterator<String> iIter = lElemList.listIterator(); iIter.hasNext();) { String sElem = iIter.next(); if (sElem.equals(".")) { throw new IllegalArgumentException("Destination path cannot have wild-cards."); } int iIndex = sElem.indexOf("@"); if (iIndex >= 0) { sElem = ((iIndex > 0) ? sElem.substring(0, iIndex) : ""); } if (sElem.length() == 0) { iIter.remove(); } } return lElemList.toArray(new String[lElemList.size()]); }
From source file:net.sf.jasperreports.engine.export.GenericElementReportTransformer.java
protected static void transformElements(TransformerContext context, String transformerExportKey, List<JRPrintElement> elements) { for (ListIterator<JRPrintElement> it = elements.listIterator(); it.hasNext();) { JRPrintElement element = it.next(); if (element instanceof JRGenericPrintElement) { JRGenericPrintElement genericElement = (JRGenericPrintElement) element; GenericElementTransformer handler = (GenericElementTransformer) GenericElementHandlerEnviroment .getInstance(context.getJasperReportsContext()) .getElementHandler(genericElement.getGenericType(), transformerExportKey); if (handler != null && handler.toExport(genericElement)) { JRPrintElement transformed = handler.transformElement(context, genericElement); if (log.isDebugEnabled()) { log.debug("Transformed element " + genericElement + " to " + transformed + " using the " + transformerExportKey + " transformer"); }// www . ja v a 2 s .com // assuming that the list is modifiable it.set(transformed); } } else if (element instanceof JRPrintFrame) { JRPrintFrame frame = (JRPrintFrame) element; transformElements(context, transformerExportKey, frame.getElements()); } } }
From source file:Main.java
public static <E> E setInSortedList(List<E> list, int index, E item, Comparator<? super E> comparator, BiPredicate<? super E, ? super E> distincter) { if (distincter != null) { ListIterator<E> iter = list.listIterator(); while (iter.hasNext()) { int currIndex = iter.nextIndex(); E currItem = iter.next();/* w w w.j av a2 s.c om*/ if (index != currIndex && distincter.test(currItem, item)) { return null; } } } E previousItem = list.set(index, item); list.sort(comparator); return previousItem; }
From source file:eu.eubrazilcc.lvl.storage.UrlShortenerTest.java
@BeforeClass public static void setUp() throws IOException { final File file = new File( concat(DEFAULT_LOCATION, TEST_CONFIG_ROOT + separator + "etc" + separator + REST_SERVICE_CONFIG)); if (file.canRead()) { final List<URL> urls = newArrayList(getDefaultConfiguration()); for (final ListIterator<URL> it = urls.listIterator(); it.hasNext();) { final URL url = it.next(); if (url.getPath().endsWith(REST_SERVICE_CONFIG)) { it.remove();//w ww . j a v a2 s. c o m it.add(toURLs(new File[] { file })[0]); } } CONFIG_MANAGER.setup(urls); hasToClean = true; } }
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 w w w. j a v a 2s . 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:org.apache.axis2.jaxws.util.WSDLExtensionValidatorUtil.java
/** * Activate any registered WSDLExtensionValidators to perform the validation * of...//from w ww . j a v a 2s .co m * * @param wsdlExtensionValidatorListID The name of the parameter in the * AxisConfiguration that contains * the list of validators. * @param msgContext * @throws AxisFault */ public static void performValidation(AxisConfiguration axisConfiguration, Set<WSDLValidatorElement> extensionSet, Definition wsdlDefinition, EndpointDescription endpointDescription) { if (debug) { log.debug( "Entered performValidation(AxisConfiguration, Set<WSDLValidatorElement>, Definition, EndpointDescription)"); log.debug("axisConfiguration=" + axisConfiguration); } if (axisConfiguration == null) { if (debug) { log.debug("The AxisConfiguration was null, so we can't fetch any validators"); } return; } if ((extensionSet == null) || (extensionSet.isEmpty())) { if (debug) { log.debug("There were no extensions to validate"); } return; } Parameter param = axisConfiguration.getParameter(Constants.WSDL_EXTENSION_VALIDATOR_LIST_ID); if (param != null) { List validatorList = (List) param.getValue(); ListIterator wsdlExtensionValidators = validatorList.listIterator(); while (wsdlExtensionValidators.hasNext()) { WSDLExtensionValidator wev = (WSDLExtensionValidator) wsdlExtensionValidators.next(); if (debug) { log.debug("Calling validate() on WSDLExtensionValidator: " + wev); } wev.validate(extensionSet, wsdlDefinition, endpointDescription); if (debug) { log.debug("Returned from WSDLExtensionValidator: " + wev); } } } }
From source file:Main.java
/** * Finds the first index where the value is located or * the index where it could be inserted, similar to the regular * binarySearch() methods, but it works with duplicate elements. * @param <T> the element type, self comparable * @param list the list to search/*from w ww. ja v a2 s.co m*/ * @param fromIndex the starting index, inclusive * @param toIndex the end index, exclusive * @param value the value to search * @return if positive, the exact index where the value is first * encountered, or -(insertion point - 1) if not in the array. */ private static <T extends Comparable<? super T>> int findFirstIterator(List<T> list, int fromIndex, int toIndex, T value) { int a = fromIndex; int b = toIndex; ListIterator<T> it = list.listIterator(); while (a <= b) { int mid = a + (b - a) / 2; T midVal = get(it, mid); int c = midVal.compareTo(value); if (c < 0) { a = mid + 1; } else if (c > 0) { b = mid - 1; } else { if (mid > 0) { if (get(it, mid - 1).compareTo(value) != 0) { return mid; } else { b = mid - 1; } } else { return 0; } } } return -(a + 1); }
From source file:Main.java
/** * Finds the last index where the value is located or * the index where it could be inserted, similar to the regular * binarySearch() methods, but it works with duplicate elements. * @param <T> the element type, self comparable * @param list the list to search//w w w . j a va2 s . com * @param fromIndex the starting index, inclusive * @param toIndex the end index, exclusive * @param value the value to search * @return if positive, the exact index where the value is first * encountered, or -(insertion point - 1) if not in the array. */ private static <T extends Comparable<? super T>> int findLastIterator(List<T> list, int fromIndex, int toIndex, T value) { int a = fromIndex; int b = toIndex; ListIterator<T> it = list.listIterator(); while (a <= b) { int mid = a + (b - a) / 2; T midVal = get(it, mid); int c = midVal.compareTo(value); if (c < 0) { a = mid + 1; } else if (c > 0) { b = mid - 1; } else { if (mid < toIndex - 1) { if (get(it, mid + 1).compareTo(value) != 0) { return mid; } else { a = mid + 1; } } else { return 0; } } } return -(a + 1); }