Input: Tries to find the Resource History view attempting to open it if necessary . [CODESPLIT] public static ResourceHistoryView getResourceHistoryView ( ) throws Exception { IWorkbenchWindow activeWindow = Activator . getDefault ( ) . getWorkbench ( ) . getActiveWorkbenchWindow ( ) ; // If there is no active workbench window, then there can be no Repository History view if ( activeWindow == null ) { return null ; } // If there is no active workbench page, then there can be no Repository History view IWorkbenchPage page = activeWindow . getActivePage ( ) ; if ( page == null ) { return null ; } return ( ResourceHistoryView ) page . showView ( IGuvnorConstants . RESHISTORYVIEW_ID ) ; }


Input: Opens a read - only in - memory editor . [CODESPLIT] public static void openEditor ( String contents , String name ) { IWorkbenchWindow window = PlatformUI . getWorkbench ( ) . getActiveWorkbenchWindow ( ) ; IStorage storage = new StringStorage ( contents , name ) ; IStorageEditorInput input = new StringInput ( storage ) ; IWorkbenchPage page = window . getActivePage ( ) ; IEditorDescriptor desc = PlatformUI . getWorkbench ( ) . getEditorRegistry ( ) . getDefaultEditor ( name ) ; // If there is no editor associated with the given file name, we'll just // use the eclipse text editor as a default String editorId = desc != null ? desc . getId ( ) : "org.eclipse.ui.DefaultTextEditor" ; //$NON-NLS-1$ try { if ( page != null ) { page . openEditor ( input , editorId ) ; } } catch ( Exception e ) { Activator . getDefault ( ) . displayError ( IStatus . ERROR , e . getMessage ( ) , e , true ) ; } }


Input: Convenience method for reporting log in failure [CODESPLIT] public static void reportAuthenticationFailure ( ) { Display display = PlatformUI . getWorkbench ( ) . getDisplay ( ) ; display . asyncExec ( new Runnable ( ) { public void run ( ) { Display display = Display . getCurrent ( ) ; Shell shell = display . getActiveShell ( ) ; MessageDialog . openError ( shell , Messages . getString ( "login.failure.dialog.caption" ) , //$NON-NLS-1$ Messages . getString ( "login.failure.dialog.message" ) ) ; //$NON-NLS-1$ } } ) ; }


Input: Prompts for user name and password for a given Guvnor repository . [CODESPLIT] public AuthPromptResults promptForAuthentication ( final String server ) { Display display = PlatformUI . getWorkbench ( ) . getDisplay ( ) ; AuthPromptRunnable op = new AuthPromptRunnable ( server ) ; display . syncExec ( op ) ; return op . getResults ( ) ; }


Input: Returns a buffer ( byte array ) of size <code > BUFFER_SIZE< / code > from the pool . When the buffer is no longer needed it should be put back in the pool for future use by calling <code > putBuffer< / code > . [CODESPLIT] public synchronized byte [ ] getBuffer ( ) { if ( pool . isEmpty ( ) ) return new byte [ BUFFER_SIZE ] ; byte [ ] buffer = ( byte [ ] ) pool . lastElement ( ) ; pool . removeElementAt ( pool . size ( ) - 1 ) ; return buffer ; }


Input: Puts the given buffer into the pool for future use . The size of the buffer must be <code > BUFFER_SIZE< / code > . [CODESPLIT] public synchronized void putBuffer ( byte [ ] buffer ) { Assert . isNotNull ( buffer ) ; Assert . isTrue ( buffer . length == BUFFER_SIZE ) ; if ( pool . size ( ) < MAX_BUFFERS ) pool . addElement ( buffer ) ; }


Input: Creates a page displayed when there are no servers defined . [CODESPLIT] private Control createDefaultPage ( FormToolkit kit ) { Form form = kit . createForm ( book ) ; Composite body = form . getBody ( ) ; GridLayout layout = new GridLayout ( 2 , false ) ; body . setLayout ( layout ) ; Link hlink = new Link ( body , SWT . NONE ) ; hlink . setText ( "Use the Servers View to create a new server..." ) ; hlink . setBackground ( book . getDisplay ( ) . getSystemColor ( SWT . COLOR_LIST_BACKGROUND ) ) ; GridData gd = new GridData ( SWT . LEFT , SWT . FILL , true , false ) ; hlink . setLayoutData ( gd ) ; hlink . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent e ) { // show Servers View ViewUtils . showServersView ( ) ; } } ) ; // Create the context menu for the default page final CommonViewer commonViewer = this . getCommonViewer ( ) ; if ( commonViewer != null ) { ICommonViewerSite commonViewerSite = CommonViewerSiteFactory . createCommonViewerSite ( this . getViewSite ( ) ) ; if ( commonViewerSite != null ) { // Note: actionService cannot be null final NavigatorActionService actionService = new NavigatorActionService ( commonViewerSite , commonViewer , commonViewer . getNavigatorContentService ( ) ) ; MenuManager menuManager = new MenuManager ( "#PopupMenu" ) ; menuManager . addMenuListener ( new IMenuListener ( ) { public void menuAboutToShow ( IMenuManager mgr ) { ISelection selection = commonViewer . getSelection ( ) ; actionService . setContext ( new ActionContext ( selection ) ) ; actionService . fillContextMenu ( mgr ) ; } } ) ; Menu menu = menuManager . createContextMenu ( body ) ; // It is necessary to set the menu in two places: // 1. The white space in the server view // 2. The text and link in the server view. If this menu is not // set, if the // user right clicks on the text or uses shortcut keys to open // the context menu, // the context menu will not come up body . setMenu ( menu ) ; hlink . setMenu ( menu ) ; } else { // if (Trace.FINEST) { // Trace.trace(Trace.STRING_FINEST, // "The commonViewerSite is null"); // } } } else { // if (Trace.FINEST) { // Trace.trace(Trace.STRING_FINEST, "The commonViewer is null"); // } } return form ; }


Input: Switch between the servers and default / empty page . [CODESPLIT] void toggleDefaultPage ( ) { if ( treeViewer . getTree ( ) . getItemCount ( ) < 1 ) { book . showPage ( noServersPage ) ; } else { book . showPage ( mainPage ) ; } }


Input: Start the animation thread [CODESPLIT] protected void startThread ( ) { if ( animationActive ) return ; stopAnimation = false ; final Display display = treeViewer == null ? Display . getDefault ( ) : treeViewer . getControl ( ) . getDisplay ( ) ; final int SLEEP = 200 ; final Runnable [ ] animator = new Runnable [ 1 ] ; animator [ 0 ] = new Runnable ( ) { public void run ( ) { if ( ! stopAnimation ) { try { int size = 0 ; String [ ] servers ; synchronized ( starting ) { size = starting . size ( ) ; servers = new String [ size ] ; starting . toArray ( servers ) ; } for ( int i = 0 ; i < size ; i ++ ) { IServer server = ServerCore . findServer ( servers [ i ] ) ; if ( server != null ) { // ServerDecorator.animate(); treeViewer . update ( server , new String [ ] { "ICON" } ) ; } } } catch ( Exception e ) { // if (Trace.FINEST) { // Trace.trace(Trace.STRING_FINEST, // "Error in Servers view animation", e); // } } display . timerExec ( SLEEP , animator [ 0 ] ) ; } } } ; Display . getDefault ( ) . asyncExec ( new Runnable ( ) { public void run ( ) { display . timerExec ( SLEEP , animator [ 0 ] ) ; } } ) ; }


Input: Adds the given property href to this propertybehavior s list of live properties . The property href must not be <code > null< / code > and the form of this property behavior must not already be omit or keepAllAlive . [CODESPLIT] public void addProperty ( String propertyHref ) { Assert . isNotNull ( propertyHref ) ; Assert . isTrue ( getFirstChild ( root , "omit" ) == null ) ; //$NON-NLS-1$ Element keepalive = getFirstChild ( root , "keepalive" ) ; //$NON-NLS-1$ if ( keepalive == null ) keepalive = addChild ( root , "keepalive" , fgNamesKeepAlive , true ) ; //$NON-NLS-1$ else Assert . isTrue ( ! "*" . equals ( getFirstText ( keepalive ) ) ) ; //$NON-NLS-1$ addChild ( keepalive , "href" , //$NON-NLS-1$ encodeHref ( propertyHref ) , new String [ ] { "href" } , //$NON-NLS-1$ false ) ; }


Input: Returns an <code > Enumeration< / code > over this propertybehavior s property hrefs . The methods <code > isMerge () < / code > and <code > isKeepAllAlive< / code > return false if this propertybehavior is in the keep some alive form . [CODESPLIT] public Enumeration getProperties ( ) throws MalformedElementException { Element keepalive = getFirstChild ( root , "keepalive" ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingKeealiveElmt" ) , keepalive ) ; //$NON-NLS-1$ ensure ( ! "*" . equals ( getFirstText ( keepalive ) ) , //$NON-NLS-1$ Policy . bind ( "ensure.wrongForm" ) ) ; //$NON-NLS-1$ final Element firstHref = getFirstChild ( keepalive , "href" ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingHrefElmt" ) , firstHref ) ; //$NON-NLS-1$ Enumeration e = new Enumeration ( ) { Element currentHref = firstHref ; public boolean hasMoreElements ( ) { return currentHref != null ; } public Object nextElement ( ) { if ( ! hasMoreElements ( ) ) throw new NoSuchElementException ( ) ; String href = getFirstText ( currentHref ) ; currentHref = getTwin ( currentHref , true ) ; return decodeHref ( href ) ; } } ; return e ; }


Input: Returns <code > true< / code > if this propertybehavior is in the keep all alive form otherwise returns <code > false< / code > . [CODESPLIT] public boolean isKeepAllAlive ( ) throws MalformedElementException { Element child = getFirstChild ( root , childNames ) ; ensureNotNull ( Policy . bind ( "ensure.expectingOmitOrKeepaliveElmt" ) , child ) ; //$NON-NLS-1$ boolean isKeepAllAlive = false ; if ( isDAVElement ( child , "keepalive" ) ) { //$NON-NLS-1$ isKeepAllAlive = "*" . equals ( getFirstText ( child ) ) ; //$NON-NLS-1$ ensureNull ( Policy . bind ( "ensure.conflictingHrefElmt" ) , getFirstChild ( child , "href" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ } child = getNextSibling ( child , childNames ) ; ensureNull ( Policy . bind ( "ensure.conflictingOmitOrKeepaliveElmt" ) , child ) ; //$NON-NLS-1$ return isKeepAllAlive ; }


Input: Sets whether this propertybehavior is in the keep all alive form or not . [CODESPLIT] public void setIsKeepAllAlive ( boolean isKeepAllAlive ) { Element child = getFirstChild ( root , childNames ) ; boolean isAlreadyKeepAllAlive = false ; if ( isDAVElement ( child , "keepalive" ) ) //$NON-NLS-1$ isAlreadyKeepAllAlive = "*" . equals ( getFirstText ( child ) ) ; //$NON-NLS-1$ if ( isKeepAllAlive ) { if ( ! isAlreadyKeepAllAlive ) { if ( child != null ) root . removeChild ( child ) ; appendChild ( root , "keepalive" , "*" ) ; //$NON-NLS-1$ //$NON-NLS-2$ } } else if ( isAlreadyKeepAllAlive ) root . removeChild ( child ) ; }


Input: Sets whether this propertybehavior is in the omit form or not . [CODESPLIT] public void setIsOmit ( boolean isOmit ) { Element child = getFirstChild ( root , childNames ) ; boolean isAlreadyOmit = isDAVElement ( child , "omit" ) ; //$NON-NLS-1$ if ( isOmit ) { if ( ! isAlreadyOmit ) { if ( child != null ) root . removeChild ( child ) ; appendChild ( root , "omit" ) ; //$NON-NLS-1$ } } else if ( isAlreadyOmit ) root . removeChild ( child ) ; }


Input: Adds the given href to this activelock s locktoken . The href must not be <code > null< / code > . [CODESPLIT] public void addLockTokenHref ( String href ) { Assert . isNotNull ( href ) ; Element locktoken = getLastChild ( root , "locktoken" ) ; //$NON-NLS-1$ if ( locktoken == null ) locktoken = setChild ( root , "locktoken" , childNames , false ) ; //$NON-NLS-1$ appendChild ( locktoken , "href" , encodeHref ( href ) ) ; //$NON-NLS-1$ }


Input: Returns the depth of this activelock ; for example <code > Context . DEPTH_ZERO< / code > . [CODESPLIT] public String getDepth ( ) throws MalformedElementException { String depth = getChildText ( root , "depth" , false ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingDepthElmt" ) , depth ) ; //$NON-NLS-1$ ensure ( depth . equals ( IContext . DEPTH_ZERO ) || depth . equals ( IContext . DEPTH_ONE ) || depth . equals ( IContext . DEPTH_INFINITY ) , Policy . bind ( "ensure.invalidDepth" , depth ) ) ; //$NON-NLS-1$ return depth ; }


Input: Returns an <code > Enumeration< / code > of <code > String< / code > s containing this activelock s lock token hrefs . [CODESPLIT] public Enumeration getLockTokenHrefs ( ) throws MalformedElementException { Element locktoken = getLastChild ( root , "locktoken" ) ; //$NON-NLS-1$ Element firstHref = null ; if ( locktoken != null ) { firstHref = getFirstChild ( locktoken , "href" ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingHrefElmt" ) , firstHref ) ; //$NON-NLS-1$ } final Node node = firstHref ; Enumeration e = new Enumeration ( ) { Node currentHref = node ; public boolean hasMoreElements ( ) { return currentHref != null ; } public Object nextElement ( ) { if ( ! hasMoreElements ( ) ) { throw new NoSuchElementException ( ) ; } String href = getFirstText ( ( Element ) currentHref ) ; currentHref = getTwin ( ( Element ) currentHref , true ) ; return decodeHref ( href ) ; } } ; return e ; }


Input: Returns this activelock s owner or <code > null< / code > if this active lock has no owner . [CODESPLIT] public Owner getOwner ( ) throws MalformedElementException { Element owner = getLastChild ( root , "owner" ) ; //$NON-NLS-1$ if ( owner == null ) return null ; return new Owner ( owner ) ; }


Input: Sets the depth of this activelock to the given depth . The depth must not be null and must be one of : <ul > <li > <code > Context . DEPTH_ZERO< / code > <li > <code > Context . DEPTH_ONE< / code > <li > <code > Context . DEPTH_INFINITY< / code > < / ul > [CODESPLIT] public void setDepth ( String depth ) { Assert . isNotNull ( depth ) ; Assert . isTrue ( depth . equals ( IContext . DEPTH_ZERO ) || depth . equals ( IContext . DEPTH_ONE ) || depth . equals ( IContext . DEPTH_INFINITY ) ) ; setChild ( root , "depth" , depth , childNames , false ) ; //$NON-NLS-1$ }


Input: Sets whether this activelock is shared or exclusive . If isShared is <code > true< / code > the activelock is set as shared otherwise the activelock is set as exclusive . [CODESPLIT] public void setIsShared ( boolean isShared ) { Element lockscope = setChild ( root , "lockscope" , childNames , true ) ; //$NON-NLS-1$ if ( isShared ) appendChild ( lockscope , "shared" ) ; //$NON-NLS-1$ else appendChild ( lockscope , "exclusive" ) ; //$NON-NLS-1$ }


Input: Creates and sets an owner element on this activelock and returns an editor on it . [CODESPLIT] public Owner setOwner ( ) { Element owner = setChild ( root , "owner" , childNames , false ) ; //$NON-NLS-1$ Owner result = null ; try { result = new Owner ( owner ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } return result ; }


Input: Sets the timeout on this activelock to the given timeout . If the timeout is <code > null< / code > the current timeout is removed . [CODESPLIT] public void setTimeout ( String timeout ) { if ( timeout == null ) { Element child = getLastChild ( root , "timeout" ) ; //$NON-NLS-1$ if ( child != null ) root . removeChild ( child ) ; } else setChild ( root , "timeout" , timeout , childNames , false ) ; //$NON-NLS-1$ }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public String getPreferenceName ( String name ) { String canonicalName = getCanonicalName ( getRoot ( ) . getName ( ) ) ; if ( name == null ) return canonicalName ; return canonicalName + IKieConstants . PREF_PATH_SEPARATOR + getCanonicalName ( name ) ; }


Input: Creates a new WebDAV lockinfo element and sets it as the root of the given document . Returns an editor on the new lockinfo element . The document must not be <code > null< / code > and must not already have a root element . [CODESPLIT] public static LockInfo create ( Document document ) { Assert . isNotNull ( document ) ; Assert . isTrue ( document . getOwnerDocument ( ) == null ) ; Element element = create ( document , "lockinfo" ) ; //$NON-NLS-1$ Element locktype = appendChild ( element , "locktype" ) ; //$NON-NLS-1$ appendChild ( locktype , "write" ) ; //$NON-NLS-1$ LockInfo result = null ; try { result = new LockInfo ( element ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } return result ; }


Input: Returns <code > true< / code > if this lockinfo is shared and <code > false< / code > if it is exclusive . [CODESPLIT] public boolean isShared ( ) throws MalformedElementException { Element lockscope = getFirstChild ( root , "lockscope" ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingLockscopeElmt" ) , lockscope ) ; //$NON-NLS-1$ String [ ] names = new String [ ] { "shared" , "exclusive" } ; //$NON-NLS-1$ //$NON-NLS-2$ Element sharedOrExclusive = getFirstChild ( lockscope , names ) ; ensureNotNull ( Policy . bind ( "ensure.missingSharedOrExclusiveElmt" ) , sharedOrExclusive ) ; //$NON-NLS-1$ boolean isShared = isDAVElement ( sharedOrExclusive , "shared" ) ; //$NON-NLS-1$ ensure ( getNextSibling ( sharedOrExclusive , names ) == null , Policy . bind ( "ensure.conflictingSharedOrExclusiveElmt" ) ) ; //$NON-NLS-1$ return isShared ; }


Input: Add a ConditionFactor to a ConditionTerm . [CODESPLIT] public void addConditionFactor ( ConditionFactor factor ) throws WebDAVException { if ( conditionFactors . contains ( factor ) ) throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseDuplicateEntry" ) ) ; //$NON-NLS-1$ conditionFactors . addElement ( factor ) ; }


Input: Create a ConditionTerm by parsing the given If header as defined by section 9 . 4 in the WebDAV spec . [CODESPLIT] public static ConditionTerm create ( StreamTokenizer tokenizer ) throws WebDAVException { ConditionTerm term = new ConditionTerm ( ) ; try { int token = tokenizer . ttype ; if ( token == ' ' ) token = tokenizer . nextToken ( ) ; else throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissing" , String . valueOf ( token ) , "(" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ while ( token == StreamTokenizer . TT_WORD || token == ' ' || token == ' ' ) { term . addConditionFactor ( ConditionFactor . create ( tokenizer ) ) ; token = tokenizer . ttype ; } if ( token == ' ' ) token = tokenizer . nextToken ( ) ; else throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissing" , String . valueOf ( token ) , ")" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ } catch ( IOException exc ) { // ignore or log? } if ( ! term . getConditionFactors ( ) . hasMoreElements ( ) ) throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissingStateOrEntity" ) ) ; //$NON-NLS-1$ return term ; }


Input: See if this ConditionTerm matches the given ConditionTerm . This is an AND operation . All the factors in the ConditionTerm must match . [CODESPLIT] public boolean matches ( ConditionTerm conditionTerm ) { int numberOfItemsToMatch = 0 ; boolean match = true ; Enumeration factors = getConditionFactors ( ) ; while ( match && factors . hasMoreElements ( ) ) { ConditionFactor factor = ( ConditionFactor ) factors . nextElement ( ) ; if ( factor . not ( ) ) { match = ! conditionTerm . contains ( factor ) ; } else { match = conditionTerm . contains ( factor ) ; numberOfItemsToMatch ++ ; } } match = match && numberOfItemsToMatch == conditionTerm . numberOfFactors ( ) ; return match ; }


Input: Get the appropriate content assistance for each partition . [CODESPLIT] public IContentAssistant getContentAssistant ( ISourceViewer sourceViewer ) { ContentAssistant assistant = new ContentAssistant ( ) ; assistant . setContentAssistProcessor ( new DefaultCompletionProcessor ( getEditor ( ) ) , IDocument . DEFAULT_CONTENT_TYPE ) ; assistant . setContentAssistProcessor ( new DSLRuleCompletionProcessor ( getEditor ( ) ) , DRLPartionScanner . RULE_PART_CONTENT ) ; assistant . setProposalPopupOrientation ( IContentAssistant . PROPOSAL_OVERLAY ) ; assistant . setAutoActivationDelay ( 0 ) ; return assistant ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void propertyChange ( PropertyChangeEvent evt ) { String prop = evt . getPropertyName ( ) ; if ( GraphicalVertex . SIZE_PROP . equals ( prop ) || GraphicalVertex . LOCATION_PROP . equals ( prop ) ) { refreshVisuals ( ) ; } else if ( GraphicalVertex . SOURCE_CONNECTIONS_PROP . equals ( prop ) ) { refreshSourceConnections ( ) ; } else if ( GraphicalVertex . TARGET_CONNECTIONS_PROP . equals ( prop ) ) { refreshTargetConnections ( ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] protected void refreshVisuals ( ) { Rectangle bounds = new Rectangle ( getCastedModel ( ) . getLocation ( ) , getCastedModel ( ) . getSize ( ) ) ; ( ( GraphicalEditPart ) getParent ( ) ) . setLayoutConstraint ( this , getFigure ( ) , bounds ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public Object getAdapter ( @ SuppressWarnings ( "rawtypes" ) Class key ) { if ( key == IPropertySource . class ) { return propertySource ; } return super . getAdapter ( key ) ; }


Input: $NON - NLS - 1$ [CODESPLIT] @ Override public void initializeRuntimes ( List < RuntimeDefinition > serverDefinitions ) { IRuntime [ ] existingRuntimes = DroolsRuntimeManager . getDefault ( ) . getConfiguredRuntimes ( ) ; List < DroolsRuntime > droolsRuntimes = new ArrayList < DroolsRuntime > ( ) ; if ( existingRuntimes != null ) { for ( IRuntime runtime : existingRuntimes ) { if ( runtime instanceof DroolsRuntime ) droolsRuntimes . add ( ( DroolsRuntime ) runtime ) ; } } initializeInternal ( serverDefinitions , droolsRuntimes ) ; if ( droolsRuntimes . size ( ) > 0 ) { DroolsRuntime [ ] dra = droolsRuntimes . toArray ( new DroolsRuntime [ 0 ] ) ; DroolsRuntimeManager . getDefault ( ) . setRuntimes ( dra ) ; } }


Input: / * create and returns a java project based on the current editor input or returns null [CODESPLIT] private IJavaProject getCurrentJavaProject ( ) { IEditorInput input = getEditor ( ) . getEditorInput ( ) ; if ( ! ( input instanceof IFileEditorInput ) ) { return null ; } IProject project = ( ( IFileEditorInput ) input ) . getFile ( ) . getProject ( ) ; IJavaProject javaProject = JavaCore . create ( project ) ; return javaProject ; }


Input: / * do we already have a completion for that string that would be either a local variable or a field? [CODESPLIT] protected static boolean doesNotContainFieldCompletion ( String completion , List < ICompletionProposal > completions ) { if ( completion == null || completion . length ( ) == 0 || completions == null ) { return false ; } for ( Iterator < ICompletionProposal > iter = completions . iterator ( ) ; iter . hasNext ( ) ; ) { Object o = iter . next ( ) ; if ( o instanceof AbstractJavaCompletionProposal ) { AbstractJavaCompletionProposal prop = ( AbstractJavaCompletionProposal ) o ; String content = prop . getReplacementString ( ) ; if ( completion . equals ( content ) ) { IJavaElement javaElement = prop . getJavaElement ( ) ; if ( javaElement instanceof ILocalVariable || javaElement instanceof IField ) { return false ; } } } } return true ; }


Input: Get a reader to the DSL contents [CODESPLIT] public static Reader getDSLContent ( String ruleSource , IResource input ) throws CoreException { String dslFileName = findDSLConfigName ( ruleSource , input ) ; if ( dslFileName == null ) { return null ; } IResource res = findDSLResource ( input , dslFileName ) ; if ( res instanceof IFile ) { IFile dslConf = ( IFile ) res ; if ( dslConf . exists ( ) ) { return new InputStreamReader ( dslConf . getContents ( ) ) ; } } return null ; }


Input: This does the hunting around the projec to find the . dsl file . [CODESPLIT] private void loadConfig ( IFile input ) { IResource res = findDSLResource ( input , dslConfigName ) ; if ( res instanceof IFile ) { IFile dslConf = ( IFile ) res ; if ( dslConf . exists ( ) ) { InputStream stream = null ; try { stream = dslConf . getContents ( ) ; readConfig ( stream ) ; valid = true ; } catch ( Exception e ) { throw new IllegalStateException ( "Unable to open DSL config file. (Exception: " + e . getMessage ( ) + ")" ) ; } finally { closeStream ( stream ) ; } } } }


Input: This will load in the DSL config file using the DSLMapping from drools - compiler [CODESPLIT] void readConfig ( InputStream stream ) throws IOException , CoreException { DSLTokenizedMappingFile file = new DSLTokenizedMappingFile ( ) ; file . parseAndLoad ( new InputStreamReader ( stream ) ) ; DSLMapping grammar = file . getMapping ( ) ; List < DSLMappingEntry > conditions = grammar . getEntries ( DSLMappingEntry . CONDITION ) ; List < DSLMappingEntry > consequences = grammar . getEntries ( DSLMappingEntry . CONSEQUENCE ) ; conditionProposals = buildProposals ( conditions ) ; consequenceProposals = buildProposals ( consequences ) ; dslTree . buildTree ( grammar ) ; }


Input: Sniffs out the expander / DSL config name as best it can . [CODESPLIT] static String findDSLConfigName ( String content ) { String name = null ; Matcher matches = EXPANDER_PATTERN . matcher ( content ) ; if ( matches . find ( ) ) { name = matches . group ( 1 ) + ".dsl" ; } return name ; }


Input: Returns the given <code > URL< / code > with a trailing slash appended to it . If the <code > URL< / code > already has a trailing slash the <code > URL< / code > is returned unchanged . <table > <caption > Example< / caption > <tr > <th > Given URL< / th > <th > Returned URL< / th > <tr > <td > http : // hostname / folder < / td > <td > http : // hostname / folder / < / td > <tr > <td > http : // hostname / folder / < / td > <td > http : // hostname / folder / < / td > < / table > [CODESPLIT] public static URL appendTrailingSlash ( URL url ) { String file = url . getFile ( ) ; if ( file . endsWith ( "/" ) ) { //$NON-NLS-1$ return url ; } try { return new URL ( url . getProtocol ( ) , url . getHost ( ) , url . getPort ( ) , file + "/" ) ; //$NON-NLS-1$ } catch ( MalformedURLException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } return null ; }


Input: Returns the child URL formed by joining the given member with the given parent URL . [CODESPLIT] public static URL getChild ( String parent , String member ) throws MalformedURLException { return getChild ( new URL ( parent ) , member ) ; }


Input: Returns the child URL formed by joining the given member with the given parent URL . [CODESPLIT] public static URL getChild ( URL parent , String member ) { String file = parent . getFile ( ) ; if ( ! file . endsWith ( "/" ) ) //$NON-NLS-1$ file = file + "/" ; //$NON-NLS-1$ try { return new URL ( parent . getProtocol ( ) , parent . getHost ( ) , parent . getPort ( ) , file + member ) ; } catch ( MalformedURLException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } return null ; }


Input: Returns all elements in the given URLs path . <table > <caption > Example< / caption > <tr > <th > Given URL< / th > <th > Element< / th > <tr > <td > http : // hostname / < / td > <td > [] < / td > <tr > <td > http : // hostname / folder / < / td > <td > [ folder ] < / td > <tr > <td > http : // hostname / folder / file< / td > <td > [ folder file ] < / td > < / table > [CODESPLIT] public static Vector getElements ( URL url ) { Vector result = new Vector ( 5 ) ; String lastElement = null ; while ( ( lastElement = getLastElement ( url ) ) != null ) { result . insertElementAt ( lastElement , 0 ) ; url = getParent ( url ) ; } return result ; }


Input: Returns the last element in the given URLs path or <code > null< / code > if the URL is the root . <table > <caption > Example< / caption > <tr > <th > Given URL< / th > <th > Last Element< / th > <tr > <td > http : // hostname / < / td > <td > null< / td > <tr > <td > http : // hostname / folder / < / td > <td > folder< / td > <tr > <td > http : // hostname / folder / file< / td > <td > file< / td > < / table > [CODESPLIT] public static String getLastElement ( URL url ) { String file = url . getFile ( ) ; int len = file . length ( ) ; if ( len == 0 || len == 1 && file . charAt ( 0 ) == ' ' ) { return null ; } int lastSlashIndex = - 1 ; for ( int i = len - 2 ; lastSlashIndex == - 1 && i >= 0 ; -- i ) { if ( file . charAt ( i ) == ' ' ) { lastSlashIndex = i ; } } boolean isDirectory = file . charAt ( len - 1 ) == ' ' ; if ( lastSlashIndex == - 1 ) { if ( isDirectory ) return file . substring ( 0 , len - 1 ) ; return file ; } if ( isDirectory ) return file . substring ( lastSlashIndex + 1 , len - 1 ) ; return file . substring ( lastSlashIndex + 1 , len ) ; }


Input: Returns the parent URL of the given URL or <code > null< / code > if the given URL is the root . <table > <caption > Example< / caption > <tr > <th > Given URL< / th > <th > Parent URL< / th > <tr > <td > http : // hostname / < / td > <td > null< / td > <tr > <td > http : // hostname / folder / file< / td > <td > http : // hostname / folder / < / td > < / table > [CODESPLIT] public static URL getParent ( URL url ) { String file = url . getFile ( ) ; int len = file . length ( ) ; if ( len == 0 || len == 1 && file . charAt ( 0 ) == ' ' ) return null ; int lastSlashIndex = - 1 ; for ( int i = len - 2 ; lastSlashIndex == - 1 && i >= 0 ; -- i ) { if ( file . charAt ( i ) == ' ' ) lastSlashIndex = i ; } if ( lastSlashIndex == - 1 ) file = "" ; //$NON-NLS-1$ else file = file . substring ( 0 , lastSlashIndex + 1 ) ; try { url = new URL ( url . getProtocol ( ) , url . getHost ( ) , url . getPort ( ) , file ) ; } catch ( MalformedURLException e ) { Assert . isTrue ( false , e . getMessage ( ) ) ; } return url ; }


Input: Returns the root URL of the given URL . <table > <caption > Example< / caption > <tr > <th > Given URL< / th > <th > Root URL< / th > <tr > <td > http : // hostname / < / td > <td > http : // hostname / < / td > <tr > <td > http : // hostname / folder / file< / td > <td > http : // hostname / < / td > < / table > [CODESPLIT] public static URL getRoot ( URL url ) { try { return new URL ( url . getProtocol ( ) , url . getHost ( ) , url . getPort ( ) , "/" ) ; //$NON-NLS-1$ } catch ( MalformedURLException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } return null ; }


Input: Returns the given URL with its trailing slash removed . If the URL has no trailing slash the URL is returned unchanged . <table > <caption > Example< / caption > <tr > <th > Given URL< / th > <th > Returned URL< / th > <tr > <td > http : // hostname / folder < / td > <td > http : // hostname / folder < / td > <tr > <td > http : // hostname / folder / < / td > <td > http : // hostname / folder < / td > < / table > [CODESPLIT] public static URL removeTrailingSlash ( URL url ) { String file = url . getFile ( ) ; if ( file . endsWith ( "/" ) ) { //$NON-NLS-1$ file = file . substring ( 0 , file . length ( ) - 1 ) ; try { return new URL ( url . getProtocol ( ) , url . getHost ( ) , url . getPort ( ) , file ) ; } catch ( MalformedURLException e ) { Assert . isTrue ( false , e . getMessage ( ) ) ; } } else { return url ; } return null ; }


Input: Returns a boolean indicating whether the given URLs overlap . <table > <caption > Example< / caption > <tr > <th > First URL< / th > <th > Second URL< / th > <th > Do they overlap< / th > <tr > <td > http : // hostname / folder / < / td > <td > http : // hostname / folder / < / td > <td > true< / td > <tr > <td > http : // hostname / folder / < / td > <td > http : // hostname / folder / file < / td > <td > true< / td > <tr > <td > http : // hostname / folder / file < / td > <td > http : // hostname / folder / < / td > <td > true< / td > <tr > <td > http : // hostname / folder1 / < / td > <td > http : // hostname / folder2 / < / td > <td > false< / td > < / table > [CODESPLIT] public static boolean urlsOverlap ( String url1 , String url2 ) throws MalformedURLException { return urlsOverlap ( new URL ( url1 ) , new URL ( url2 ) ) ; }


Input: Returns a boolean indicating whether the given URLs overlap . <table > <caption > Example< / caption > <tr > <th > First URL< / th > <th > Second URL< / th > <th > Do they overlap< / th > <tr > <td > http : // hostname / folder / < / td > <td > http : // hostname / folder / < / td > <td > true< / td > <tr > <td > http : // hostname / folder / < / td > <td > http : // hostname / folder / file < / td > <td > true< / td > <tr > <td > http : // hostname / folder / file < / td > <td > http : // hostname / folder / < / td > <td > true< / td > <tr > <td > http : // hostname / folder1 / < / td > <td > http : // hostname / folder2 / < / td > <td > false< / td > <tr > <td > http : // hostname1 / folder / < / td > <td > http : // hostname2 / folder / < / td > <td > false< / td > < / table > [CODESPLIT] public static boolean urlsOverlap ( URL url1 , URL url2 ) { if ( ! getRoot ( url1 ) . equals ( getRoot ( url2 ) ) ) { return false ; } Vector elements1 = URLTool . getElements ( url1 ) ; Vector elements2 = URLTool . getElements ( url2 ) ; for ( int i = 0 ; i < elements1 . size ( ) && i < elements2 . size ( ) ; ++ i ) { String element1 = ( String ) elements1 . elementAt ( i ) ; String element2 = ( String ) elements2 . elementAt ( i ) ; if ( ! element1 . equals ( element2 ) ) { return false ; } } return true ; }


Input: Return a menu which launches the various wizards [CODESPLIT] public Menu getMenu ( Control parent ) { setMenu ( new Menu ( parent ) ) ; final Shell shell = parent . getShell ( ) ; addProjectWizard ( menu , shell ) ; addRuleWizard ( menu , shell ) ; addDSLWizard ( menu , shell ) ; addDTWizard ( menu , shell ) ; return menu ; }


Input: Returns the content length of this message s body or - 1 if the content length is unknown . [CODESPLIT] public long getContentLength ( ) { // Get the declared content length. long contentLength = context . getContentLength ( ) ; // If it is defined send the answer. if ( contentLength != - 1 ) return contentLength ; // Certain messages are defined as having zero length // message bodies. int statusCode = getStatusCode ( ) ; if ( statusCode == IResponse . SC_NO_CONTENT || statusCode == IResponse . SC_NOT_MODIFIED || statusCode >= 100 && statusCode < 200 ) return 0 ; // We don't know how long the body is. return - 1 ; }


Input: Returns the content type of this response s body or <code > null< / code > if the content type is unknown . [CODESPLIT] public ContentType getContentType ( ) { String contentTypeString = context . getContentType ( ) ; if ( contentTypeString == null ) return null ; ContentType contentType = null ; try { contentType = new ContentType ( contentTypeString ) ; } catch ( IllegalArgumentException e ) { // ignore or log? } return contentType ; }


Input: Returns this response s body as a DOM <code > Document< / code > . This response must have a document body . [CODESPLIT] public Document getDocumentBody ( ) throws IOException { Assert . isTrue ( hasDocumentBody ) ; Assert . isTrue ( ! hasInputStream ) ; // Lazily parse the message body. if ( document == null ) { String characterEncoding = null ; ContentType contentType = getContentType ( ) ; if ( contentType != null ) { characterEncoding = contentType . getValue ( "charset" ) ; //$NON-NLS-1$ } if ( characterEncoding == null ) { characterEncoding = "ASCII" ; //$NON-NLS-1$ } IDocumentMarshaler marshaler = new DocumentMarshaler ( ) ; document = marshaler . parse ( new InputStreamReader ( is , characterEncoding ) ) ; } return document ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public String getHtml ( ) { return NODE_NAME + " : " + this . node . getId ( ) + " : " + this . node . getQueryElement ( ) == null ? "" : this . node . getQueryElement ( ) . getQueryName ( ) ; }


Input: Creates and adds a response element to this multistatus and returns an editor on it . [CODESPLIT] public ResponseBody addResponse ( ) { Element response = addChild ( root , "response" , childNames , true ) ; //$NON-NLS-1$ try { return new ResponseBody ( response ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ return null ; // Never reached. } }


Input: Creates a new WebDAV multistatus element and sets it as the root of the given document . Returns an editor on the new multistatus element . <p > The document must not be <code > null< / code > and must not already have a root element . < / p > [CODESPLIT] public static MultiStatus create ( Document document ) { Assert . isNotNull ( document ) ; Assert . isTrue ( document . getOwnerDocument ( ) == null ) ; Element element = create ( document , "multistatus" ) ; //$NON-NLS-1$ try { return new MultiStatus ( element ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ return null ; // Never reached. } }


Input: Returns an <code > Enumeration< / code > over this multistatus responses . [CODESPLIT] public Enumeration getResponses ( ) throws MalformedElementException { final Element firstResponse = getFirstChild ( root , "response" ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingResponseElmt" ) , firstResponse ) ; //$NON-NLS-1$ Enumeration e = new Enumeration ( ) { Element currentResponse = firstResponse ; public boolean hasMoreElements ( ) { return currentResponse != null ; } public Object nextElement ( ) { if ( ! hasMoreElements ( ) ) throw new NoSuchElementException ( ) ; ResponseBody responseBody = null ; try { responseBody = new ResponseBody ( currentResponse ) ; } catch ( MalformedElementException ex ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } currentResponse = getTwin ( currentResponse , true ) ; return responseBody ; } } ; return e ; }


Input: $NON - NLS - 1$ [CODESPLIT] private boolean isGuvnorResource ( Object element ) { if ( element instanceof IResource ) { return GuvnorMetadataUtils . findGuvnorMetadata ( ( IResource ) element ) != null ; } else { return false ; } }


Input: Adds the given href to the end of the set of hrefs . If the href already exists it is not added . [CODESPLIT] public void addHref ( String href ) { String encodedHref = encodeHref ( href ) ; if ( isDuplicate ( encodedHref ) ) return ; appendChild ( root , "href" , encodedHref ) ; //$NON-NLS-1$ }


Input: Creates a new href set element with the given name and sets it as the root of the given document . Returns an editor on the new href set element . The document must not be <code > null< / code > and must not already have a root element . [CODESPLIT] public static HrefSet create ( Document document , QualifiedName name ) { Assert . isNotNull ( document ) ; Assert . isTrue ( document . getOwnerDocument ( ) == null ) ; Assert . isNotNull ( name ) ; Assert . isTrue ( DAV_NS . equals ( name . getQualifier ( ) ) ) ; Element element = create ( document , name . getLocalName ( ) ) ; try { return new HrefSet ( element , name ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ return null ; // Never reached. } }


Input: Returns an <code > Enumeration< / code > over the set of hrefs . [CODESPLIT] public Enumeration getHrefs ( ) { final Element firstHref = getFirstChild ( root , "href" ) ; //$NON-NLS-1$ Enumeration e = new Enumeration ( ) { Element currentHref = firstHref ; public boolean hasMoreElements ( ) { return currentHref != null ; } public Object nextElement ( ) { if ( ! hasMoreElements ( ) ) throw new NoSuchElementException ( ) ; String href = getFirstText ( currentHref ) ; currentHref = getNextSibling ( currentHref , "href" ) ; //$NON-NLS-1$ return decodeHref ( href ) ; } } ; return e ; }


Input: Inserts the given newHref before the given refHref in the set of hrefs . If newHref already exists it is not inserted . [CODESPLIT] public void insertHrefBefore ( String newHref , String refHref ) { String refHrefEncoded = encodeHref ( refHref ) ; String newHrefEncoded = encodeHref ( newHref ) ; if ( isDuplicate ( newHrefEncoded ) ) return ; Element child = getFirstChild ( root , "href" ) ; //$NON-NLS-1$ while ( child != null ) { if ( refHrefEncoded . equals ( getFirstText ( child ) ) ) { insertBefore ( child , "href" , newHrefEncoded ) ; //$NON-NLS-1$ return ; } child = getNextSibling ( child , "href" ) ; //$NON-NLS-1$ } Assert . isTrue ( false , Policy . bind ( "assert.noHrefRef" ) ) ; //$NON-NLS-1$ }


Input: Remove the given href from the set of hrefs . [CODESPLIT] public void removeHref ( String href ) { String encodedHref = encodeHref ( href ) ; Element child = getFirstChild ( root , "href" ) ; //$NON-NLS-1$ while ( child != null ) { if ( encodedHref . equals ( getFirstText ( child ) ) ) { root . removeChild ( child ) ; return ; } child = getNextSibling ( child , "href" ) ; //$NON-NLS-1$ } }


Input: Gets this response s first propstat with the given status and adds an element created from the given property name as a property of the propstat s prop . If such a propstat does not exists it is created . The propstat s response description is set to the given response description or removed if the response description is <code > null< / code > . Returns the propstat . The property name must not be <code > null< / code > and its qualifier and local part must not be <code > null< / code > and must not be the empty string . The status must not be <code > null< / code > . This response must not already be in the status form . [CODESPLIT] public PropStat accumulatePropStat ( QualifiedName propertyName , String status , String responseDescription ) { Assert . isNotNull ( propertyName ) ; Assert . isNotNull ( status ) ; Element child = getFirstChild ( root , new String [ ] { "href" , "status" } ) ; //$NON-NLS-1$ //$NON-NLS-2$ Assert . isTrue ( child == null || isDAVElement ( child , "href" ) //$NON-NLS-1$ && getNextSibling ( child , new String [ ] { "href" , "status" } ) == null ) ; //$NON-NLS-1$ //$NON-NLS-2$ String nsName = propertyName . getQualifier ( ) ; Assert . isTrue ( ! "" . equals ( nsName ) ) ; //$NON-NLS-1$ String localName = propertyName . getLocalName ( ) ; Assert . isNotNull ( localName ) ; Assert . isTrue ( ! localName . equals ( "" ) ) ; //$NON-NLS-1$ Document document = root . getOwnerDocument ( ) ; Element element = document . createElement ( localName ) ; declareNS ( element , null , nsName ) ; try { return accumulatePropStat ( element , status , responseDescription ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ return null ; // Never reached. } }


Input: Gets this response s first propstat with the given status and adds a clone of the given element as a property of its prop . If such a propstat does not exists it is created . The propstat s response description is set to the given response description or removed if the response description is <code > null< / code > . Returns the propstat . The element and status must not be <code > null< / code > . This response must not already be in the status form . [CODESPLIT] public PropStat accumulatePropStat ( Element element , String status , String responseDescription ) throws MalformedElementException { Assert . isNotNull ( element ) ; Assert . isNotNull ( status ) ; Element child = getFirstChild ( root , new String [ ] { "href" , "status" } ) ; //$NON-NLS-1$ //$NON-NLS-2$ Assert . isTrue ( child == null || isDAVElement ( child , "href" ) //$NON-NLS-1$ && getNextSibling ( child , new String [ ] { "href" , "status" } ) == null ) ; //$NON-NLS-1$ //$NON-NLS-2$ boolean found = false ; Element propstat = getFirstChild ( root , "propstat" ) ; //$NON-NLS-1$ while ( ! found && propstat != null ) { String text = getChildText ( propstat , "status" , false ) ; //$NON-NLS-1$ if ( text != null && text . equals ( status ) ) found = true ; else propstat = getTwin ( propstat , true ) ; } Element prop = null ; if ( propstat == null ) { propstat = addChild ( root , "propstat" , fgNamesPropStat , false ) ; //$NON-NLS-1$ prop = setChild ( propstat , "prop" , PropStat . childNames , true ) ; //$NON-NLS-1$ setChild ( propstat , "status" , status , PropStat . childNames , false ) ; //$NON-NLS-1$ } else { prop = getFirstChild ( propstat , "prop" ) ; //$NON-NLS-1$ if ( prop == null ) prop = setChild ( propstat , "prop" , PropStat . childNames , true ) ; //$NON-NLS-1$ } if ( responseDescription == null ) { Element responsedescription = getLastChild ( propstat , "responsedescription" ) ; //$NON-NLS-1$ if ( responsedescription != null ) propstat . removeChild ( responsedescription ) ; } else setChild ( propstat , "responsedescription" , //$NON-NLS-1$ responseDescription , PropStat . childNames , false ) ; extractNode ( prop , element ) ; try { return new PropStat ( propstat ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ return null ; // Never reached. } }


Input: Adds the given href to this response . If <code > setHref ( String ) < / code > hasn t been called and no hrefs have been added this method sets the first href and is thus equivalent to <code > setHref ( String ) < / code > . The href must not be <code > null< / code > . This response must not already be in propstat form . [CODESPLIT] public void addHref ( String href ) { Assert . isNotNull ( href ) ; Assert . isTrue ( getLastChild ( root , "propstat" ) == null ) ; //$NON-NLS-1$ addChild ( root , "href" , encodeHref ( href ) , fgNamesStatus , false ) ; //$NON-NLS-1$ }


Input: Creates and adds a propstat element on this response and returns an editor on it . [CODESPLIT] public PropStat addPropStat ( ) { Element firstHref = getFirstChild ( root , "href" ) ; //$NON-NLS-1$ Assert . isTrue ( firstHref == null || getNextSibling ( firstHref , new String [ ] { "href" , "status" } ) == null ) ; //$NON-NLS-1$ //$NON-NLS-2$ Element element = addChild ( root , "propstat" , fgNamesPropStat , false ) ; //$NON-NLS-1$ try { return new PropStat ( element ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ return null ; // Never reached. } }


Input: Changes all of this response s propstats with the given old status to have the given new status . In addition their response descriptions are changed to be the given response description or removed if the given response description is <code > null< / code > . The old status and new status must not be <code > null< / null > . This response must not be in the status form . [CODESPLIT] public void changePropStatStatus ( String oldStatus , String newStatus , String responseDescription ) { Assert . isNotNull ( oldStatus ) ; Assert . isNotNull ( newStatus ) ; Element firstHref = getFirstChild ( root , "href" ) ; //$NON-NLS-1$ Assert . isTrue ( firstHref == null || getNextSibling ( firstHref , new String [ ] { "href" , "status" } ) == null ) ; //$NON-NLS-1$ //$NON-NLS-2$ Element propstat = getFirstChild ( root , "propstat" ) ; //$NON-NLS-1$ while ( propstat != null ) { String status = getChildText ( propstat , "status" , true ) ; //$NON-NLS-1$ if ( oldStatus . equals ( status ) ) { setChild ( propstat , "status" , newStatus , PropStat . childNames , true ) ; //$NON-NLS-1$ if ( responseDescription == null ) { Element responsedescription = getLastChild ( propstat , "responsedescription" ) ; //$NON-NLS-1$ if ( responsedescription != null ) propstat . removeChild ( responsedescription ) ; } else setChild ( propstat , "responsedescription" , //$NON-NLS-1$ responseDescription , PropStat . childNames , false ) ; } propstat = getTwin ( propstat , true ) ; } }


Input: Returns this response s first href . [CODESPLIT] public String getHref ( ) throws MalformedElementException { String href = getChildText ( root , "href" , true ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingHrefElmt" ) , href ) ; //$NON-NLS-1$ return decodeHref ( href ) ; }


Input: Returns an <code > Enumeration< / code > of this response s hrefs ( not including the first href ) . [CODESPLIT] public Enumeration getHrefs ( ) throws MalformedElementException { final Node firstHref = getFirstChild ( root , "href" ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingHrefElmt" ) , firstHref ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingStatusElmt" ) , //$NON-NLS-1$ getNextSibling ( ( Element ) firstHref , "status" ) ) ; //$NON-NLS-1$ Enumeration e = new Enumeration ( ) { Node currentHref = getTwin ( ( Element ) firstHref , true ) ; public boolean hasMoreElements ( ) { return currentHref != null ; } public Object nextElement ( ) { if ( ! hasMoreElements ( ) ) throw new NoSuchElementException ( ) ; String href = getFirstText ( ( Element ) currentHref ) ; currentHref = getTwin ( ( Element ) currentHref , true ) ; return decodeHref ( href ) ; } } ; return e ; }


Input: Returns an <code > Enumeration< / code > of this response s <code > Propstat< / code > s . [CODESPLIT] public Enumeration getPropStats ( ) throws MalformedElementException { final Element firstPropStat = getFirstChild ( root , "propstat" ) ; //$NON-NLS-1$ ensureNotNull ( "ensure.missingPropstatElmt" , firstPropStat ) ; //$NON-NLS-1$ Enumeration e = new Enumeration ( ) { Element currentPropStat = firstPropStat ; public boolean hasMoreElements ( ) { return currentPropStat != null ; } public Object nextElement ( ) { if ( ! hasMoreElements ( ) ) throw new NoSuchElementException ( ) ; PropStat result = null ; try { result = new PropStat ( currentPropStat ) ; } catch ( MalformedElementException ex ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; //$NON-NLS-1$ } currentPropStat = getTwin ( currentPropStat , true ) ; return result ; } } ; return e ; }


Input: Returns this response s status . [CODESPLIT] public String getStatus ( ) throws MalformedElementException { Element status = getFirstChild ( root , "status" ) ; //$NON-NLS-1$ ensureNotNull ( Policy . bind ( "ensure.missingStatusElmt" ) , status ) ; //$NON-NLS-1$ return getFirstText ( status ) ; }


Input: Returns <code > true< / code > if this response is in propstat form and <code > false< / code > if it is in status form . [CODESPLIT] public boolean isPropStat ( ) throws MalformedElementException { Element child = getFirstChild ( root , new String [ ] { "status" , "propstat" } ) ; //$NON-NLS-1$ //$NON-NLS-2$ ensureNotNull ( Policy . bind ( "ensure.missingStatusOrPropstatElmt" ) , child ) ; //$NON-NLS-1$ boolean isPropStat = isDAVElement ( child , "propstat" ) ; //$NON-NLS-1$ if ( isPropStat ) child = getNextSibling ( child , "status" ) ; //$NON-NLS-1$ else child = getNextSibling ( child , "propstat" ) ; //$NON-NLS-1$ ensureNull ( Policy . bind ( "ensure.conflictingStatusOrPropstatElmt" ) , child ) ; //$NON-NLS-1$ return isPropStat ; }


Input: Sets this response s response description to the given value . If the value is <code > null< / code > and a response description has already been set it is removed . [CODESPLIT] public void setResponseDescription ( Element value ) { Element child = getLastChild ( root , "responsedescription" ) ; //$NON-NLS-1$ if ( child != null ) root . removeChild ( child ) ; if ( value == null ) { child = setChild ( root , "responsedescription" , childNames , false ) ; //$NON-NLS-1$ child . appendChild ( value ) ; } }


Input: Sets the status on this response to the given status . The status must not be <code > null< / code > . This response must not already be in the propstat form . [CODESPLIT] public void setStatus ( String status ) { Assert . isNotNull ( status ) ; Assert . isTrue ( getLastChild ( root , "propstat" ) == null ) ; //$NON-NLS-1$ setChild ( root , "status" , status , fgNamesStatus , true ) ; //$NON-NLS-1$ }


Input: Appends a new member to the end of this object with the specified name and the JSON representation of the specified string . <p > This method <strong > does not prevent duplicate names< / strong > . Calling this method with a name that already exists in the object will append another member with the same name . In order to replace existing members use the method <code > set ( name value ) < / code > instead . However <strong > <em > add< / em > is much faster than <em > set< / em > < / strong > ( because it does not need to search for existing members ) . Therefore <em > add< / em > should be preferred when constructing new objects . < / p > [CODESPLIT] public JsonObject add ( String name , String value ) { add ( name , valueOf ( value ) ) ; return this ; }


Input: Sets the value of the member with the specified name to the JSON representation of the specified string . If this object does not contain a member with this name a new member is added at the end of the object . If this object contains multiple members with this name only the last one is changed . <p > This method should <strong > only be used to modify existing objects< / strong > . To fill a new object with members the method <code > add ( name value ) < / code > should be preferred which is much faster ( as it does not need to search for existing members ) . < / p > [CODESPLIT] public JsonObject set ( String name , String value ) { set ( name , valueOf ( value ) ) ; return this ; }


Input: Returns the Basic authorization credentials for the given username and password . The credentials have the following form : <code > credentials = Basic basic - credentials basic - credentials = base64 - user - pass base64 - user - pass = &lt ; base64 encoding of user - pass except not limited to 76 char / line&gt ; user - pass = userid : password userid = * &lt ; TEXT excluding : &gt ; password = * TEXT < / code > <P > Userids might be case sensitive . <P > For example if the user s name is Aladdin and the user s password is open sesame the following credentials are supplied : <code > Basic QWxhZGRpbjpvcGVuIHN1c2FtZQ == < / code > [CODESPLIT] private String credentials ( String username , String password ) { Assert . isNotNull ( username ) ; Assert . isNotNull ( password ) ; String userpass = username + ":" + password ; //$NON-NLS-1$ byte [ ] data = null ; try { data = userpass . getBytes ( "UTF8" ) ; //$NON-NLS-1$ } catch ( UnsupportedEncodingException e ) { data = userpass . getBytes ( ) ; } return "Basic " + Base64Encoder . encode ( data ) ; //$NON-NLS-1$ }


Input: Report a property change to registered listeners ( for example edit parts ) . [CODESPLIT] protected void firePropertyChange ( String property , Object oldValue , Object newValue ) { if ( pcsDelegate . hasListeners ( property ) ) { pcsDelegate . firePropertyChange ( property , oldValue , newValue ) ; } }


Input: Return the current stack frame context or a valid stack frame for the given value . [CODESPLIT] public static IJavaStackFrame getStackFrame ( IValue value ) throws CoreException { IStatusHandler handler = getStackFrameProvider ( ) ; if ( handler != null ) { IJavaStackFrame stackFrame = ( IJavaStackFrame ) handler . handleStatus ( fgNeedStackFrame , value ) ; if ( stackFrame != null ) { return stackFrame ; } } IDebugTarget target = value . getDebugTarget ( ) ; IJavaDebugTarget javaTarget = ( IJavaDebugTarget ) target . getAdapter ( IJavaDebugTarget . class ) ; if ( javaTarget != null ) { IThread [ ] threads = javaTarget . getThreads ( ) ; for ( int i = 0 ; i < threads . length ; i ++ ) { IThread thread = threads [ i ] ; if ( thread . isSuspended ( ) ) { return ( IJavaStackFrame ) thread . getTopStackFrame ( ) ; } } } return null ; }


Input: Returns true if the first class is the same or a subtype of the second class . [CODESPLIT] private boolean isSubtypeOf ( String class1 , String class2 ) { if ( class1 == null || class2 == null ) { return false ; } class1 = convertToNonPrimitiveClass ( class1 ) ; class2 = convertToNonPrimitiveClass ( class2 ) ; // TODO add code to take primitive types into account ClassTypeResolver resolver = new ClassTypeResolver ( getUniqueImports ( ) , ProjectClassLoader . getProjectClassLoader ( getEditor ( ) ) ) ; try { Class < ? > clazz1 = resolver . resolveType ( class1 ) ; Class < ? > clazz2 = resolver . resolveType ( class2 ) ; if ( clazz1 == null || clazz2 == null ) { return false ; } return clazz2 . isAssignableFrom ( clazz1 ) ; } catch ( ClassNotFoundException exc ) { return false ; } }


Input: / * Completions for object instance members [CODESPLIT] private Collection < ICompletionProposal > getMvelInstanceCompletionsFromJDT ( final int documentOffset , final String prefix , Map < String , String > params , Class < ? > lastType , boolean settersOnly ) { if ( lastType == null ) { lastType = Object . class ; } //FIXME: there is a small chance of var name collision using this arbitrary mvdrlofc as a variable name. //ideally the variable name should be inferred from the last member of the expression final String syntheticVarName = "mvdrlofc" ; String javaText = "\n" + lastType . getPackage ( ) . getName ( ) + "." + CompletionUtil . getSimpleClassName ( lastType ) + " " + syntheticVarName + ";\n" + syntheticVarName + "." ; final List < ICompletionProposal > list1 = new ArrayList < ICompletionProposal > ( ) ; requestJavaCompletionProposals ( javaText , prefix , documentOffset , params , list1 ) ; final List < ICompletionProposal > list = list1 ; Collection < ICompletionProposal > mvelList = RuleCompletionProcessor . mvelifyProposals ( list , settersOnly ) ; return mvelList ; }


Input: / * Completions for static Class members [CODESPLIT] private Collection < ICompletionProposal > getMvelClassCompletionsFromJDT ( final int documentOffset , final String prefix , Map < String , String > params , Class < ? > lastType ) { if ( lastType == null ) { lastType = Object . class ; } //FIXME: there is a small chance of var name collision using this arbitrary mvdrlofc as a variable name. //ideally the variable name should be inferred from the last member of the expression String javaText = "\n" + CompletionUtil . getSimpleClassName ( lastType ) + "." ; final List < ICompletionProposal > list1 = new ArrayList < ICompletionProposal > ( ) ; requestJavaCompletionProposals ( javaText , prefix , documentOffset , params , list1 ) ; final List < ICompletionProposal > list = list1 ; Collection < ICompletionProposal > mvelList = RuleCompletionProcessor . mvelifyProposals ( list , false ) ; return mvelList ; }


Input: Attempt to compare proposals of different types based on the tokenized display string [CODESPLIT] public static boolean containsProposal ( final Collection < ICompletionProposal > proposals , String newProposal ) { for ( ICompletionProposal prop : proposals ) { String displayString = prop . getDisplayString ( ) ; String [ ] existings = displayString . split ( " " ) ; if ( existings . length == 0 ) { continue ; } String [ ] newProposals = newProposal . split ( " " ) ; if ( newProposals . length == 0 ) { continue ; } if ( existings [ 0 ] . equals ( newProposals [ 0 ] ) ) { return true ; } } return false ; }


Input: / * Filters accessor method proposals to replace them with their mvel expression equivalent For instance a completion for getStatus () would be replaced by a completion for status when asking for stters only then only setters or writable fields will be returned [CODESPLIT] public static Collection < ICompletionProposal > mvelifyProposals ( List < ICompletionProposal > list , boolean settersOnly ) { final Collection < ICompletionProposal > set = new HashSet < ICompletionProposal > ( ) ; for ( ICompletionProposal o : list ) { if ( o instanceof JavaMethodCompletionProposal ) { //methods processJavaMethodCompletionProposal ( list , settersOnly , set , o ) ; } else if ( o instanceof JavaCompletionProposal ) { //fields processesJavaCompletionProposal ( settersOnly , set , o ) ; } else if ( ! settersOnly ) { set . add ( o ) ; } } return set ; }


Input: Creates a WebDAV element with the given name and appends it as a child of the given parent . Returns the child element . The parent must not be <code > null< / code > and must be a WebDAV element . The name of the child must not be <code > null< / code > . [CODESPLIT] public static Element appendChild ( Element parent , String name ) { Assert . isTrue ( isDAVElement ( parent ) ) ; Assert . isNotNull ( name ) ; String nsPrefix = getNSPrefix ( parent ) ; String tagName = nsPrefix == null ? name : nsPrefix + ":" + name ; //$NON-NLS-1$ Element child = parent . getOwnerDocument ( ) . createElement ( tagName ) ; parent . appendChild ( child ) ; return child ; }


Input: Creates a WebDAV element with the given name and appends it as a child of the given parent . In addition a text node created from the given data is created and appended to the child . Returns the child element . The parent must not be <code > null< / code > and must be a WebDAV element . The name of the child must not be <code > null< / code > . The data must not be <code > null< / code > . [CODESPLIT] public static Element appendChild ( Element parent , String name , String data ) { Assert . isTrue ( isDAVElement ( parent ) ) ; Assert . isNotNull ( name ) ; Assert . isNotNull ( data ) ; Element child = appendChild ( parent , name ) ; child . appendChild ( child . getOwnerDocument ( ) . createTextNode ( data ) ) ; return child ; }


Input: Returns a clone of the given node . The given document becomes the owner document of the clone . [CODESPLIT] public static Node cloneNode ( Document document , Node node ) { Node nodeClone = null ; switch ( node . getNodeType ( ) ) { case Node . ELEMENT_NODE : { nodeClone = document . createElement ( ( ( Element ) node ) . getTagName ( ) ) ; NamedNodeMap namedNodeMap = node . getAttributes ( ) ; for ( int i = 0 ; i < namedNodeMap . getLength ( ) ; ++ i ) { Attr attr = ( Attr ) namedNodeMap . item ( i ) ; Attr attrClone = document . createAttribute ( attr . getName ( ) ) ; attrClone . setValue ( attr . getValue ( ) ) ; ( ( Element ) nodeClone ) . setAttributeNode ( attrClone ) ; } } break ; case Node . TEXT_NODE : nodeClone = document . createTextNode ( ( ( CharacterData ) node ) . getData ( ) ) ; break ; case Node . CDATA_SECTION_NODE : nodeClone = document . createCDATASection ( ( ( CharacterData ) node ) . getData ( ) ) ; break ; case Node . ENTITY_REFERENCE_NODE : nodeClone = document . createEntityReference ( node . getNodeName ( ) ) ; break ; case Node . PROCESSING_INSTRUCTION_NODE : nodeClone = document . createProcessingInstruction ( ( ( ProcessingInstruction ) node ) . getTarget ( ) , ( ( ProcessingInstruction ) node ) . getData ( ) ) ; break ; case Node . COMMENT_NODE : nodeClone = document . createComment ( ( ( CharacterData ) node ) . getData ( ) ) ; break ; case Node . DOCUMENT_FRAGMENT_NODE : nodeClone = document . createDocumentFragment ( ) ; break ; case Node . DOCUMENT_NODE : case Node . DOCUMENT_TYPE_NODE : case Node . NOTATION_NODE : case Node . ATTRIBUTE_NODE : case Node . ENTITY_NODE : Assert . isTrue ( false , Policy . bind ( "assert.notSupported" ) ) ; //$NON-NLS-1$ break ; default : Assert . isTrue ( false , Policy . bind ( "assert.unknownNodeType" ) ) ; //$NON-NLS-1$ } return nodeClone ; }


Input: Creates a WebDAV element with the given name and adds it as the root of the given document . In addition the WebDAV namespace is declared on the new element . Returns the new element . The document must not be <code > null< / code > and must not already have a root element . The name of the element to be created must not be <code > null< / code > . [CODESPLIT] public static Element create ( Document document , String name ) { Assert . isNotNull ( document ) ; Assert . isTrue ( document . getDocumentElement ( ) == null ) ; Assert . isNotNull ( name ) ; Element element = document . createElement ( name ) ; declareNS ( element , null , DAV_NS ) ; document . appendChild ( element ) ; return element ; }


Input: Adds a namespace declaration to the given element . If only the prefix is <code > null< / code > a default namespace is declared . If the prefix and the namespaceUrl are <code > null< / code > the default namespace is removed . The element must not be <code > null< / code > . If the namespaceUrl is <code > null< / code > the <code > prefix< / code > must also be <code > null< / code > . [CODESPLIT] public static void declareNS ( Element element , String prefix , String namespaceUrl ) { Assert . isNotNull ( element ) ; Assert . isTrue ( namespaceUrl != null || prefix == null && namespaceUrl == null ) ; String name = XML_PREFIX + ( prefix == null ? "" : ":" + prefix ) ; //$NON-NLS-1$ //$NON-NLS-2$ String value = namespaceUrl == null ? "" : namespaceUrl ; //$NON-NLS-1$ element . setAttribute ( name , value ) ; }


Input: Ensures that the given node is a WebDAV element with the given name returning it as an <code > Element< / code > if it is . [CODESPLIT] protected static Element ensureDAVElement ( String message , Node node , String name ) throws MalformedElementException { Assert . isNotNull ( name ) ; if ( node == null || node . getNodeType ( ) != Node . ELEMENT_NODE ) throw new MalformedElementException ( message ) ; Element element = ( Element ) node ; if ( ! name . equals ( getNSLocalName ( element ) ) || ! DAV_NS . equals ( getNSName ( element ) ) ) throw new MalformedElementException ( message ) ; return element ; }


Input: Ensures that the given object is not <code > null< / code > . [CODESPLIT] protected static void ensureNotNull ( String message , Object object ) throws MalformedElementException { if ( object == null ) throw new MalformedElementException ( message ) ; }


Input: Ensures that the given object is <code > null< / code > . [CODESPLIT] protected static void ensureNull ( String message , Object object ) throws MalformedElementException { if ( object != null ) throw new MalformedElementException ( message ) ; }


Input: Ensures that the given node is a text node returning it as a <code > Text< / code > node if it is . [CODESPLIT] protected static Text ensureText ( String message , Node node ) throws MalformedElementException { if ( node == null || node . getNodeType ( ) != Node . TEXT_NODE ) throw new MalformedElementException ( message ) ; return ( Text ) node ; }


Input: Clones the given element and its subtrees and sets it as the root of the given document . Returns the cloned element . The document must not have a root and must not be <code > null< / code > . The element must not be <code > null< / code > . [CODESPLIT] public static Element extractElement ( Document document , Element element ) throws MalformedElementException { Assert . isNotNull ( document ) ; Assert . isTrue ( document . getDocumentElement ( ) == null ) ; Assert . isNotNull ( element ) ; return ( Element ) extractNode ( document , element ) ; }


Input: Clones the given node and its subtrees and sets it as the root of the given parent node . Returns the cloned node . The parent node and the node to be cloned must not be <code > null< / code > . [CODESPLIT] public static Node extractNode ( Node parent , Node node ) throws MalformedElementException { // Get a handle to the root of the parent node tree. Document document ; if ( parent . getNodeType ( ) == Node . DOCUMENT_NODE ) document = ( Document ) parent ; else document = parent . getOwnerDocument ( ) ; // Create a clone of the node owned by the document, and add to the parent. Node nodeClone = cloneNode ( document , node ) ; parent . appendChild ( nodeClone ) ; // If the node is an Element if ( node . getNodeType ( ) == Node . ELEMENT_NODE ) { // Figure out its namespace information. String nsPrefix = getNSPrefix ( ( Element ) node ) ; String nsName = getNSName ( ( Element ) node ) ; // Is this namespace already defined on the clone?  If not declare it. String nsNameClone = resolve ( nsPrefix , ( Element ) nodeClone ) ; if ( nsName != nsNameClone && ( nsName == null || ! nsName . equals ( nsNameClone ) ) ) declareNS ( ( Element ) nodeClone , nsPrefix , nsName ) ; // Do the same namespace fix-up for each of the node's attributes. NamedNodeMap nodeMap = nodeClone . getAttributes ( ) ; for ( int i = 0 ; i < nodeMap . getLength ( ) ; ++ i ) { Attr attr = ( Attr ) nodeMap . item ( i ) ; nsPrefix = getNSPrefix ( attr . getName ( ) ) ; if ( nsPrefix != null && ! nsPrefix . equals ( XML_PREFIX ) ) { nsName = resolve ( nsPrefix , ( Element ) node ) ; nsNameClone = resolve ( nsPrefix , ( Element ) nodeClone ) ; if ( nsName != nsNameClone && ( nsName == null || ! nsName . equals ( nsNameClone ) ) ) declareNS ( ( Element ) nodeClone , nsPrefix , nsName ) ; } } } // Recursively clone each of the node's children. Node child = node . getFirstChild ( ) ; while ( child != null ) { extractNode ( nodeClone , child ) ; child = child . getNextSibling ( ) ; } // Finished cloning this node. return nodeClone ; }


Input: Returns the first child of the given parent that is a WebDAV element with one of the given names or <code > null< / code > if no such child exists . <p > If firstToLast is true the search for the child starts at the parent s first child otherwise the search starts at the parent s last child . The parent must not be <code > null< / code > and must be a WebDAV element . The names of children to search for must not be <code > null< / code > . < / p > [CODESPLIT] private static Element getChild ( Element parent , String [ ] names , boolean firstToLast ) { Assert . isTrue ( isDAVElement ( parent ) ) ; Assert . isNotNull ( names ) ; // Get the first candidate. Node child = null ; if ( firstToLast ) child = parent . getFirstChild ( ) ; else child = parent . getLastChild ( ) ; // While there are children left to consider. while ( child != null ) { // See if the child name matches any being sought. for ( int i = 0 ; i < names . length ; ++ i ) if ( isDAVElement ( child , names [ i ] ) ) return ( Element ) child ; // Try the next child. if ( firstToLast ) child = child . getNextSibling ( ) ; else child = child . getPreviousSibling ( ) ; } // A matching child was not found. return null ; }


Input: <p > Returns the child WebDAV element of the given parent that is nearest in position to a WebDAV element with the given name or <code > null< / code > if no such child exists . <p > Children are expected to be in the order specified by the given names . If firstToLast is true the search for the child starts at the parent s first child otherwise the search starts at the parent s last child . <p > The parent must not be <code > null< / code > and must be a WebDAV element . The name of the child to search for must not be <code > null< / code > . The parent s valid child names must not be <code > null< / code > and must contain the name of the child being searched for . <p > The returned child is as follows : <ul > <li > Searching first to last< / li > <ul > <li > returns <code > null< / code > if an element with the given name should appear as the last child< / li > <li > returns the first occurring child if an element with the given name is a child< / li > <li > returns a child if an element with the given name would appear before it< / li > < / ul > <li > Searching last to first< / li > <ul > <li > returns <code > null< / code > if an element with the given name would appear as the first child< / li > <li > returns the last occurring child if an element with the given name is a child< / li > <li > returns a child if an element with the given name would appear after it< / li > < / ul > < / ul > [CODESPLIT] public static Element getChild ( Element parent , String name , String [ ] names , boolean firstToLast ) { Assert . isNotNull ( parent ) ; Assert . isNotNull ( name ) ; Assert . isNotNull ( names ) ; boolean found = false ; for ( int i = 0 ; ! found && i < names . length ; ++ i ) { found = names [ i ] . equals ( name ) ; } Assert . isTrue ( found ) ; int i ; Node child = null ; if ( firstToLast ) { i = 0 ; child = parent . getFirstChild ( ) ; } else { i = names . length - 1 ; child = parent . getLastChild ( ) ; } while ( child != null && ! names [ i ] . equals ( name ) ) { int mark = i ; while ( ! isDAVElement ( child , names [ i ] ) && ! names [ i ] . equals ( name ) ) { if ( firstToLast ) { ++ i ; } else { -- i ; } } if ( ! names [ i ] . equals ( name ) ) { if ( firstToLast ) { child = child . getNextSibling ( ) ; } else { child = child . getPreviousSibling ( ) ; } } else if ( ! isDAVElement ( child , names [ i ] ) ) { int pos = i ; found = false ; while ( ! found && ( pos >= 0 && pos < names . length ) ) { found = isDAVElement ( child , names [ pos ] ) ; if ( firstToLast ) { ++ pos ; } else { -- pos ; } } if ( ! found ) { i = mark ; if ( firstToLast ) { child = child . getNextSibling ( ) ; } else { child = child . getPreviousSibling ( ) ; } } } } return ( Element ) child ; }


Input: Returns the first child element of the given parent element or <code > null< / code > if no such child exists . If firstToLast is true the search for the child starts at the parent s first child otherwise the search starts at the parent s last child . The parent must not be <code > null< / code > . [CODESPLIT] public static Element getChildElement ( Element parent , boolean firstToLast ) { Assert . isNotNull ( parent ) ; Node child = null ; if ( firstToLast ) child = parent . getFirstChild ( ) ; else child = parent . getLastChild ( ) ; while ( child != null && ! isElement ( child ) ) { if ( firstToLast ) child = child . getNextSibling ( ) ; else child = child . getPreviousSibling ( ) ; } return ( Element ) child ; }


Input: Returns the data of the first child text node of the first WebDAV child with the given name of the given parent or the empty <code > String< / code > if no such child text node exists or <code > null< / code > if no such child exists . If firstToLast is true the search for the child starts at the parent s first child otherwise the search starts at the parent s last child . The parent must not be <code > null< / code > and must be a WebDAV element . The name of the child must not be <code > null< / code > . [CODESPLIT] public static String getChildText ( Element parent , String name , boolean firstToLast ) { Assert . isTrue ( isDAVElement ( parent ) ) ; Assert . isNotNull ( name ) ; Element child ; if ( firstToLast ) child = getFirstChild ( parent , name ) ; else child = getLastChild ( parent , name ) ; if ( child != null ) return getText ( child , firstToLast ) ; return null ; }


Input: Returns the first WebDAV child of the given parent or <code > null< / code > if no such child exists . The parent must not be <code > null< / code > and must be a WebDAV element . [CODESPLIT] public static Element getDAVChild ( Element parent ) { Assert . isTrue ( isDAVElement ( parent ) ) ; Node child = parent . getFirstChild ( ) ; while ( child != null && ! isDAVElement ( child ) ) child = child . getNextSibling ( ) ; return ( Element ) child ; }


Input: Returns the first child of the given parent that is a WebDAV element with one of the given names or <code > null< / code > if no such child exists . <p > The search for the child starts at the parent s first child . The parent must not be <code > null< / code > and must be a WebDAV element . The names of children to search for must not be <code > null< / code > . < / p > [CODESPLIT] public static Element getFirstChild ( Element parent , String [ ] names ) { return getChild ( parent , names , true ) ; }


Input: Returns the first child of the given parent that is a WebDAV element with the given name or <code > null< / code > if no such child exists . <p > The search for the child starts at the parent s first child . The parent must not be <code > null< / code > and must be a DAV : namespace element . The name of the child to search for must not be <code > null< / code > . [CODESPLIT] public static Element getFirstChild ( Element parent , String name ) { Assert . isNotNull ( name ) ; return getChild ( parent , new String [ ] { name } , true ) ; }


Input: Returns the data of the given parent s first text node or the empty <code > String< / code > if no such text node exists . The search for the text node starts at the parent s first child . The parent must not be <code > null< / code > . [CODESPLIT] public static String getFirstText ( Element parent ) { Assert . isNotNull ( parent ) ; Node child = parent . getFirstChild ( ) ; while ( child != null && ! isText ( child ) ) child = child . getNextSibling ( ) ; if ( child == null ) return "" ; //$NON-NLS-1$ return ( ( Text ) child ) . getData ( ) ; }


Input: Returns the last child of the given parent that is a WebDAV element with the given name or <code > null< / code > if no such child exists . <p > The search starts at the parent s last child . The parent must not be <code > null< / code > and must be a DAV : namespace element . The name of the child to search for must not be <code > null< / code > . [CODESPLIT] public static Element getLastChild ( Element parent , String name ) { Assert . isNotNull ( name ) ; return getChild ( parent , new String [ ] { name } , false ) ; }


Input: Returns the given element s namespace declarations . The element must not be <code > null< / code > . [CODESPLIT] public static Namespaces getNamespaces ( Element element ) { Assert . isNotNull ( element ) ; Node parent = element . getParentNode ( ) ; while ( parent != null && ! isElement ( parent ) ) parent = parent . getParentNode ( ) ; Namespaces namespaces = null ; if ( parent != null ) namespaces = getNamespaces ( ( Element ) parent ) ; return getNamespaces ( element , namespaces , false ) ; }


Input: Returns the given element s namespace declarations . The given namespace declarations should be the element s parent s or <code > null< / code > if the element has no parent . If removeDuplicateNSDeclarations is <code > true< / code > duplicate namespace declarations are removed from the element s attributes . The element must not be <code > null< / code > . [CODESPLIT] protected static Namespaces getNamespaces ( Element element , Namespaces namespaces , boolean removeDuplicateNSDeclarations ) { // Create a container to hold the new namespace definitions. Namespaces newNamespaces = null ; if ( namespaces == null ) newNamespaces = new Namespaces ( ) ; else newNamespaces = new Namespaces ( namespaces ) ; Vector oldAttributes = new Vector ( ) ; // For each attribute on the given element. NamedNodeMap nodeMap = element . getAttributes ( ) ; for ( int i = 0 ; i < nodeMap . getLength ( ) ; ++ i ) { Attr attr = ( Attr ) nodeMap . item ( i ) ; // Is it a name space declaration? String name = attr . getName ( ) ; if ( name . startsWith ( XML_PREFIX ) ) { String nsName = attr . getValue ( ) ; // Is it setting or clearing the default namespace? // (i.e. has no prefix part) if ( name . length ( ) == XML_PREFIX . length ( ) ) { if ( nsName . equals ( "" ) ) //$NON-NLS-1$ newNamespaces . setDefaultNSName ( null ) ; else newNamespaces . setDefaultNSName ( nsName ) ; } else if ( name . charAt ( XML_PREFIX . length ( ) ) == ' ' ) { // It is a namespace declaration. String nsPrefix = name . substring ( XML_PREFIX . length ( ) + 1 ) ; if ( nsPrefix . length ( ) > 0 && nsName . length ( ) > 0 ) { // Ensure it is in the new namespaces list. newNamespaces . putNSName ( nsPrefix , nsName ) ; boolean prefixExists = newNamespaces . getNSPrefix ( nsName ) != null ; if ( ! prefixExists ) newNamespaces . putNSPrefix ( nsName , nsPrefix ) ; // If it is due for removal, rememebr it in the oldAttributes list. if ( removeDuplicateNSDeclarations && ( prefixExists || nsName . equals ( newNamespaces . getDefaultNSName ( ) ) ) ) oldAttributes . addElement ( attr ) ; } } } } // Remove all the duplicates on the given element. Enumeration e = oldAttributes . elements ( ) ; while ( e . hasMoreElements ( ) ) element . removeAttributeNode ( ( Attr ) e . nextElement ( ) ) ; // Answer the new list of namespaces for this element. return newNamespaces ; }


Input: Returns the next sibling element of the given element or <code > null< / code > if no such sibling exists . Only the sibling s next children are searched . The element must not be <code > null< / code > . [CODESPLIT] public static Element getNextSibling ( Element element ) { Assert . isNotNull ( element ) ; Node sibling = element ; do { sibling = sibling . getNextSibling ( ) ; } while ( sibling != null && ! isElement ( sibling ) ) ; return ( Element ) sibling ; }


Input: Returns the first WebDAV sibling of the given element that has one of the given names or <code > null< / code > if no such sibling exists . Only the sibling s next children ( not the previous children ) are searched . The element must not be <code > null< / code > and must be a WebDAV element . The possible names of the sibling to search for must not be <code > null< / code > . [CODESPLIT] public static Element getNextSibling ( Element element , String [ ] names ) { Assert . isTrue ( isDAVElement ( element ) ) ; Assert . isNotNull ( names ) ; Node sibling = element . getNextSibling ( ) ; while ( sibling != null ) { for ( int i = 0 ; i < names . length ; ++ i ) if ( isDAVElement ( sibling , names [ i ] ) ) return ( Element ) sibling ; sibling = sibling . getNextSibling ( ) ; } return null ; }


Input: Returns the next WebDAV sibling of the given element that has the given name or <code > null< / code > if no such sibling exists . Only the sibling s next children are searched . The element must not be <code > null< / code > and must be a WebDAV element . The name of the sibling to search for must not be <code > null< / code > . [CODESPLIT] public static Element getNextSibling ( Element element , String name ) { return getNextSibling ( element , new String [ ] { name } ) ; }


Input: Returns the local part of the given name or <code > null< / code > if its name has no local part . The name must not be <code > null< / code > . <table > <caption > Example< / caption > <tr > <th > name< / th > <th > local name< / th > <tr > <td > D : foo< / td > <td > foo< / td > <tr > <td > foo< / td > <td > foo< / td > <tr > <td > D : < / td > <td > null< / td > <tr > <td > : foo< / td > <td > foo< / td > <tr > <td > : < / td > <td > null< / td > < / table > [CODESPLIT] public static String getNSLocalName ( String name ) { Assert . isNotNull ( name ) ; int p = name . lastIndexOf ( ' ' ) ; if ( p == - 1 ) return name ; if ( p == name . length ( ) - 1 ) return null ; return name . substring ( p + 1 ) ; }


Input: Returns the local part of the name of the given element or <code > null< / code > if its name has no local part . The element must not be <code > null< / code > . <table > <caption > Example< / caption > <tr > <th > tag name< / th > <th > local name< / th > <tr > <td > D : foo< / td > <td > foo< / td > <tr > <td > foo< / td > <td > foo< / td > <tr > <td > D : < / td > <td > null< / td > <tr > <td > : foo< / td > <td > foo< / td > <tr > <td > : < / td > <td > null< / td > < / table > [CODESPLIT] public static String getNSLocalName ( Element element ) { Assert . isNotNull ( element ) ; return getNSLocalName ( element . getTagName ( ) ) ; }


Input: Returns the URL of the given element s namespace or <code > null< / code > if it has no namespace . The element must not be <code > null< / code > . [CODESPLIT] public static String getNSName ( Element element ) throws MalformedElementException { Assert . isNotNull ( element ) ; String nsPrefix = getNSPrefix ( element ) ; String nsName = resolve ( nsPrefix , element ) ; if ( nsPrefix != null && nsName == null ) throw new MalformedElementException ( Policy . bind ( "exception.namespacePrefixNotResolved" , nsPrefix ) ) ; //$NON-NLS-1$ return nsName ; }


Input: Returns the namespace prefix part of the given name or <code > null< / code > if its name has no prefix . The name must not be <code > null< / code > . <table > <caption > Example< / caption > <tr > <th > name< / th > <th > namespace prefix< / th > <tr > <td > D : foo< / td > <td > D< / td > <tr > <td > foo< / td > <td > null< / td > <tr > <td > D : < / td > <td > D< / td > <tr > <td > : foo< / td > <td > null< / td > <tr > <td > : < / td > <td > null< / td > < / table > [CODESPLIT] public static String getNSPrefix ( String name ) { Assert . isNotNull ( name ) ; int p = name . lastIndexOf ( ' ' ) ; if ( p <= 0 ) return null ; return name . substring ( 0 , p ) ; }


Input: Returns the namespace prefix part of the name of the given element or <code > null< / code > if its name has no prefix . The element must not be <code > null< / code > . <table > <caption > Example< / caption > <tr > <th > tag name< / th > <th > namespace prefix< / th > <tr > <td > D : foo< / td > <td > D< / td > <tr > <td > foo< / td > <td > null< / td > <tr > <td > D : < / td > <td > D< / td > <tr > <td > : foo< / td > <td > null< / td > <tr > <td > : < / td > <td > null< / td > < / table > [CODESPLIT] public static String getNSPrefix ( Element element ) { Assert . isNotNull ( element ) ; return getNSPrefix ( element . getTagName ( ) ) ; }


Input: Returns a qualified name that is formed from the given element s namespace name and namespace local name . The qualified name s qualifier is the element s namespace name and the qualified name s local name is the element s local name . The element must not be <code > null< / code > . [CODESPLIT] public static QualifiedName getQualifiedName ( Element element ) throws MalformedElementException { Assert . isNotNull ( element ) ; String nsName = getNSName ( element ) ; String nsLocalName = getNSLocalName ( element ) ; if ( nsLocalName == null ) throw new MalformedElementException ( Policy . bind ( "exception.noLocalNameForElmt" ) ) ; //$NON-NLS-1$ return new QualifiedNameImpl ( nsName , nsLocalName ) ; }


Input: Returns the first WebDAV sibling of the given element that has the given name or <code > null< / code > if no such sibling exists . If firstToLast is true only the sibling s next children are searched otherwise only the siblings previous children are searched . The element must not be <code > null< / code > and must be a WebDAV element . The name of the sibling to search for must not be <code > null< / code > . [CODESPLIT] public static Element getSibling ( Element element , String name , boolean firstToLast ) { Assert . isTrue ( isDAVElement ( element ) ) ; Assert . isNotNull ( name ) ; Node sibling = element ; do { if ( firstToLast ) sibling = sibling . getNextSibling ( ) ; else sibling = sibling . getPreviousSibling ( ) ; } while ( sibling != null && ! isDAVElement ( sibling , name ) ) ; return ( Element ) sibling ; }


Input: Returns the data of the given parent s first text node or the empty <code > String< / code > if no such text node exists . If firstToLast is true the search for the text node starts at the parent s first child otherwise the search starts at the parent s last child . The parent must not be <code > null< / code > . [CODESPLIT] public static String getText ( Element parent , boolean firstToLast ) { Assert . isNotNull ( parent ) ; Node child = null ; if ( firstToLast ) child = parent . getFirstChild ( ) ; else child = parent . getLastChild ( ) ; while ( child != null && ! isText ( child ) ) { if ( firstToLast ) child = child . getNextSibling ( ) ; else child = child . getPreviousSibling ( ) ; } if ( child != null ) return ( ( Text ) child ) . getData ( ) ; return "" ; //$NON-NLS-1$ }


Input: Returns the first WebDAV sibling of the given element that has the same name as the element or <code > null< / code > if no such sibling exists . If firstToLast is true only the sibling s next children are searched otherwise only the siblings previous children are searched . The element must not be <code > null< / code > and must be a WebDAV element . [CODESPLIT] public static Element getTwin ( Element element , boolean firstToLast ) { Assert . isTrue ( isDAVElement ( element ) ) ; String name = getNSLocalName ( element ) ; return getSibling ( element , name , firstToLast ) ; }


Input: Creates a WebDAV element with the given name and inserts it before the given sibling . Returns the new sibling . The sibling must not be <code > null< / code > and must be a WebDAV element . The name of the new sibling must not be <code > null< / code > . [CODESPLIT] public static Element insertBefore ( Element sibling , String name ) { Assert . isTrue ( isDAVElement ( sibling ) ) ; Assert . isNotNull ( name ) ; String nsPrefix = getNSPrefix ( sibling ) ; String tagName = nsPrefix == null ? name : nsPrefix + ":" + name ; //$NON-NLS-1$ Element newSibling = sibling . getOwnerDocument ( ) . createElement ( tagName ) ; sibling . getParentNode ( ) . insertBefore ( newSibling , sibling ) ; return newSibling ; }


Input: Returns a boolean indicating whether or not the given node is a WebDAV element . The node may be <code > null< / code > in which case <code > false< / code > is returned . [CODESPLIT] public static boolean isDAVElement ( Node node ) { if ( node == null || node . getNodeType ( ) != Node . ELEMENT_NODE ) return false ; try { if ( ! DAV_NS . equals ( getNSName ( ( Element ) node ) ) ) return false ; } catch ( MalformedElementException e ) { return false ; } return true ; }


Input: Returns a boolean indicating whether or not the given node is a WebDAV element with the given name . The node may be <code > null< / code > in which case <code > false< / code > is returned . The name must not be <code > null< / code > . [CODESPLIT] public static boolean isDAVElement ( Node node , String name ) { Assert . isNotNull ( name ) ; if ( node == null || node . getNodeType ( ) != Node . ELEMENT_NODE ) return false ; try { Element element = ( Element ) node ; if ( ! name . equals ( getNSLocalName ( element ) ) || ! DAV_NS . equals ( getNSName ( element ) ) ) { return false ; } } catch ( MalformedElementException e ) { return false ; } return true ; }


Input: Removes redundant namespace declarations from the given node and all its children to maximum depth . The node must not be <code > null< / code > . [CODESPLIT] public static Node reduceNS ( Node node , Namespaces parentNamespaces ) throws MalformedElementException { Namespaces namespaces = parentNamespaces ; if ( node . getNodeType ( ) == Node . ELEMENT_NODE ) { Element element = ( Element ) node ; namespaces = getNamespaces ( element , parentNamespaces , false ) ; String nsPrefix = getNSPrefix ( element ) ; String nsLocalName = getNSLocalName ( element ) ; if ( nsPrefix != null ) { String nsName = namespaces . getNSName ( nsPrefix ) ; ensureNotNull ( Policy . bind ( "ensure.missingNamespaceForPrefix" , nsPrefix ) , nsName ) ; //$NON-NLS-1$ String tagName = null ; if ( nsName . equals ( namespaces . getDefaultNSName ( ) ) ) { tagName = nsLocalName ; } else { tagName = namespaces . getNSPrefix ( nsName ) + ":" + nsLocalName ; //$NON-NLS-1$ } if ( ! tagName . equals ( element . getTagName ( ) ) ) { Document document = element . getOwnerDocument ( ) ; Element newElement = document . createElement ( tagName ) ; NamedNodeMap nodeMap = element . getAttributes ( ) ; for ( int i = 0 ; i < nodeMap . getLength ( ) ; ++ i ) { Attr attr = ( Attr ) nodeMap . item ( i ) ; newElement . setAttribute ( attr . getName ( ) , attr . getValue ( ) ) ; } Node child = element . getFirstChild ( ) ; while ( child != null ) { element . removeChild ( child ) ; newElement . appendChild ( child ) ; child = element . getFirstChild ( ) ; } element . getParentNode ( ) . replaceChild ( newElement , element ) ; element = newElement ; } } Vector oldAttributes = new Vector ( ) ; Vector newAttributes = new Vector ( ) ; NamedNodeMap nodeMap = element . getAttributes ( ) ; for ( int i = 0 ; i < nodeMap . getLength ( ) ; ++ i ) { Attr attr = ( Attr ) nodeMap . item ( i ) ; String name = attr . getName ( ) ; String value = attr . getValue ( ) ; String newName = name ; nsPrefix = getNSPrefix ( name ) ; nsLocalName = getNSLocalName ( name ) ; if ( nsPrefix != null && ! nsPrefix . equals ( XML_PREFIX ) ) { String nsName = namespaces . getNSName ( nsPrefix ) ; ensureNotNull ( Policy . bind ( "ensure.missingNamespaceForPrefix" , nsPrefix ) , nsName ) ; //$NON-NLS-1$ String newNSPrefix = namespaces . getNSPrefix ( nsName ) ; if ( ! newNSPrefix . equals ( nsPrefix ) ) { newName = newNSPrefix + ":" + nsLocalName ; //$NON-NLS-1$ } } boolean newAttribute = true ; if ( parentNamespaces != null ) { if ( nsPrefix == null && XML_PREFIX . equals ( nsLocalName ) ) { if ( value . equals ( parentNamespaces . getDefaultNSName ( ) ) ) { newAttribute = false ; } } if ( nsPrefix != null && XML_PREFIX . equals ( nsPrefix ) ) { if ( parentNamespaces . getNSPrefix ( value ) != null ) { newAttribute = false ; } } } oldAttributes . addElement ( attr ) ; if ( newAttribute ) { newAttributes . addElement ( new String [ ] { newName , value } ) ; } } Enumeration oldAttrs = oldAttributes . elements ( ) ; while ( oldAttrs . hasMoreElements ( ) ) { element . removeAttributeNode ( ( Attr ) oldAttrs . nextElement ( ) ) ; } Enumeration newAttrs = newAttributes . elements ( ) ; while ( newAttrs . hasMoreElements ( ) ) { String [ ] newAttr = ( String [ ] ) newAttrs . nextElement ( ) ; element . setAttribute ( newAttr [ 0 ] , newAttr [ 1 ] ) ; } node = element ; } Node child = node . getFirstChild ( ) ; while ( child != null ) { child = reduceNS ( child , namespaces ) ; child = child . getNextSibling ( ) ; } return node ; }


Input:
Resolves the given namespace prefix in the namespace of the given element . If the given prefix is  null the default namespace is resolved . Returns the URL of the namespace or  null if the prefix could not be resolved . [CODESPLIT] public static String resolve ( String prefix , Element element ) { Assert . isNotNull ( element ) ; /* The prefix xml is by definition bound to the namespace name
         * XML_NS_NAME.
         */ if ( XML_NS_PREFIX . equals ( prefix ) ) { return XML_NS_NAME ; } /* Search from given element up parent chain to root (document)
         * looking for a XML namespace declaration (represented as
         * an element attribute with a name beginning in
         * XML_PREFIX ("xmlns")).
         */ Node current = element ; do { NamedNodeMap attrs = current . getAttributes ( ) ; int n = attrs . getLength ( ) ; for ( int i = 0 ; i < n ; i ++ ) { Attr attr = ( Attr ) attrs . item ( i ) ; String name = attr . getName ( ) ; if ( name . startsWith ( XML_PREFIX ) ) { if ( name . length ( ) == XML_PREFIX . length ( ) ) { // no prefix e.g., xmlns="foo:" if ( prefix == null ) { String nsName = attr . getValue ( ) ; if ( nsName . equals ( "" ) ) { //$NON-NLS-1$ return null ; } return nsName ; } } else { if ( prefix != null && name . equals ( XML_PREFIX + ":" + prefix ) ) { //$NON-NLS-1$ return attr . getValue ( ) ; } } } } do { current = current . getParentNode ( ) ; } while ( current != null && current . getNodeType ( ) != Node . ELEMENT_NODE ) ; } while ( current != null ) ; return null ; }


Input: <p > Creates a WebDAV element with the given name and sets it as a child of the given parent . Returns the child element . <p > Children are positioned in the order specified by the given names . If a child with the same name as the child already exist the child is replaced . If firstToLast is true the search for the child s position starts at the parent s first child otherwise the search starts at the parent s last child . <p > The parent must not be <code > null< / code > and must be a WebDAV element . The child s name must not be <code > null< / code > . The parent s valid child names must not be <code > null< / code > and must contain the name of the child . [CODESPLIT] public static Element setChild ( Element parent , String name , String [ ] names , boolean firstToLast ) { Assert . isTrue ( isDAVElement ( parent ) ) ; Assert . isNotNull ( name ) ; Assert . isNotNull ( names ) ; String nsPrefix = getNSPrefix ( parent ) ; String tagName = nsPrefix == null ? name : nsPrefix + ":" + name ; //$NON-NLS-1$ Element child = parent . getOwnerDocument ( ) . createElement ( tagName ) ; setChild ( parent , child , names , firstToLast ) ; return child ; }


Input: <p > Sets the given child element as a child of the given parent . <p > Children are positioned in the order specified by the given names . If a child with the same name already exists it is replaced . If firstToLast is true the search for the child s position starts at the parent s first child otherwise the search starts at the parent s last child . <p > The parent must not be <code > null< / code > and must be a WebDAV element . The child must not be null and its namespace prefix must resolve to the WebDAV namespace URL in the parent . The parent s valid child names must not be <code > null< / code > and must contain the name of the child . [CODESPLIT] public static void setChild ( Element parent , Element child , String [ ] names , boolean firstToLast ) { Assert . isTrue ( isDAVElement ( parent ) ) ; Assert . isNotNull ( child ) ; Assert . isTrue ( DAV_NS . equals ( resolve ( getNSPrefix ( child ) , parent ) ) ) ; Assert . isNotNull ( names ) ; boolean found = false ; String name = getNSLocalName ( child ) ; for ( int i = 0 ; ! found && i < names . length ; ++ i ) { found = names [ i ] . equals ( name ) ; } Assert . isTrue ( found ) ; Node sibling = getChild ( parent , name , names , firstToLast ) ; if ( isDAVElement ( sibling , name ) ) { parent . replaceChild ( child , sibling ) ; } else if ( firstToLast ) { if ( sibling == null ) { parent . appendChild ( child ) ; } else { parent . insertBefore ( child , sibling ) ; } } else { Node refChild = null ; if ( sibling == null ) { refChild = parent . getFirstChild ( ) ; } else { refChild = sibling . getNextSibling ( ) ; } if ( refChild == null ) { parent . appendChild ( child ) ; } else { parent . insertBefore ( child , refChild ) ; } } }


Input: Resets the stream to its beginning so it can be read again . [CODESPLIT] public void reset ( ) throws IOException { if ( file == null ) { ( ( ByteArrayInputStream ) is ) . reset ( ) ; } else { if ( fos != null ) { while ( skip ( 4096 ) > 0 ) ; fos . close ( ) ; fos = null ; if ( length == - 1 ) { length = totalBytesRead ; } } is . close ( ) ; is = new FileInputStream ( file ) ; } totalBytesRead = 0 ; }


Input: For user triggered content assistance [CODESPLIT] protected void createActions ( ) { super . createActions ( ) ; IAction a = new TextOperationAction ( RuleEditorMessages . getResourceBundle ( ) , "ContentAssistProposal." , this , ISourceViewer . CONTENTASSIST_PROPOSALS ) ; a . setActionDefinitionId ( ITextEditorActionDefinitionIds . CONTENT_ASSIST_PROPOSALS ) ; setAction ( "ContentAssistProposal" , a ) ; a = new TextOperationAction ( RuleEditorMessages . getResourceBundle ( ) , "ContentAssistTip." , this , ISourceViewer . CONTENTASSIST_CONTEXT_INFORMATION ) ; //$NON-NLS-1$ a . setActionDefinitionId ( ITextEditorActionDefinitionIds . CONTENT_ASSIST_CONTEXT_INFORMATION ) ; setAction ( "ContentAssistTip" , a ) ; a = new ToggleBreakpointAction ( getSite ( ) . getPart ( ) , null , getVerticalRuler ( ) ) ; setAction ( ITextEditorActionConstants . RULER_DOUBLE_CLICK , a ) ; }


Input: Add an incoming or outgoing connection to this vertex . [CODESPLIT] public void addConnection ( Connection conn ) { if ( conn == null || conn . getSource ( ) == conn . getTarget ( ) ) { throw new IllegalArgumentException ( ) ; } if ( conn . getSource ( ) == this ) { sourceConnections . add ( conn ) ; firePropertyChange ( SOURCE_CONNECTIONS_PROP , null , conn ) ; } else if ( conn . getTarget ( ) == this ) { targetConnections . add ( conn ) ; firePropertyChange ( TARGET_CONNECTIONS_PROP , null , conn ) ; } }


Input: Return the property value for the given propertyId or null . [CODESPLIT] public Object getPropertyValue ( Object propertyId ) { if ( XPOS_PROP . equals ( propertyId ) ) { return Integer . toString ( location . x ) ; } if ( YPOS_PROP . equals ( propertyId ) ) { return Integer . toString ( location . y ) ; } if ( HEIGHT_PROP . equals ( propertyId ) ) { return Integer . toString ( size . height ) ; } if ( WIDTH_PROP . equals ( propertyId ) ) { return Integer . toString ( size . width ) ; } return null ; }