/** * Tells whether the first segments of this {@link Path} matches * the segments of <code>path</code>. * @param path some other path * @return <code>true</code> if this path is either equal to <code>path</code> or * if this path starts with <code>path</code> */ public boolean startsWith( Path path ){ if( path.getSegmentCount() > getSegmentCount() ){ return false; } for( int i = 0, n = path.getSegmentCount(); i<n; i++ ){ if( !path.getSegment( i ).equals( getSegment( i ) )){ return false; } } return true; }
public void delete( Path path, int segment ){ if( segment == path.getSegmentCount() ){ delete( false ); } else if( children != null ){ String check = path.getSegment( segment ); for( TreeNode child : children ){ if( check.equals( child.getPath().getLastSegment() )){ child.delete( path, segment+1 ); break; } } } }
private Node getNode( Path path, boolean create, int segment ){ if( path.getSegmentCount() == segment ) return this; if( children == null ){ children = new ArrayList<Node>(); } String name = path.getSegment( segment ); for( Node child : children ){ if( name.equals( child.getName() )){ return child.getNode( path, create, segment+1 ); } } if( !create ) return null; Node result = new Node( name ); children.add( result ); return result.getNode( path, create, segment+1 ); } }
if( !placeholder.getSegment( 0 ).equals( "dock" ) ){ return true; if( placeholder.getSegment( 1 ).equals( "single" )){ String id = placeholder.getSegment( 2 ); if( placeholder.getSegment( 1 ).equals( "multi" ) ){ if( pendingChecks != null ){ pendingChecks.add( placeholder ); String id = placeholder.getSegment( 2 );
if( !placeholder.getSegment( 0 ).equals( "dock" ) ){ return false; if( placeholder.getSegment( 1 ).equals( "single" )){ String id = placeholder.getSegment( 2 ); if( placeholder.getSegment( 1 ).equals( "multi" ) ){ if( pendingChecks != null ){ pendingChecks.add( placeholder ); String id = placeholder.getSegment( 2 );
public TreeNode getNode( Path path, int segment ){ if( segment == path.getSegmentCount() ) return this; if( children == null ){ children = new ArrayList<TreeNode>(); } String check = path.getSegment( segment ); for( TreeNode child : children ){ if( check.equals( child.getPath().getLastSegment() )){ return child.getNode( path, segment+1 ); } } TreeNode child = new TreeNode( this, path.subPath( 0, segment+1 ) ); children.add( child ); fireNodeAdded( this, child ); return child.getNode( path, segment+1 ); }