public String getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { return node.getName(); }
@Override public String toString() { return super.toString() + "[Name=" + getName() + ", displayName=" + getDisplayName() + "]"; // NOI18N }
/** Find a child node by name. * This may be overridden in subclasses to provide a more advanced way of finding the * child, but the default implementation simply scans through the list of nodes * to find the first one with the requested name. * <p>Normally the list of nodes should have been computed by the time this returns, * but see {@link #getNodes()} for an important caveat as to why this may not * be doing what you want and what to do instead. * @param name (code) name of child node to find or <code>null</code> if any arbitrary child may * be returned * @return the node or <code>null</code> if it could not be found */ public Node findChild(String name) { Node[] list = getNodes(); if (list.length == 0) { return null; } if (name == null) { // return any node return list[0]; } for (int i = 0; i < list.length; i++) { if (name.equals(list[i].getName())) { // ok, we have found it return list[i]; } } return null; }
public void setValue(String val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { Object oldName = node.getName(); node.setName(val); node.firePropertyChange(Node.PROP_NAME, oldName, val); } }
/** Find a path (by name) from one node to the root or a parent. * @param node the node to start in * @param parent parent node to stop in (can be <code>null</code> for the root) * @return list of child names--i.e. a path from the parent to the child node * @exception IllegalArgumentException if <code>node</code>'s getName() * method returns <code>null</code> */ public static String[] createPath(Node node, Node parent) { LinkedList<String> ar = new LinkedList<String>(); while ((node != null) && (node != parent)) { if (node.getName() == null) { boolean isFilter = false; if (node instanceof FilterNode) { isFilter = true; } throw new IllegalArgumentException( "Node:" + node.getClass() // NOI18N +"[" + node.getDisplayName() + "]" // NOI18N +(isFilter ? (" of original:" + ((FilterNode) node).getOriginal().getClass()) : "") // NOI18N +" gets null name!" ); // NOI18N } ar.addFirst(node.getName()); node = node.getParentNode(); } String[] res = new String[ar.size()]; ar.toArray(res); return res; }
/** Remove a Bean property change listener. * @param l the listener */ public final void removePropertyChangeListener(PropertyChangeListener l) { int count = -1; if (err.isLoggable(Level.FINE)) { count = getPropertyChangeListenersCount(); } listeners.remove(PropertyChangeListener.class, l); if (err.isLoggable(Level.FINE)) { err.log( Level.FINE, "RMV - " + getName() + " [" + count + "]->[" + getPropertyChangeListenersCount() + "] " + l ); } notifyPropertyChangeListenerRemoved(l); }
/** Add a listener to the node's computed Bean properties. * @param l the listener */ public final void addPropertyChangeListener(PropertyChangeListener l) { int count = -1; if (err.isLoggable(Level.FINE)) { count = getPropertyChangeListenersCount(); } listeners.add(PropertyChangeListener.class, l); if (err.isLoggable(Level.FINE)) { err.log( Level.FINE, "ADD - " + getName() + " [" + count + "]->[" + getPropertyChangeListenersCount() + "] " + l ); } notifyPropertyChangeListenerAdded(l); }
Children.PR.enterReadAccess(); String childPath = node.getName();
/** Returns cached name. * @return name of represented node */ public String getName () { if (name == UNKNOWN) { name = node == null ? null : node.getName (); } return name; }
/** Returns cached name. * @return name of represented node */ public String getName() { if (name == UNKNOWN) { name = (node == null) ? null : node.getName(); } return name; }
public class Node implements Comparable<Node> { public int compareTo(Node otherNode) { return node.getName().compareTo(otherNode.getName()); }
String query = "INSERT INTO " + table + " (name, department) values"; for (Node n : vertices) { query += " ('" + n.getName() + "', '" + n.getOrgId() + "')"); } statement.execute(query);
public class NodeAdapter implements JsonSerializer<Node> { public JsonElement serialize(Node node, Type type, JsonSerializationContext jsc) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("name", node.getName()); jsonObject.addProperty("group", node.getHyperEdge().getIdHe()); return jsonObject; } }
String query = "insert into " + table + " (name, department) values (?,?)"; try(PreparedStatement ps = connection.prepareStatement(query)) { for(Node n : vertices) { ps.setString(1, n.getName()); ps.setInt(2, n.getOrgId()); ps.addBatch(); } ps.executeBatch(); } catch(SQLException e) { // Exception handling }
HashSet<String> result = new HashSet(); for( Node leaf: list) search(false, name, leaf, result); public void search(boolean found, String name, Node node, HashSet<String> result){ if(node == null) return; found = found ? found : node.getName().equals(name); if(found) result.add(node.getId()); search(found, name, node.getParent(), result); }
private Node[] findDropedNodes(Node folder, Node[] dragNodes) { if ((folder == null) || (dragNodes.length == 0)) { return null; } Node[] dropNodes = new Node[dragNodes.length]; Children children = folder.getChildren(); for (int i = 0; i < dragNodes.length; i++) { dropNodes[i] = children.findChild(dragNodes[i].getName()); } return dropNodes; }
private Node[] findDropedNodes(Node folder, Node[] dragNodes) { if ((folder == null) || (dragNodes.length == 0)) { return null; } Node[] dropNodes = new Node[dragNodes.length]; Children children = folder.getChildren(); for (int i = 0; i < dragNodes.length; i++) { dropNodes[i] = children.findChild(dragNodes[i].getName()); } return dropNodes; }
public Node update(Node node, Long nodeId) throws EntityNotFoundException { Node updated = findById(nodeId, 0); updated.setDescription(node.getDescription()); updated.setType(node.getType()); updated.setName(node.getName()); updated.setCode(node.getCode()); //added param depth=0 here nodeRepository.save(updated, 0); return updated; }