/** * @param index The node index. * @return The product node at the given index. */ public T get(int index) { return nodeList.getAt(index); }
/** * Gets the product at the given index. * * @param index the index * @return The product at the given index. */ public Product getProduct(int index) { return productList.getAt(index); }
/** * Gets the index of the node with the given name. The method performs a case insensitive search. * * @param name the name of the node, must not be <code>null</code> * * @return the index of the node with the given name or <code>-1</code> if a node with the given name is not * contained in this list * * @throws IllegalArgumentException if the name is <code>null</code> */ public final int indexOf(String name) { Guardian.assertNotNull("name", name); int n = size(); for (int i = 0; i < n; i++) { if (getAt(i).getName().equalsIgnoreCase(name)) { return i; } } return -1; }
/** * Releases all of the resources used by this object instance and all of its owned children. Its primary use is to * allow the garbage collector to perform a vanilla job. * <p/> * <p>This method should be called only if it is for sure that this object instance will never be used again. The * results of referencing an instance of this class after a call to <code>dispose()</code> are undefined. */ public final void dispose() { for (int i = 0; i < size(); i++) { getAt(i).dispose(); } removeAll(); disposeRemovedList(); }
public void testGetAt() { addAllNodes(); assertEquals(_nodeList.getAt(0), _attribute1); assertEquals(_nodeList.getAt(1), _attribute2); assertEquals(_nodeList.getAt(2), _attribute3); assertEquals(_nodeList.getAt(3), _attribute4); try { _nodeList.getAt(-1); fail("IndexOutOfBoundsException expected"); } catch (java.lang.IndexOutOfBoundsException e) { } try { _nodeList.getAt(4); fail("IndexOutOfBoundsException expected"); } catch (java.lang.IndexOutOfBoundsException e) { } removeAllNodes(); }
/** * Creates a subset of this list using the given filter. * * @param filter the product node filter to be used, if <code>null</code> a clone of this list is created * * @return the subset */ public ProductNodeList<T> createSubset(ProductNodeFilter<T> filter) { ProductNodeList<T> list = new ProductNodeList<T>(); for (int i = 0; i < size(); i++) { T node = getAt(i); if (filter.accept(node)) { list.add(node); } } return list; }
private Product[] getCompatibleProducts() { List<Product> compatibleProducts = new ArrayList<Product>(productsList.size()); compatibleProducts.add(targetProduct); final float geolocationEps = getGeolocationEps(); Debug.trace("BandMathsDialog.geolocationEps = " + geolocationEps); Debug.trace("BandMathsDialog.getCompatibleProducts:"); Debug.trace(" comparing: " + targetProduct.getName()); for (int i = 0; i < productsList.size(); i++) { final Product product = productsList.getAt(i); if (targetProduct != product) { Debug.trace(" with: " + product.getDisplayName()); final boolean isCompatibleProduct = targetProduct.isCompatibleProduct(product, geolocationEps); Debug.trace(" result: " + isCompatibleProduct); if (isCompatibleProduct) { compatibleProducts.add(product); } } } return compatibleProducts.toArray(new Product[compatibleProducts.size()]); }
if (editProduct == null) { valueSet = sourceProducts.getDisplayNames(); Product product = (Product) sourceProducts.getAt(selectedProductIndex); prodName = createNewProductName(valueSet.length > 0 ? product.getName() : ""); prodDesc = "";