signature:
public class ElementEditor { /** * 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 .
 * @ param parent the parent of the child to search for
 * @ return the first WebDAV child of the parent , or null */
public static Element getDAVChild ( Element parent ) { } }

implementation: Assert . isTrue ( isDAVElement ( parent ) ) ; Node child = parent . getFirstChild ( ) ; while ( child != null && ! isDAVElement ( child ) ) child = child . getNextSibling ( ) ; return ( Element ) child ;


signature:
public class ElementEditor { /** * 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 .
 * 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 >
 * @ param parent the parent of the child to search .
 * @ param names all possible names of the child to search for .
 * @ return the specified child of the parent , or
 * < code > null < code > if no such child exists . */
public static Element getFirstChild ( Element parent , String [ ] names ) { } }

implementation: return getChild ( parent , names , true ) ;


signature:
public class ElementEditor { /** * 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 .
 * 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 > .
 * @ param parent the parent of the child to search .
 * @ param name the name of the child to search for .
 * @ return the specified child of the parent , or < code > null
 * < / code > if no such child exists . */
public static Element getFirstChild ( Element parent , String name ) { } }

implementation: Assert . isNotNull ( name ) ; return getChild ( parent , new String [ ] { name } , true ) ;


signature:
public class ElementEditor { /** * 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 > .
 * @ param parent the parent of the text node to search for
 * @ return the data of the text node being searched for , or
 * the empty < code > String < / code > if no such text node
 * exists */
public static String getFirstText ( Element parent ) { } }

implementation:
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 ( ) ;


signature:
public class ElementEditor { /** * 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 .
 * 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 > .
 * @ param parent the parent of the child to search .
 * @ param name the name of the child to search for .
 * @ return the specified child of the parent , or < code > null
 * < / code > if no such child exists . */
public static Element getLastChild ( Element parent , String name ) { } }

implementation: Assert . isNotNull ( name ) ; return getChild ( parent , new String [ ] { name } , false ) ;


signature:
public class ElementEditor { /** * Returns the given element ' s namespace declarations . The element must
 * not be < code > null < / code > .
 * @ param element the element whose namespace declarations are returned
 * @ return the element ' s namespace declarations */
public static Namespaces getNamespaces ( Element element ) { } }

implementation: 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 ) ;


signature:
public class ElementEditor { /** * 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 > .
 * @ param element the element whose namespace declaration is returned
 * @ param namespaces the namespace declarations for the element ' s
 * parent ' s or < code > null < / code > if it has no parent
 * @ param removeDuplicateNSDeclarations a boolean indicating whether
 * duplicate namespace declarations should be removed
 * from the element ' s attributes
 * @ return the given element ' s namespace declarations */
protected static Namespaces getNamespaces ( Element element , Namespaces namespaces , boolean removeDuplicateNSDeclarations ) { } }

implementation:
// 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 ;


signature:
public class ElementEditor { /** * 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 > .
 * @ param element the element whose sibling element is being
 * searched for
 * @ return the sibling element , or < code > null < / code > */
public static Element getNextSibling ( Element element ) { } }

implementation: Assert . isNotNull ( element ) ; Node sibling = element ; do { sibling = sibling . getNextSibling ( ) ; } while ( sibling != null && ! isElement ( sibling ) ) ; return ( Element ) sibling ;


signature:
public class ElementEditor { /** * 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 > .
 * @ param element the element whose sibling is being searched for
 * @ param names the possible names of the sibling being search for
 * @ return the sibling with the specified name , or
 * < code > null < / code > */
public static Element getNextSibling ( Element element , String [ ] names ) { } }

implementation: 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 ;


signature:
public class ElementEditor { /** * 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 > .
 * @ param element the element whose sibling is being searched for
 * @ param name the name of the sibling being search for
 * @ return the sibling with the given name , or
 * < code > null < / code > */
public static Element getNextSibling ( Element element , String name ) { } }

implementation: return getNextSibling ( element , new String [ ] { name } ) ;


signature:
public class ElementEditor { /** * 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 >
 * @ param name the name whose local part is returned
 * @ return the name ' s local part , or < code > null < / code > */
public static String getNSLocalName ( String name ) { } }

implementation: Assert . isNotNull ( name ) ; int p = name . lastIndexOf ( ':' ) ; if ( p == - 1 ) return name ; if ( p == name . length ( ) - 1 ) return null ; return name . substring ( p + 1 ) ;


signature:
public class ElementEditor { /** * 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 >
 * @ param element the element whose local name is returned
 * @ return the element ' s local name , or < code > null < / code > */
public static String getNSLocalName ( Element element ) { } }

implementation: Assert . isNotNull ( element ) ; return getNSLocalName ( element . getTagName ( ) ) ;


signature:
public class ElementEditor { /** * 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 > .
 * @ param element the element whose namespace is returned
 * @ return the namespace of the element , or < code > null < / code >
 * @ throws MalformedElementException if the name of the given
 * element has a namespace prefix which could not be
 * resolved */
public static String getNSName ( Element element ) throws MalformedElementException { } }

implementation:
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 ;


signature:
public class ElementEditor { /** * 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 >
 * @ param name the name whose namespace prefix is returned
 * @ return the name ' s namespace prefix , or < code > null < / code > */
public static String getNSPrefix ( String name ) { } }

implementation: Assert . isNotNull ( name ) ; int p = name . lastIndexOf ( ':' ) ; if ( p <= 0 ) return null ; return name . substring ( 0 , p ) ;


signature:
public class ElementEditor { /** * 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 >
 * @ param element the element whose namespace prefix is returned
 * @ return the element ' s namespace prefix , or < code > null < / code > */
public static String getNSPrefix ( Element element ) { } }

implementation: Assert . isNotNull ( element ) ; return getNSPrefix ( element . getTagName ( ) ) ;


signature:
public class ElementEditor { /** * 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 > .
 * @ param element the element whose qualified name is returned
 * @ return the qualified name that is formed from the given
 * element ' s namespace name and namespace local name
 * @ exception MalformedElementException if the name of the element has a
 * namespace prefix which could not be resolved , or the
 * element does not have a local name */
public static QualifiedName getQualifiedName ( Element element ) throws MalformedElementException { } }

implementation:
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 ) ;


signature:
public class ElementEditor { /** * 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 > .
 * @ param element the element whose sibling is being searched for
 * @ param name the name of the sibling being search for
 * @ param firstToLast a boolean specifying the direction to search for
 * the sibling among the element ' s siblings
 * @ return the sibling with the given name , or
 * < code > null < / code >
 * @ deprecated */
public static Element getSibling ( Element element , String name , boolean firstToLast ) { } }

implementation: 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 ;


signature:
public class ElementEditor { /** * 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 > .
 * @ param parent the parent of the text node to search for
 * @ param firstToLast a boolean specifying the direction to search for
 * the text node among the parent ' s children
 * @ return the data of the text node being searched for , or
 * the empty < code > String < / code > if no such text node
 * exists
 * @ deprecated */
public static String getText ( Element parent , boolean firstToLast ) { } }

implementation: 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 $


signature:
public class ElementEditor { /** * 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 .
 * @ param element the element whose sibling is being searched for
 * @ param firstToLast a boolean specifying the direction to search for
 * the sibling among the element ' s siblings
 * @ return the sibling with the same name as the given
 * element , or < code > null < / code > if no such element
 * exists */
public static Element getTwin ( Element element , boolean firstToLast ) { } }

implementation: Assert . isTrue ( isDAVElement ( element ) ) ; String name = getNSLocalName ( element ) ; return getSibling ( element , name , firstToLast ) ;


signature:
public class ElementEditor { /** * 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 > .
 * @ param sibling the existing sibling element
 * @ param name the name of the new sibling element that is created
 * and inserted before the existing sibling element
 * @ return the new sibling element that is created */
public static Element insertBefore ( Element sibling , String name ) { } }

implementation:
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 ;


signature:
public class ElementEditor { /** * 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 .
 * @ param node a node , or < code > null < / code >
 * @ return a boolean indicating whether or not the given node is a
 * WebDAV element */
public static boolean isDAVElement ( Node node ) { } }

implementation: 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 ;


signature:
public class ElementEditor { /** * 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 > .
 * @ param node a node , or < code > null < / code >
 * @ return a boolean indicating whether or not the given node is a
 * WebDAV element with the given name */
public static boolean isDAVElement ( Node node , String name ) { } }

implementation: 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 ;


signature:
public class ElementEditor { /** * Removes redundant namespace declarations from the given node and all
 * its children to maximum depth . The node must not be
 * < code > null < / code > .
 * @ param node the node whose namespace declarations are to be reduced
 * @ return the node , or a new node ( element ) with an equivalent
 * qualified name but whose tag name has changed
 * @ throws MalformedElementException if the name of the given node
 * ( element ) , or one of its attributes , has a namespace
 * prefix which could not be resolved */
public static Node reduceNS ( Node node , Namespaces parentNamespaces ) throws MalformedElementException { } }

implementation:
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 ;


signature:
public class ElementEditor { /** * Resolves the given namespace prefix in the namespace of the given
 * element . If the given prefix is < code > null < / code > , the default
 * namespace is resolved . Returns the URL of the namespace , or
 * < code > null < / code > if the prefix could not be resolved .
 * @ param prefix the namespace prefix to be resolved , or
 * < code > null < code > for the default namespace
 * @ param element the element supplying the namespace
 * @ return the URL of the namespace , or < code > null < / code > if the
 * prefix could not be resolved */
public static String resolve ( String prefix , Element element ) { } }

implementation:
Assert . isNotNull ( element ) ; /* The prefix xml is by definition bound to the namespace name
 * < code > XML _ NS _ NAME < / code > . */
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 ;


signature:
public class ElementEditor { /** * < 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 .
 * @ param parent the parent to which the child is added
 * @ param name the name of the child which is created and added
 * to the parent
 * @ param names the ordered collection of valid child names for
 * the parent
 * @ param firstToLast a boolean specifying the direction to search for
 * the child ' s position among the parent ' s children
 * @ return the child element that is created */
public static Element setChild ( Element parent , String name , String [ ] names , boolean firstToLast ) { } }

implementation:
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 ;


signature:
public class ElementEditor { /** * < 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 .
 * @ param parent the parent to which the child is added
 * @ param child the child which is added to the parent
 * @ param names the ordered collection of valid child names for
 * the parent
 * @ param firstToLast a boolean specifying the direction to search for
 * the child ' s position among the parent ' s children */
public static void setChild ( Element parent , Element child , String [ ] names , boolean firstToLast ) { } }

implementation: 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 ) ; } }


signature:
public class RequestInputStream { /** * Resets the stream to its beginning so it can be read again .
 * @ exception IOException if there is an I / O error */
public void reset ( ) throws IOException { } }

implementation: 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 ;


signature:
public class AbstractRuleEditor { /** * For user triggered content assistance */
protected void createActions ( ) { } }

implementation:
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 ) ;


signature:
public class GraphicalVertex { /** * Add an incoming or outgoing connection to this vertex .
 * @ param conn a non - null connection instance
 * @ throws IllegalArgumentException if the connection is null or has not distinct endpoints */
public void addConnection ( Connection conn ) { } }

implementation: 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 ) ; }


signature:
public class GraphicalVertex { /** * Return the property value for the given propertyId , or null . */
public Object getPropertyValue ( Object propertyId ) { } }

implementation: 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 ;


signature:
public class GraphicalVertex { /** * Remove an incoming or outgoing connection from this vertex .
 * @ param conn a non - null connection instance
 * @ throws IllegalArgumentException if the parameter is null */
public void removeConnection ( Connection conn ) { } }

implementation: if ( conn == null ) { throw new IllegalArgumentException ( ) ; } if ( conn . getSource ( ) == this ) { sourceConnections . remove ( conn ) ; firePropertyChange ( SOURCE_CONNECTIONS_PROP , null , conn ) ; } else if ( conn . getTarget ( ) == this ) { targetConnections . remove ( conn ) ; firePropertyChange ( TARGET_CONNECTIONS_PROP , null , conn ) ; }


signature:
public class GraphicalVertex { /** * Set the Location of this vertex .
 * @ param newLocation a non - null Point instance
 * @ throws IllegalArgumentException if the parameter is null */
public void setLocation ( Point newLocation ) { } }

implementation: if ( newLocation == null ) { throw new IllegalArgumentException ( ) ; } location . setLocation ( newLocation ) ; firePropertyChange ( LOCATION_PROP , null , location ) ;


signature:
public class GraphicalVertex { /** * Set the property value for the given property id . */
public void setPropertyValue ( Object propertyId , Object value ) { } }

implementation: if ( XPOS_PROP . equals ( propertyId ) ) { int x = Integer . parseInt ( ( String ) value ) ; setLocation ( new Point ( x , location . y ) ) ; } else if ( YPOS_PROP . equals ( propertyId ) ) { int y = Integer . parseInt ( ( String ) value ) ; setLocation ( new Point ( location . x , y ) ) ; } else if ( HEIGHT_PROP . equals ( propertyId ) ) { int height = Integer . parseInt ( ( String ) value ) ; setSize ( new Dimension ( size . width , height ) ) ; } else if ( WIDTH_PROP . equals ( propertyId ) ) { int width = Integer . parseInt ( ( String ) value ) ; setSize ( new Dimension ( width , size . height ) ) ; }


signature:
public class GraphicalVertex { /** * Set the Size of this vertex .
 * Will not update the size if newSize is null .
 * @ param newSize a non - null Dimension instance or null */
public void setSize ( Dimension newSize ) { } }

implementation: if ( newSize != null ) { size . setSize ( newSize ) ; firePropertyChange ( SIZE_PROP , null , size ) ; }


signature:
public class GraphicalVertex { /** * Constructs constraints string
 * @ param constraints array of constraints
 * @ return html - formatted constraints representation */
public static String dumpConstraints ( final Constraint [ ] constraints ) { } }

implementation: if ( constraints == null ) { return null ; } final StringBuffer buffer = new StringBuffer ( ) ; for ( int i = 0 , length = constraints . length ; i < length ; i ++ ) { buffer . append ( constraints [ i ] . toString ( ) + "<br>" ) ; } return buffer . toString ( ) ;


signature:
public class ZoomInAction2 { /** * Replaces existing zoomManager with the new one .
 * Implementation is null - safe .
 * @ param newManager new zoom manager */
public void setZoomManager ( ZoomManager newManager ) { } }

implementation: if ( zoomManager != null ) { zoomManager . removeZoomListener ( this ) ; } zoomManager = newManager ; if ( zoomManager != null ) { zoomManager . addZoomListener ( this ) ; }


signature:
public class StreamProcessingUtils { /** * $ NON - NLS - 1 $ */
public static Map < String , ResourceProperties > parseListing ( String base , InputStream is ) throws Exception { } }

implementation:
Map < String , ResourceProperties > res = new HashMap < String , ResourceProperties > ( ) ; DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; DocumentBuilder parser = factory . newDocumentBuilder ( ) ; Document doc = parser . parse ( is ) ; NodeList nl = doc . getElementsByTagNameNS ( DAV_NS , "response" ) ; // $ NON - NLS - 1 $
for ( int i = 0 ; i < nl . getLength ( ) ; i ++ ) { Element oneElem = ( Element ) nl . item ( i ) ; NodeList resName = oneElem . getElementsByTagNameNS ( DAV_NS , "href" ) ; // $ NON - NLS - 1 $
assert ( resName . getLength ( ) == 1 ) ; String bareName = extractOverlap ( base , URLDecoder . decode ( resName . item ( 0 ) . getTextContent ( ) , "UTF-8" ) ) ; if ( bareName . trim ( ) . length ( ) > 0 ) { ResourceProperties props = new ResourceProperties ( ) ; NodeList propList = oneElem . getElementsByTagNameNS ( DAV_NS , "resourcetype" ) ; // $ NON - NLS - 1 $
assert ( propList . getLength ( ) == 1 ) ; NodeList resTypeList = ( ( Element ) propList . item ( 0 ) ) . getElementsByTagNameNS ( DAV_NS , "collection" ) ; // $ NON - NLS - 1 $
assert ( resTypeList . getLength ( ) < 2 ) ; if ( resTypeList . getLength ( ) == 1 ) { props . setDirectory ( true ) ; } propList = oneElem . getElementsByTagNameNS ( DAV_NS , "creationdate" ) ; // $ NON - NLS - 1 $
if ( propList . getLength ( ) > 0 ) { props . setCreationDate ( propList . item ( 0 ) . getTextContent ( ) ) ; } propList = oneElem . getElementsByTagNameNS ( DAV_NS , "getlastmodified" ) ; // $ NON - NLS - 1 $
if ( propList . getLength ( ) > 0 ) { props . setLastModifiedDate ( propList . item ( 0 ) . getTextContent ( ) ) ; } String normBase = base . trim ( ) . endsWith ( "/" ) ? base . trim ( ) : base . trim ( ) + "/" ; // $ NON - NLS - 1 $ / / $ NON - NLS - 2 $
props . setBase ( normBase ) ; res . put ( bareName , props ) ; } } return res ;


signature:
public class DSLMappingSorter { /** * / * ( non - Javadoc )
 * Method declared on ViewerSorter . */
public int compare ( Viewer viewer , Object o1 , Object o2 ) { } }

implementation: DSLMappingEntry item1 = ( DSLMappingEntry ) o1 ; DSLMappingEntry item2 = ( DSLMappingEntry ) o2 ; switch ( criteria ) { case OBJECT : return compareObject ( item1 , item2 ) ; case EXPRESSION : return compareExpressions ( item1 , item2 ) ; case MAPPING : return compareMappings ( item1 , item2 ) ; case SCOPE : return compareScope ( item1 , item2 ) ; default : return 0 ; }


signature:
public class SupportedLock { /** * Creates a new lockentry and adds it to this supported lock . Returns
 * an editor on the new lockentry .
 * @ return an editor on a new lockentry for this supportedlock */
public LockEntry addLockEntry ( ) { } }

implementation:
Element lockentry = addChild ( root , "lockentry" , childNames , false ) ; // $ NON - NLS - 1 $
Element locktype = appendChild ( lockentry , "locktype" ) ; // $ NON - NLS - 1 $
appendChild ( locktype , "write" ) ; // $ NON - NLS - 1 $
LockEntry result = null ; try { result = new LockEntry ( lockentry ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; // $ NON - NLS - 1 $
} return result ;


signature:
public class SupportedLock { /** * Returns an < code > Enumeration < / code > over this supportedlock ' s
 * < code > LockEntry < / code > s .
 * @ return an < code > Enumeration < / code > of < code > LockEntry < / code > s
 * @ throws MalformedElementException if there is reason to believe that
 * this editor ' s underlying element is not well formed */
public Enumeration getLockEntries ( ) throws MalformedElementException { } }

implementation:
final Node firstLockEntry = getFirstChild ( root , "lockentry" ) ; // $ NON - NLS - 1 $
Enumeration e = new Enumeration ( ) { Node currentLockEntry = firstLockEntry ; public boolean hasMoreElements ( ) { return currentLockEntry != null ; } public Object nextElement ( ) { if ( ! hasMoreElements ( ) ) throw new NoSuchElementException ( ) ; LockEntry result = null ; try { result = new LockEntry ( ( Element ) currentLockEntry ) ; } catch ( MalformedElementException ex ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; // $ NON - NLS - 1 $
} currentLockEntry = getTwin ( ( Element ) currentLockEntry , true ) ; return result ; } } ; return e ;


signature:
public class RepositoryView { /** * ( non - Javadoc )
 * @ see org . eclipse . ui . part . WorkbenchPart # createPartControl ( org . eclipse . swt . widgets . Composite ) */
public void createPartControl ( Composite parent ) { } }

implementation:
viewer = new TreeViewer ( parent , SWT . MULTI | SWT . H_SCROLL | SWT . V_SCROLL ) ; drillDownAdapter = new DrillDownAdapter ( viewer ) ; viewer . setContentProvider ( new RepositoryContentProvider ( ) ) ; viewer . setLabelProvider ( new RepositoryLabelProvider ( ) ) ; viewer . setSorter ( new NameSorter ( ) ) ; viewer . setInput ( viewer ) ; makeActions ( ) ; hookContextMenu ( ) ; hookDoubleClickAction ( ) ; contributeToActionBars ( ) ; Activator . getLocationManager ( ) . addRepositorySetListener ( new IRepositorySetListener ( ) { public void repositorySetChanged ( int type , List < GuvnorRepository > repList ) { // TODO : Just creating an entirely new content provider .
// Someday might update this to have incremental changes
// to existing content provider .
viewer . setContentProvider ( new RepositoryContentProvider ( ) ) ; } } ) ; super . getSite ( ) . setSelectionProvider ( viewer ) ; addDragDropSupport ( ) ;


signature:
public class ReteGraph { /** * Add new BaseVertex to the graph
 * @ param vertex
 * @ return true , if vertex was added , false otherwise */
public boolean addChild ( BaseVertex vertex ) { } }

implementation: if ( vertex != null && vertices . add ( vertex ) ) { firePropertyChange ( PROP_CHILD_ADDED , null , vertex ) ; return true ; } return false ;


signature:
public class ReteGraph { /** * Remove a vertex from this graph
 * @ param vertex vertex to be removed
 * @ return true , if the vertex removal succeeded , false otherwise */
public boolean removeChild ( BaseVertex vertex ) { } }

implementation: if ( vertex != null && vertices . remove ( vertex ) ) { firePropertyChange ( PROP_CHILD_REMOVED , null , vertex ) ; return true ; } return false ;


signature:
public class DroolsEclipsePlugin { /** * This method is called upon plug - in activation */
public void start ( BundleContext context ) throws Exception { } }

implementation: super . start ( context ) ; IPreferenceStore preferenceStore = getPreferenceStore ( ) ; useCachePreference = preferenceStore . getBoolean ( IDroolsConstants . CACHE_PARSED_RULES ) ; preferenceStore . addPropertyChangeListener ( new IPropertyChangeListener ( ) { public void propertyChange ( PropertyChangeEvent event ) { if ( IDroolsConstants . CACHE_PARSED_RULES . equals ( event . getProperty ( ) ) ) { useCachePreference = ( ( Boolean ) event . getNewValue ( ) ) . booleanValue ( ) ; if ( ! useCachePreference ) { clearCache ( ) ; } } } } ) ;


signature:
public class DroolsEclipsePlugin { /** * This method is called when the plug - in is stopped */
public void stop ( BundleContext context ) throws Exception { } }

implementation: super . stop ( context ) ; plugin = null ; resourceBundle = null ; parsedRules = null ; compiledRules = null ; processInfos = null ; processInfosById = null ; for ( Color color : colors . values ( ) ) { color . dispose ( ) ; }


signature:
public class DroolsEclipsePlugin { /** * Returns the string from the plugin ' s resource bundle ,
 * or ' key ' if not found . */
public static String getResourceString ( String key ) { } }

implementation: ResourceBundle bundle = DroolsEclipsePlugin . getDefault ( ) . getResourceBundle ( ) ; try { return ( bundle != null ) ? bundle . getString ( key ) : key ; } catch ( MissingResourceException e ) { return key ; }


signature:
public class DroolsEclipsePlugin { /** * Returns the plugin ' s resource bundle , */
public ResourceBundle getResourceBundle ( ) { } }

implementation: try { if ( resourceBundle == null ) resourceBundle = ResourceBundle . getBundle ( "droolsIDE.DroolsIDEPluginResources" ) ; } catch ( MissingResourceException x ) { resourceBundle = null ; } return resourceBundle ;


signature:
public class DroolsEclipsePlugin { /** * Form Colors , default colors for now .
 * @ param display
 * @ return */
public FormColors getRuleBuilderFormColors ( Display display ) { } }

implementation: if ( ruleBuilderFormColors == null ) { ruleBuilderFormColors = new FormColors ( display ) ; ruleBuilderFormColors . markShared ( ) ; } return ruleBuilderFormColors ;


signature:
public class DateTime { /** * Do nothing if date format is not supported */
public void setDateTime ( String date ) { } }

implementation: String [ ] patterns = { RFC_1123_PATTERN , ISO_8601_UTC_PATTERN , ISO_8601_UTC_MILLIS_PATTERN , ISO_8601_PATTERN , ISO_8601_MILLIS_PATTERN , RFC_850_PATTERN , ASCTIME_PATTERN } ; for ( int i = 0 ; i < patterns . length ; i ++ ) { if ( setDateTime ( date , patterns [ i ] ) ) break ; }


signature:
public class DateTime { /** * Do nothing if date format is not supported . */
protected boolean setDateTime ( String date , String pattern ) { } }

implementation: boolean dateChanged = true ; dateFormat . applyPattern ( pattern ) ; try { setDateTime ( dateFormat . parse ( date ) ) ; } catch ( ParseException e ) { dateChanged = false ; } return dateChanged ;


signature:
public class PreferencesUtils { /** * $ NON - NLS - 1 $ */
public static String getDefaultRepositoryDir ( ) { } }

implementation:
String key = core_defaultRepositoryDir ; String dir = getDeprecatedRepoRootPreference ( ) ; IEclipsePreferences p = InstanceScope . INSTANCE . getNode ( egitPluginId ) ; if ( dir == null ) { dir = p . get ( key , getDefaultDefaultRepositoryDir ( ) ) ; } IStringVariableManager manager = VariablesPlugin . getDefault ( ) . getStringVariableManager ( ) ; String result ; try { result = manager . performStringSubstitution ( dir ) ; } catch ( CoreException e ) { result = "" ; // $ NON - NLS - 1 $
} if ( result == null || result . isEmpty ( ) ) { result = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getRawLocation ( ) . toOSString ( ) ; } return result ;


signature:
public class Activator { /** * ( non - Javadoc )
 * @ see org . osgi . framework . BundleActivator # stop ( org . osgi . framework . BundleContext ) */
public void stop ( BundleContext bundleContext ) throws Exception { } }

implementation: context = null ; instance = null ; super . stop ( bundleContext ) ;


signature:
public class Activator { /** * Utility to create an error status for this plug - in .
 * @ param message User comprehensible message
 * @ param thr cause
 * @ return an initialized error status */
public static IStatus error ( final String message , final Throwable thr ) { } }

implementation: return new Status ( IStatus . ERROR , PLUGIN_ID , 0 , message , thr ) ;


signature:
public class Activator { /** * Utility method to log errors in the Egit plugin .
 * @ param message User comprehensible message
 * @ param thr The exception through which we noticed the error */
public static void logError ( final String message , final Throwable thr ) { } }

implementation: getDefault ( ) . getLog ( ) . log ( error ( message , thr ) ) ;


signature:
public class FieldEditorPropertyPage { /** * Adds the given field editor to this page .
 * @ param editor the field editor */
protected void addField ( FieldEditor editor ) { } }

implementation:
if ( fields == null ) { fields = new ArrayList < FieldEditor > ( ) ; } // Set the actual preference name based on the current selection
// in the Kie Navigator tree view . The preference name is constructed
// from the path to the selected tree node by getPreferenceName ( ) .
String name = editor . getPreferenceName ( ) ; editor . setPreferenceName ( getPreferenceName ( name ) ) ; fields . add ( editor ) ;


signature:
public class FieldEditorPropertyPage { /** * Adjust the layout of the field editors so that they are properly aligned . */
protected void adjustGridLayout ( ) { } }

implementation: int numColumns = calcNumberOfColumns ( ) ; ( ( GridLayout ) fieldEditorParent . getLayout ( ) ) . numColumns = numColumns ; if ( fields != null ) { for ( int i = 0 ; i < fields . size ( ) ; i ++ ) { FieldEditor fieldEditor = fields . get ( i ) ; fieldEditor . fillIntoGrid ( fieldEditorParent , numColumns ) ; } }


signature:
public class FieldEditorPropertyPage { /** * Applys the font to the field editors managed by this page . */
protected void applyFont ( ) { } }

implementation:
if ( fields != null ) { Iterator < FieldEditor > e = fields . iterator ( ) ; while ( e . hasNext ( ) ) { FieldEditor pe = e . next ( ) ; // pe . applyFont ( ) ;
} }


signature:
public class FieldEditorPropertyPage { /** * Calculates the number of columns needed to host all field editors .
 * @ return the number of columns */
private int calcNumberOfColumns ( ) { } }

implementation: int result = 0 ; if ( fields != null ) { Iterator < FieldEditor > e = fields . iterator ( ) ; while ( e . hasNext ( ) ) { FieldEditor pe = e . next ( ) ; result = Math . max ( result , pe . getNumberOfControls ( ) ) ; } } return result ;


signature:
public class FieldEditorPropertyPage { /** * Recomputes the page ' s error state by calling < code > isValid < / code > for
 * every field editor . */
protected void checkState ( ) { } }

implementation:
boolean valid = true ; invalidFieldEditor = null ; // The state can only be set to true if all
// field editors contain a valid value . So we must check them all
if ( fields != null ) { int size = fields . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { FieldEditor editor = fields . get ( i ) ; valid = valid && editor . isValid ( ) ; if ( ! valid ) { invalidFieldEditor = editor ; break ; } } } setValid ( valid ) ;


signature:
public class FieldEditorPropertyPage { /** * ( non - Javadoc ) Method declared on PreferencePage . */
@ Override protected Control createContents ( Composite parent ) { } }

implementation: fieldEditorParent = new Composite ( parent , SWT . NULL ) ; GridLayout layout = new GridLayout ( ) ; layout . numColumns = 1 ; layout . marginHeight = 0 ; layout . marginWidth = 0 ; fieldEditorParent . setLayout ( layout ) ; fieldEditorParent . setFont ( parent . getFont ( ) ) ; createFieldEditors ( ) ; if ( style == GRID ) { adjustGridLayout ( ) ; } initialize ( ) ; checkState ( ) ; return fieldEditorParent ;


signature:
public class FieldEditorPropertyPage { /** * The field editor preference page implementation of an
 * < code > IDialogPage < / code > method disposes of this page ' s controls and
 * images . Subclasses may override to release their own allocated SWT
 * resources , but must call < code > super . dispose < / code > . */
@ Override public void dispose ( ) { } }

implementation: super . dispose ( ) ; if ( fields != null ) { Iterator < FieldEditor > e = fields . iterator ( ) ; while ( e . hasNext ( ) ) { FieldEditor pe = e . next ( ) ; pe . setPage ( null ) ; pe . setPropertyChangeListener ( null ) ; pe . setPreferenceStore ( null ) ; } }


signature:
public class FieldEditorPropertyPage { /** * Returns a parent composite for a field editor .
 * This value must not be cached since a new parent may be created each time
 * this method called . Thus this method must be called each time a field
 * editor is constructed .
 * @ return a parent */
protected Composite getFieldEditorParent ( ) { } }

implementation:
if ( style == FLAT ) { // Create a new parent for each field editor
Composite parent = new Composite ( fieldEditorParent , SWT . NULL ) ; parent . setLayoutData ( new GridData ( GridData . FILL_HORIZONTAL ) ) ; return parent ; } // Just return the parent
return fieldEditorParent ;


signature:
public class FieldEditorPropertyPage { /** * Initializes all field editors . */
protected void initialize ( ) { } }

implementation: if ( fields != null ) { Iterator < FieldEditor > e = fields . iterator ( ) ; while ( e . hasNext ( ) ) { FieldEditor pe = e . next ( ) ; pe . setPage ( this ) ; pe . setPropertyChangeListener ( this ) ; pe . setPreferenceStore ( getPreferenceStore ( ) ) ; pe . load ( ) ; } }


signature:
public class FieldEditorPropertyPage { /** * The field editor preference page implementation of a
 * < code > PreferencePage < / code > method loads all the field editors with their
 * default values . */
@ Override protected void performDefaults ( ) { } }

implementation:
if ( fields != null ) { Iterator < FieldEditor > e = fields . iterator ( ) ; while ( e . hasNext ( ) ) { FieldEditor pe = e . next ( ) ; pe . loadDefault ( ) ; } } // Force a recalculation of my error state .
checkState ( ) ; super . performDefaults ( ) ;


signature:
public class FieldEditorPropertyPage { /** * The field editor preference page implementation of this
 * < code > PreferencePage < / code > method saves all field editors by calling
 * < code > FieldEditor . store < / code > . Note that this method does not save the
 * preference store itself ; it just stores the values back into the
 * preference store .
 * @ see FieldEditor # store ( ) */
@ Override public boolean performOk ( ) { } }

implementation:
if ( fields != null ) { Iterator < FieldEditor > e = fields . iterator ( ) ; while ( e . hasNext ( ) ) { FieldEditor pe = e . next ( ) ; pe . store ( ) ; // pe . setPresentsDefaultValue ( false ) ;
} } return true ;


signature:
public class FieldEditorPropertyPage { /** * The field editor preference page implementation of this
 * < code > IPreferencePage < / code > ( and < code > IPropertyChangeListener < / code > )
 * method intercepts < code > IS _ VALID < / code > events but passes other events on
 * to its superclass . */
@ Override public void propertyChange ( PropertyChangeEvent event ) { } }

implementation:
if ( event . getProperty ( ) . equals ( FieldEditor . IS_VALID ) ) { boolean newValue = ( ( Boolean ) event . getNewValue ( ) ) . booleanValue ( ) ; // If the new value is true then we must check all field editors .
// If it is false , then the page is invalid in any case .
if ( newValue ) { checkState ( ) ; } else { invalidFieldEditor = ( FieldEditor ) event . getSource ( ) ; setValid ( newValue ) ; } }


signature:
public class FieldEditorPropertyPage { /** * ( non - Javadoc ) Method declared on IDialog . */
@ Override public void setVisible ( boolean visible ) { } }

implementation: super . setVisible ( visible ) ; if ( visible && invalidFieldEditor != null ) { invalidFieldEditor . setFocus ( ) ; }


signature:
public class JsonPreferenceStore { /** * { @ inheritDoc } */
public boolean contains ( String name ) { } }

implementation: JsonValue value = object . get ( name ) ; return value != null ;


signature:
public class JsonPreferenceStore { /** * { @ inheritDoc } */
public void firePropertyChangeEvent ( String name , Object oldValue , Object newValue ) { } }

implementation: firePropertyChangeEvent ( this , name , oldValue , newValue ) ;


signature:
public class JsonPreferenceStore { /** * Fires a property change event with the given source , property name , old and new value . Used
 * when the event source should be different from this mockup preference store .
 * @ param source The event source
 * @ param name The property name
 * @ param oldValue The property ' s old value
 * @ param newValue The property ' s new value */
public void firePropertyChangeEvent ( Object source , String name , Object oldValue , Object newValue ) { } }

implementation: PropertyChangeEvent event = new PropertyChangeEvent ( source , name , oldValue , newValue ) ; Object [ ] listeners = fListeners . getListeners ( ) ; for ( int i = 0 ; i < listeners . length ; i ++ ) ( ( IPropertyChangeListener ) listeners [ i ] ) . propertyChange ( event ) ;


signature:
public class JsonPreferenceStore { /** * { @ inheritDoc } */
public void putValue ( String name , String value ) { } }

implementation: object . set ( name , value ) ; dirty = true ;


signature:
public class JsonPreferenceStore { /** * { @ inheritDoc } */
public void setValue ( String name , String value ) { } }

implementation: String oldValue = this . getString ( name ) ; putValue ( name , value ) ; firePropertyChangeEvent ( name , oldValue , value ) ;


signature:
public class CompareVersionAction { /** * ( non - Javadoc )
 * @ see org . eclipse . ui . IActionDelegate # run ( org . eclipse . jface . action . IAction ) */
public void run ( IAction action ) { } }

implementation: if ( selectedFile == null || props == null || targetPart == null ) { return ; } VersionChooserDialog dialog = new VersionChooserDialog ( targetPart . getSite ( ) . getShell ( ) , selectedFile . getName ( ) , getVersionEntries ( ) ) ; if ( dialog . open ( ) == VersionChooserDialog . OK ) { compareWithSelectedVersion ( dialog . getSelectedEntry ( ) ) ; }


signature:
public class DRLRuleEditorActionContributor { /** * / * ( non - Javadoc )
 * @ see org . eclipse . ui . part . EditorActionBarContributor # init ( org . eclipse . ui . IActionBars , org . eclipse . ui . IWorkbenchPage ) */
public void init ( IActionBars bars , IWorkbenchPage page ) { } }

implementation: contributor . init ( bars ) ; super . init ( bars , page ) ;


signature:
public class DRLRuleEditorActionContributor { /** * / * ( non - Javadoc )
 * @ see org . eclipse . ui . part . MultiPageEditorActionBarContributor # setActivePage ( org . eclipse . ui . IEditorPart ) */
public void setActivePage ( IEditorPart activeEditor ) { } }

implementation: IActionBars bars = getActionBars ( ) ; if ( activeEditor instanceof ITextEditor ) { if ( bars != null ) { contributor . setActiveEditor ( activeEditor ) ; } }


signature:
public class DRLRuleEditorActionContributor { /** * In addition to @ link org . eclipse . ui . part . MultiPageEditorActionBarContributor # setActiveEditor ( org . eclipse . ui . IEditorPart )
 * it sets contribution items to DRLRuleEditor2 for later use when
 * multipageditor tabs are switched . */
public void setActiveEditor ( IEditorPart part ) { } }

implementation: super . setActiveEditor ( part ) ; if ( part instanceof DRLRuleEditor2 ) { DRLRuleEditor2 p = ( DRLRuleEditor2 ) part ; p . setZoomComboContributionItem ( zitem ) ; p . setZoomInAction ( zoomIn ) ; p . setZoomOutAction ( zoomOut ) ; }


signature:
public class DRLRuleEditorActionContributor { /** * Adds Zoom - related contributions .
 * @ see org . eclipse . ui . part . EditorActionBarContributor # contributeToToolBar ( org . eclipse . jface . action . IToolBarManager ) */
public void contributeToToolBar ( IToolBarManager toolBarManager ) { } }

implementation: super . contributeToToolBar ( toolBarManager ) ; toolBarManager . add ( new Separator ( ) ) ; String [ ] zoomStrings = new String [ ] { ZoomManager . FIT_ALL , ZoomManager . FIT_HEIGHT , ZoomManager . FIT_WIDTH } ; zitem = new ZoomComboContributionItem ( getPage ( ) , zoomStrings ) ; zitem . setZoomManager ( null ) ; zitem . setVisible ( false ) ; zoomIn = new ZoomInAction2 ( ) ; zoomIn . setEnabled ( false ) ; zoomOut = new ZoomOutAction2 ( ) ; zoomOut . setEnabled ( false ) ; toolBarManager . add ( zitem ) ; toolBarManager . add ( zoomIn ) ; toolBarManager . add ( zoomOut ) ;


signature:
public class CompletionContext { /** * especially when parsing incomplete rules */
private void determineDialect ( String backText ) { } }

implementation: dialect = null ; boolean mvel = MVEL_DIALECT_PATTERN . matcher ( backText ) . matches ( ) ; boolean java = JAVA_DIALECT_PATTERN . matcher ( backText ) . matches ( ) ; if ( mvel ) { dialect = MVEL_DIALECT ; } else if ( java ) { dialect = JAVA_DIALECT ; }


signature:
public class CompletionContext { /** * Returns the variables defined in the given rule ( fragment ) .
 * The key is the name of the variable .
 * The value is a list of 2 String :
 * - the first one is the class name of the variable
 * - the second one is the property of the given class that defines the type of this variable ,
 * note that this property could be nested ,
 * if this property is null then the given class is the type of the variable */
public Map < String , String [ ] > getRuleParameters ( ) { } }

implementation: Map < String , String [ ] > result = new HashMap < String , String [ ] > ( ) ; int i = 0 ; int lastLocation = - 1 ; for ( Object o : parserList ) { if ( o instanceof DroolsToken ) { DroolsToken token = ( DroolsToken ) o ; if ( DroolsEditorType . IDENTIFIER_VARIABLE . equals ( token . getEditorType ( ) ) || DroolsEditorType . IDENTIFIER_PATTERN . equals ( token . getEditorType ( ) ) ) { String variableName = token . getText ( ) ; if ( lastLocation == Location . LOCATION_LHS_BEGIN_OF_CONDITION ) { int j = i + 2 ; String className = "" ; while ( j < parserList . size ( ) ) { Object obj = parserList . get ( j ++ ) ; if ( obj instanceof DroolsToken ) { String s = ( ( DroolsToken ) obj ) . getText ( ) ; if ( "(" . equals ( s ) ) { result . put ( variableName , new String [ ] { className , null } ) ; break ; } else { className += s ; } } } } else if ( lastLocation == Location . LOCATION_LHS_INSIDE_CONDITION_START ) { int index = findTokenBack ( Location . LOCATION_LHS_BEGIN_OF_CONDITION , i ) ; int j = index + 3 ; String className = "" ; while ( j < i ) { Object obj = parserList . get ( j ++ ) ; if ( obj instanceof DroolsToken ) { String s = ( ( DroolsToken ) obj ) . getText ( ) ; if ( "(" . equals ( s ) ) { break ; } else { className += s ; } } } j = i + 2 ; String propertyName = "" ; while ( j < parserList . size ( ) ) { Object obj = parserList . get ( j ++ ) ; if ( obj instanceof DroolsToken ) { String s = ( ( DroolsToken ) obj ) . getText ( ) ; if ( "," . equals ( s ) || ")" . equals ( s ) ) { result . put ( variableName , new String [ ] { className , propertyName } ) ; break ; } else { propertyName += s ; } } else { result . put ( variableName , new String [ ] { className , propertyName } ) ; } } } } } else if ( o instanceof Integer ) { lastLocation = ( Integer ) o ; } i ++ ; } return result ;


signature:
public class URLDecoder { /** * Decodes the given < code > URL < / code > from an < code > ASCII < / code >
 * readable < code > URL < / code > that is safe for transport . Returns the
 * result .
 * @ return the result of decoding the given < code > URL < / code > from an
 * < code > ASCII < / code > readable < code > URL < / code > that is safe for
 * transport */
public static String decode ( String url ) { } }

implementation:
try { return decode ( new URL ( url ) ) . toString ( ) ; } catch ( MalformedURLException e ) { // ignore or log ?
} String file ; String ref = null ; int lastSlashIndex = url . lastIndexOf ( '/' ) ; int lastHashIndex = url . lastIndexOf ( '#' ) ; if ( ( lastHashIndex - lastSlashIndex > 1 ) && lastHashIndex < url . length ( ) - 1 ) { file = url . substring ( 0 , lastHashIndex ) ; ref = url . substring ( lastHashIndex + 1 , url . length ( ) ) ; } else { file = url ; } return decode ( file , ref ) ;


signature:
public class URLDecoder { /** * Decodes the file and reference parts of a < code > URL < / code > from an
 * < code > ASCII < / code > readable < code > URL < / code > that is safe for
 * transport . Returns the result .
 * @ return the result of decoding the file and reference parts of a
 * < code > URL < / code > from an < code > ASCII < / code > readable
 * < code > URL < / code > that is safe for transport */
public static String decode ( String file , String ref ) { } }

implementation:
StringBuffer buf = new StringBuffer ( ) ; StringTokenizer tokenizer = new StringTokenizer ( file , "/" , true ) ; // $ NON - NLS - 1 $
while ( tokenizer . hasMoreTokens ( ) ) { String token = tokenizer . nextToken ( ) ; if ( token . equals ( "/" ) ) { // $ NON - NLS - 1 $
buf . append ( token ) ; } else { buf . append ( decodeSegment ( token ) ) ; } } if ( ref != null ) { buf . append ( '#' ) ; buf . append ( decodeSegment ( ref ) ) ; } return buf . toString ( ) ;


signature:
public class Base64Encoder { /** * Returns the BASE64 encoded < code > String < / code > of the given data .
 * @ param data the bytes to be BASE64 encoded
 * @ return the BASE64 encoded < code > String < / code > of the given data */
public static String encode ( byte [ ] data ) { } }

implementation:
Assert . isNotNull ( data ) ; StringBuffer buf = new StringBuffer ( ) ; byte b = 0 ; int bits = 2 ; for ( int i = 0 ; i < data . length ; ++ i ) { b = ( byte ) ( ( b | ( data [ i ] >> bits ) ) & 0x003f ) ; buf . append ( encode ( b ) ) ; b = ( byte ) ( ( data [ i ] << 6 - bits ) & 0x003f ) ; bits += 2 ; if ( bits == 8 ) { buf . append ( encode ( ( byte ) ( b & 0x003f ) ) ) ; b = 0 ; bits = 2 ; } } if ( bits == 4 ) { buf . append ( encode ( b ) ) ; buf . append ( "==" ) ; // $ NON - NLS - 1 $
} else if ( bits == 6 ) { buf . append ( encode ( b ) ) ; buf . append ( '=' ) ; } return buf . toString ( ) ;


signature:
public class DAVClient { /** * Returns a new context that is based on the given context .
 * @ param userContext
 * @ param locator
 * @ return a new context that is based on the given context */
protected IContext newContext ( IContext userContext , ILocator locator ) throws MalformedURLException { } }

implementation: Assert . isNotNull ( userContext ) ; Assert . isNotNull ( locator ) ; IContext context = davFactory . newContext ( userContext ) ; if ( locator . getLabel ( ) != null ) context . setLabel ( locator . getLabel ( ) ) ; return context ;


signature:
public class DSLEditor { /** * for the sort field */
public void doSave ( IProgressMonitor monitor ) { } }

implementation: FileEditorInput input = ( FileEditorInput ) getEditorInput ( ) ; File outputFile = input . getFile ( ) . getLocation ( ) . toFile ( ) ; saveFile ( monitor , outputFile , input ) ;


signature:
public class DSLEditor { /** * Setup table listeners for GUI events . */
private void createTableListeners ( ) { } }

implementation:
// setup views into current selected
table . addSelectionListener ( new SelectionListener ( ) { public void widgetSelected ( SelectionEvent e ) { populate ( ) ; } public void widgetDefaultSelected ( SelectionEvent e ) { populate ( ) ; } private void populate ( ) { DSLMappingEntry selected = getCurrentSelected ( ) ; exprText . setText ( selected . getMappingKey ( ) ) ; mappingText . setText ( selected . getMappingValue ( ) ) ; objText . setText ( selected . getMetaData ( ) . getMetaData ( ) == null ? "" : selected . getMetaData ( ) . getMetaData ( ) ) ; } } ) ; // double click support
table . addMouseListener ( new MouseListener ( ) { public void mouseDoubleClick ( MouseEvent e ) { showEditPopup ( ) ; } public void mouseDown ( MouseEvent e ) { } public void mouseUp ( MouseEvent e ) { } } ) ;


signature:
public class DSLEditor { /** * Create the Table */
private void createTable ( Composite parent ) { } }

implementation:
int style = SWT . MULTI | SWT . BORDER | SWT . H_SCROLL | SWT . V_SCROLL | SWT . FULL_SELECTION | SWT . HIDE_SELECTION ; table = new Table ( parent , style ) ; GridData gridData = new GridData ( GridData . FILL_BOTH ) ; gridData . grabExcessVerticalSpace = true ; gridData . horizontalSpan = 3 ; table . setLayoutData ( gridData ) ; table . setLinesVisible ( true ) ; table . setHeaderVisible ( true ) ; TableColumn column ; // Expression col
column = new TableColumn ( table , SWT . LEFT , 0 ) ; column . setText ( "Language Expression" ) ; column . setWidth ( 350 ) ; // Add listener to column so sorted when clicked
column . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent e ) { tableViewer . setSorter ( new DSLMappingSorter ( DSLMappingSorter . EXPRESSION ) ) ; } } ) ; // 3rd column with task Owner
column = new TableColumn ( table , SWT . LEFT , 1 ) ; column . setText ( "Rule Language Mapping" ) ; column . setWidth ( 200 ) ; // Add listener to column so sorted when clicked
column . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent e ) { tableViewer . setSorter ( new DSLMappingSorter ( DSLMappingSorter . MAPPING ) ) ; } } ) ; // 4th column with task PercentComplete
column = new TableColumn ( table , SWT . LEFT , 2 ) ; column . setText ( "Object" ) ; column . setWidth ( 80 ) ; // 5th column with task PercentComplete
column = new TableColumn ( table , SWT . LEFT , 3 ) ; column . setText ( "Scope" ) ; column . setWidth ( 80 ) ; // Add listener to column so tasks are sorted when clicked
column . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent e ) { tableViewer . setSorter ( new DSLMappingSorter ( DSLMappingSorter . SCOPE ) ) ; } } ) ;


signature:
public class URLTable { /** * Returns the value to which the given URL is mapped to in the table . If
 * the given URL not mapped to any value , or is malformed , returns
 * < code > null < / code > .
 * @ param url a URL as a < code > String < / code >
 * @ return the value to which the given URL is mapped to in the table ,
 * or < code > null < / code >
 * @ throws MalformedURLException if the given URL is malformed */
public Object get ( String url ) throws MalformedURLException { } }

implementation: Assert . isNotNull ( url ) ; return get ( new URL ( url ) ) ;


signature:
public class URLTable { /** * Returns the value to which the given < code > URL < / code > is mapped to in
 * the table . If the given < code > URL < / code > not mapped to any value ,
 * returns < code > null < / code > .
 * @ param url a < code > URL < / code >
 * @ return the value to which the given < code > URL < / code > is mapped to
 * in the table , or < code > null < / code > */
public Object get ( URL url ) { } }

implementation: Assert . isNotNull ( url ) ; return get ( new URLKey ( url ) ) ;


signature:
public class URLTable { /** * Returns the value to which the specified URL is mapped to in the
 * table . If the specified URL is not mapped to any value , returns
 * < code > null < / code > .
 * @ param url a < code > URLKey < / code >
 * @ return the value to which the specified URL is mapped to in the
 * table , or < code > null < / code > */
private Object get ( URLKey url ) { } }

implementation: Assert . isNotNull ( url ) ; return table . get ( url ) ;


signature:
public class URLTable { /** * Returns an < code > Enumeration < / code > over the keys in this
 * < code > URLTable < / code > .
 * @ return an < code > Enumeration < / code > over < code > URL < / code > s */
public Enumeration keys ( ) { } }

implementation: final Enumeration keys = table . keys ( ) ; Enumeration e = new Enumeration ( ) { public boolean hasMoreElements ( ) { return keys . hasMoreElements ( ) ; } public Object nextElement ( ) { return ( ( URLKey ) keys . nextElement ( ) ) . getURL ( ) ; } } ; return e ;


signature:
public class URLTable { /** * Maps the given URL to the given value in this table .
 * @ param url a URL as a < code > String < / code >
 * @ param value an object
 * @ throws MalformedURLException if the given URL is malformed */
public void put ( String url , Object value ) throws MalformedURLException { } }

implementation: Assert . isNotNull ( url ) ; Assert . isNotNull ( value ) ; put ( new URL ( url ) , value ) ;


signature:
public class URLTable { /** * Maps the given < code > URL < / code > to the given value in this table .
 * @ param url a < code > URL < / code >
 * @ param value an object */
public void put ( URL url , Object value ) { } }

implementation: Assert . isNotNull ( url ) ; Assert . isNotNull ( value ) ; put ( new URLKey ( url ) , value ) ;


signature:
public class URLTable { /** * Maps the specified URL to the given value in this table .
 * @ param url a < code > URLKey < / code >
 * @ param value an object */
private void put ( URLKey url , Object value ) { } }

implementation:
Assert . isNotNull ( url ) ; Assert . isNotNull ( value ) ; // Remove the old entry so the url key is replaced
if ( table . get ( url ) != null ) table . remove ( url ) ; table . put ( url , value ) ;


signature:
public class Node { /** * The method will create a new Node instance and try to add it as
 * a child node . If an Node with the same string token exists , the
 * method will return the existing node instead .
 * @ param token
 * @ return */
public Node addToken ( String token ) { } }

implementation:
Node newnode = new Node ( token ) ; // set the depth first
newnode . setDepth ( depth + 1 ) ; // add the node as a child
newnode = addChild ( newnode ) ; return newnode ;


signature:
public class Node { /** * The method will check to see if a Node with the same string token
 * already exists . If it doesn ' t , it will add the token as a child and
 * return the same node .
 * On the otherhand , if there is an existing Node for the same string
 * token , the method returns the existing Node instance .
 * @ param n
 * @ return */
public Node addChild ( Node n ) { } }

implementation: if ( ! this . children . containsKey ( n . getToken ( ) ) ) { this . children . put ( n . getToken ( ) , n ) ; n . setParent ( this ) ; return n ; } else { return ( Node ) this . children . get ( n . getToken ( ) ) ; }


signature:
public class DroolsElement { /** * be used directly . Use DroolsModelBuilder instead . */
void setFile ( IFile file , int offset , int length ) { } }

implementation: this . file = file ; this . offset = offset ; this . length = length ;


signature:
public class NodeSetConstraintCommand { /** * / * ( non - Javadoc )
 * @ see org . eclipse . gef . commands . Command # canExecute ( ) */
public boolean canExecute ( ) { } }

implementation: Object type = request . getType ( ) ; return ( RequestConstants . REQ_MOVE . equals ( type ) || RequestConstants . REQ_MOVE_CHILDREN . equals ( type ) ) ;


signature:
public class Precondition { /** * Add a Condition to this Precondition . Conditions are OR ' d together to
 * check for a matching resource .
 * @ param condition the Condition to add
 * @ exception WebDAVException thrown if the precondition already contains this condition */
public void addCondition ( Condition condition ) throws WebDAVException { } }

implementation:
// a Resource URI can only be specified once in a Precondition
Enumeration conditions = getConditions ( ) ; if ( condition . getResourceURI ( ) != null ) { while ( conditions . hasMoreElements ( ) ) { Condition existingCondition = ( Condition ) conditions . nextElement ( ) ; if ( existingCondition . getResourceURI ( ) != null && existingCondition . getResourceURI ( ) . equals ( condition . getResourceURI ( ) ) ) throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMultipleSpecification" , condition . getResourceURI ( ) ) ) ; // $ NON - NLS - 1 $
} } this . conditions . addElement ( condition ) ;


signature:
public class Precondition { /** * Add a condition created from the given URI and state token . This is a
 * convenience method used primarily to create preconditions for lock tokens
 * that must be provided in the resource context for methods that update
 * the resource .
 * @ param resourceURI the URI of the resource the state token applies to . Null
 * implicitly specifies the resource processing the request
 * @ param stateToken the state token to match */
public void addStateTokenCondition ( String resourceURI , String stateToken ) throws WebDAVException { } }

implementation: Condition condition = new Condition ( resourceURI ) ; ConditionTerm term = new ConditionTerm ( ) ; term . addConditionFactor ( new StateToken ( stateToken ) ) ; condition . addConditionTerm ( term ) ; addCondition ( condition ) ;


signature:
public class Precondition { /** * See if this Precondition contains a matching Condition .
 * @ param condition the condition to match
 * @ return true if this precondition contains atleast one condition matching the given condition */
public boolean matches ( Condition condition ) { } }

implementation: boolean match = false ; Enumeration conditions = getConditions ( ) ; while ( ! match && conditions . hasMoreElements ( ) ) { Condition existingCondition = ( Condition ) conditions . nextElement ( ) ; match = existingCondition . matches ( condition ) ; } return match ;


signature:
public class Assert { /** * Asserts that the given object is not < code > null < / code > . If this
 * is not the case , some kind of unchecked exception is thrown .
 * The given message is included in that exception , to aid debugging . */
static public void isNotNull ( Object o , String message ) { } }

implementation: if ( o == null ) throw new AssertionFailedException ( Policy . bind ( "assert.null" , message ) ) ; // $ NON - NLS - 1 $


signature:
public class Assert { /** * Asserts that the given boolean is < code > true < / code > . If this
 * is not the case , some kind of unchecked exception is thrown .
 * The given message is included in that exception , to aid debugging . */
static public boolean isTrue ( boolean expression , String message ) { } }

implementation:
if ( ! expression ) throw new AssertionFailedException ( Policy . bind ( "assert.fail" , message ) ) ; // $ NON - NLS - 1 $
return expression ;


signature:
public class PropStat { /** * Returns this propstat ' s prop .
 * @ return this propstat ' s prop
 * @ throws MalformedElementException if there is reason to believe that
 * this editor ' s underlying element is not well formed */
public Prop getProp ( ) throws MalformedElementException { } }

implementation:
Element prop = getFirstChild ( root , "prop" ) ; // $ NON - NLS - 1 $
ensureNotNull ( Policy . bind ( "ensure.missingPropElmt" ) , prop ) ; // $ NON - NLS - 1 $
return new Prop ( prop ) ;


signature:
public class PropStat { /** * Returns this propstat ' s status .
 * @ return this propstat ' s status
 * @ throws MalformedElementException if there is reason to believe that
 * this editor ' s underlying element is not well formed */
public String getStatus ( ) throws MalformedElementException { } }

implementation:
String status = getChildText ( root , "status" , false ) ; // $ NON - NLS - 1 $
ensureNotNull ( Policy . bind ( "ensure.missingStatusElmt" ) , status ) ; // $ NON - NLS - 1 $
return status ;


signature:
public class PropStat { /** * Creates and sets a new prop on this propstat and returns an editor on
 * it .
 * @ return an editor on a new prop element */
public Prop setProp ( ) { } }

implementation:
Element prop = setChild ( root , "prop" , childNames , true ) ; // $ NON - NLS - 1 $
try { return new Prop ( prop ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; // $ NON - NLS - 1 $
return null ; // Never reached .
}


signature:
public class PropStat { /** * Sets the status on this propstat to the given status . The status
 * must not be < code > null < / code > .
 * @ param status the status for this propstat */
public void setStatus ( String status ) { } }

implementation: Assert . isNotNull ( status ) ; setChild ( root , "status" , status , childNames , true ) ; // $ NON - NLS - 1 $


signature:
public class DSLRuleCompletionProcessor { /** * because of how the backText works , we need to get the last line , so that
 * we can pass it to the DSLUtility
 * @ param backText
 * @ return */
public String getLastLine ( String backText ) { } }

implementation:
BufferedReader breader = new BufferedReader ( new StringReader ( backText ) ) ; String last = "" ; String line = null ; try { while ( ( line = breader . readLine ( ) ) != null ) { // only if the line has text do we set last to it
if ( line . length ( ) > 0 ) { last = line ; } } } catch ( IOException e ) { DroolsEclipsePlugin . log ( e ) ; } // now that all the conditions for a single object are on the same line
// we need to check for the left parenthesis
if ( last . indexOf ( "(" ) > - 1 ) { last = last . substring ( last . lastIndexOf ( "(" ) + 1 ) ; } // if the string has a comma " , " we get the substring starting from
// the index after the last comma
if ( last . indexOf ( "," ) > - 1 ) { last = last . substring ( last . lastIndexOf ( "," ) + 1 ) ; } // if the line ends with right parenthesis , we change it to zero length
// string
if ( last . endsWith ( ")" ) ) { last = "" ; } return last ;


signature:
public class DSLRuleCompletionProcessor { /** * Returns the last line that doesn ' t start with a dash
 * @ param backText
 * @ return */
public String getLastNonDashLine ( String backText ) { } }

implementation:
BufferedReader breader = new BufferedReader ( new StringReader ( backText ) ) ; String last = "" ; String line = null ; try { while ( ( line = breader . readLine ( ) ) != null ) { // there may be blank lines , so we trim first
line = line . trim ( ) ; // only if the line has text do we set last to it
if ( line . length ( ) > 0 && ! line . startsWith ( "-" ) ) { last = line ; } } } catch ( IOException e ) { DroolsEclipsePlugin . log ( e ) ; } if ( last . indexOf ( "(" ) > - 1 && ! last . endsWith ( ")" ) ) { last = last . substring ( 0 , last . indexOf ( "(" ) ) ; } else if ( last . indexOf ( "(" ) > - 1 && last . endsWith ( ")" ) ) { last = "" ; } return last ;


signature:
public class DSLRuleCompletionProcessor { /** * The DSLTree is configurable . It can either return just the child of the
 * last token found , or it can traverse the tree and generate all the
 * combinations beneath the last matching node . TODO I don ' t know how to add
 * configuration to the editor , so it needs to be hooked up to the
 * configuration for the editor later .
 * @ param last
 * @ return */
protected List < String > getProposals ( DSLAdapter adapter , String obj , String last , boolean firstLine ) { } }

implementation: if ( last . length ( ) == 0 ) { last = " " ; } return adapter . getDSLTree ( ) . getChildrenList ( obj , last , true , firstLine ) ;


signature:
public class Policy { /** * Lookup the message with the given ID in this catalog and bind its
 * substitution locations with the given string . */
public static String bind ( String id , String binding ) { } }

implementation: return bind ( id , new String [ ] { binding } ) ;


signature:
public class Policy { /** * Lookup the message with the given ID in this catalog and bind its
 * substitution locations with the given strings . */
public static String bind ( String id , String binding1 , String binding2 ) { } }

implementation: return bind ( id , new String [ ] { binding1 , binding2 } ) ;


signature:
public class Policy { /** * Lookup the message with the given ID in this catalog and bind its
 * substitution locations with the given string values . */
public static String bind ( String id , String [ ] bindings ) { } }

implementation:
if ( id == null ) return "No message available" ; // $ NON - NLS - 1 $
String message = null ; try { message = bundle . getString ( id ) ; } catch ( MissingResourceException e ) { // If we got an exception looking for the message , fail gracefully by just returning
// the id we were looking for . In most cases this is semi - informative so is not too bad .
return "Missing message: " + id + "in: " + bundleName ; // $ NON - NLS - 1 $ / / $ NON - NLS - 2 $
} if ( bindings == null ) return message ; return MessageFormat . format ( message , bindings ) ;


signature:
public class URLEncoder { /** * Encodes the given file and reference parts of a < code > URL < / code > into
 * an < code > ASCII < / code > readable < code > String < / code > that is safe for
 * transport . Returns the result .
 * @ return the result of encoding the given file and reference parts of
 * a < code > URL < / code > into an < code > ASCII < / code > readable
 * < code > String < / code > that is safe for transport */
public static String encode ( String file , String ref ) { } }

implementation:
StringBuffer buf = new StringBuffer ( ) ; StringTokenizer tokenizer = new StringTokenizer ( file , "/" , true ) ; // $ NON - NLS - 1 $
while ( tokenizer . hasMoreTokens ( ) ) { String token = tokenizer . nextToken ( ) ; if ( token . equals ( "/" ) ) { // $ NON - NLS - 1 $
buf . append ( token ) ; } else { buf . append ( encodeSegment ( token ) ) ; } } if ( ref != null ) { buf . append ( '#' ) ; buf . append ( encodeSegment ( ref ) ) ; } return buf . toString ( ) ;


signature:
public class URLEncoder { /** * Encodes the given < code > URL < / code > into an < code > ASCII < / code >
 * readable < code > URL < / code > that is safe for transport . Returns the
 * result .
 * @ return the result of encoding the given < code > URL < / code > into an
 * < code > ASCII < / code > readable < code > URL < / code > that is safe for
 * transport */
public static URL encode ( URL url ) { } }

implementation:
String file = url . getFile ( ) ; String ref = url . getRef ( ) ; try { return new URL ( url . getProtocol ( ) , url . getHost ( ) , url . getPort ( ) , encode ( file , ref ) ) ; } catch ( MalformedURLException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; // $ NON - NLS - 1 $
} return null ;


signature:
public class ConnectionEditPart { /** * / * ( non - Javadoc )
 * @ see org . eclipse . gef . editparts . AbstractGraphicalEditPart # createFigure ( ) */
protected IFigure createFigure ( ) { } }

implementation: PolylineConnection connection = new ConnectionFigure ( ) ; PolylineDecoration decoration = new PolylineDecoration ( ) ; connection . setTargetDecoration ( decoration ) ; return connection ;


signature:
public class NewJBPMProjectWizard { /** * Create the sample process file .
 * @ throws IOException */
private void createProcess ( IJavaProject project , IProgressMonitor monitor , String exampleType ) throws CoreException , IOException { } }

implementation:
// create the process ( sample . bpmn ) file
String fileName = "org/jbpm/eclipse/wizard/project/" + exampleType + ".bpmn.template" ; IFolder folder = null ; folder = project . getProject ( ) . getFolder ( "src/main/resources/com/sample" ) ; FileUtils . createFolder ( folder , monitor ) ; IFile file = folder . getFile ( "sample.bpmn" ) ; InputStream inputstream = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( fileName ) ; if ( ! file . exists ( ) ) { file . create ( inputstream , true , monitor ) ; } else { file . setContents ( inputstream , true , false , monitor ) ; } // create a Java main class to invoke the process
fileName = "org/jbpm/eclipse/wizard/project/ProcessMain-" + exampleType + ".java" ; IRuntime runtime = startPage . getRuntime ( ) ; if ( runtime . getVersion ( ) . getMajor ( ) == 5 ) { fileName += ".v5.template" ; } else { fileName += ".template" ; } folder = project . getProject ( ) . getFolder ( "src/main/java" ) ; IPackageFragmentRoot packageFragmentRoot = project . getPackageFragmentRoot ( folder ) ; IPackageFragment packageFragment = packageFragmentRoot . createPackageFragment ( "com.sample" , true , monitor ) ; inputstream = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( fileName ) ; packageFragment . createCompilationUnit ( "ProcessMain.java" , new String ( FileUtils . readStream ( inputstream ) ) , true , monitor ) ; // create persistence . xml
if ( runtime . getVersion ( ) . getMajor ( ) == 5 ) { if ( "advanced" . equals ( exampleType ) ) { folder = project . getProject ( ) . getFolder ( "src/main/resources/META-INF" ) ; FileUtils . createFolder ( folder , monitor ) ; inputstream = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( "org/jbpm/eclipse/wizard/project/ProcessLauncher-advanced-persistence.xml.template" ) ; file = folder . getFile ( "persistence.xml" ) ; if ( ! file . exists ( ) ) { file . create ( inputstream , true , monitor ) ; } else { file . setContents ( inputstream , true , false , monitor ) ; } } }


signature:
public class NewJBPMProjectWizard { /** * Create the sample process junit test file . */
private void createProcessSampleJUnit ( IJavaProject project , String exampleType , IProgressMonitor monitor ) throws JavaModelException , IOException { } }

implementation: String s = "org/jbpm/eclipse/wizard/project/ProcessJUnit-" + exampleType + ".java" ; IRuntime runtime = startPage . getRuntime ( ) ; if ( runtime . getVersion ( ) . getMajor ( ) == 5 ) { s += ".v5.template" ; } else { s += ".template" ; } IFolder folder = project . getProject ( ) . getFolder ( "src/main/java" ) ; IPackageFragmentRoot packageFragmentRoot = project . getPackageFragmentRoot ( folder ) ; IPackageFragment packageFragment = packageFragmentRoot . createPackageFragment ( "com.sample" , true , monitor ) ; InputStream inputstream = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( s ) ; packageFragment . createCompilationUnit ( "ProcessTest.java" , new String ( FileUtils . readStream ( inputstream ) ) , true , monitor ) ;


signature:
public class NewJBPMProjectWizard { /** * / * ( non - Javadoc )
 * @ see org . kie . eclipse . wizard . project . AbstractKieProjectWizard # createOnlineExampleProjectPage ( java . lang . String )
 * Create the Online Example Project Wizard Page */
@ Override protected IKieProjectWizardPage createOnlineExampleProjectPage ( String pageId ) { } }

implementation: return new AbstractKieOnlineExampleProjectWizardPage ( ONLINE_EXAMPLE_PROJECT_PAGE ) { @ Override public String getTitle ( ) { return "Create jBPM Projects from Online Examples" ; } @ Override public String getDescription ( ) { return "Select jBPM Example Projects" ; } @ Override public IRuntimeManager getRuntimeManager ( ) { return JBPMRuntimeManager . getDefault ( ) ; } @ Override public String getProductId ( ) { return "jbpm" ; } } ;


signature:
public class KieServerHandler { /** * Return the version number of the KIE Workbench that is installed on the
 * given server . If the server is not running or not responsive , use a value
 * from the Preference Store .
 * @ param server
 * @ return */
@ Override public String getRuntimeId ( ) { } }

implementation: IPreferenceStore store = org . kie . eclipse . Activator . getDefault ( ) . getPreferenceStore ( ) ; String value = store . getString ( getKieVersionPreferenceKey ( ) ) ; return value ;


signature:
public class KieServerHandler { /** * / * ( non - Javadoc )
 * @ see org . kie . eclipse . navigator . view . server . IKieService # getRepositories ( org . kie . eclipse . navigator . view . server . IKieSpaceHandler ) */
@ Override public List < IKieRepositoryHandler > getRepositories ( IKieSpaceHandler space ) throws IOException { } }

implementation: return getDelegate ( ) . getRepositories ( space ) ;


signature:
public class KieServerHandler { /** * / * ( non - Javadoc )
 * @ see org . kie . eclipse . navigator . view . server . IKieService # getProjects ( org . kie . eclipse . navigator . view . server . IKieRepository ) */
@ Override public List < IKieProjectHandler > getProjects ( IKieRepositoryHandler repository ) throws IOException { } }

implementation: return getDelegate ( ) . getProjects ( repository ) ;


signature:
public class ArrayUtils { /** * < p > Finds the index of the given object in the array starting at the given index . < / p >
 * < p > This method returns { @ link # INDEX _ NOT _ FOUND } ( < code > - 1 < / code > ) for a < code > null < / code > input array . < / p >
 * < p > A negative startIndex is treated as zero . A startIndex larger than the array
 * length will return { @ link # INDEX _ NOT _ FOUND } ( < code > - 1 < / code > ) . < / p >
 * @ param array the array to search through for the object , may be < code > null < / code >
 * @ param objectToFind the object to find , may be < code > null < / code >
 * @ param startIndex the index to start searching at
 * @ return the index of the object within the array starting at the index ,
 * { @ link # INDEX _ NOT _ FOUND } ( < code > - 1 < / code > ) if not found or < code > null < / code > array input */
public static int indexOf ( Object [ ] array , Object objectToFind , int startIndex ) { } }

implementation: if ( array == null ) { return INDEX_NOT_FOUND ; } if ( startIndex < 0 ) { startIndex = 0 ; } if ( objectToFind == null ) { for ( int i = startIndex ; i < array . length ; i ++ ) { if ( array [ i ] == null ) { return i ; } } } else { for ( int i = startIndex ; i < array . length ; i ++ ) { if ( objectToFind . equals ( array [ i ] ) ) { return i ; } } } return INDEX_NOT_FOUND ;


signature:
public class ShowHistoryAction { /** * ( non - Javadoc )
 * @ see org . eclipse . ui . IActionDelegate # run ( org . eclipse . jface . action . IAction ) */
public void run ( IAction action ) { } }

implementation:
String repositoryLoc = null ; String fullPath = null ; if ( selectedNode != null ) { repositoryLoc = selectedNode . getGuvnorRepository ( ) . getLocation ( ) ; fullPath = selectedNode . getFullPath ( ) ; } else { if ( selectedFile == null || props == null ) { return ; } repositoryLoc = props . getRepository ( ) ; fullPath = props . getFullpath ( ) ; } IResponse response = null ; try { IWebDavClient client = WebDavServerCache . getWebDavClient ( repositoryLoc ) ; if ( client == null ) { client = WebDavClientFactory . createClient ( new URL ( repositoryLoc ) ) ; WebDavServerCache . cacheWebDavClient ( repositoryLoc , client ) ; } InputStream ins = null ; try { response = client . getResourceVersions ( fullPath ) ; ins = response . getInputStream ( ) ; } catch ( WebDavException wde ) { if ( wde . getErrorCode ( ) != IResponse . SC_UNAUTHORIZED ) { // If not an authentication failure , we don ' t know what to do with it
throw wde ; } boolean retry = PlatformUtils . getInstance ( ) . authenticateForServer ( repositoryLoc , client ) ; if ( retry ) { response = client . getResourceVersions ( fullPath ) ; ins = response . getInputStream ( ) ; } } if ( ins != null ) { Properties verProps = new Properties ( ) ; verProps . load ( ins ) ; ResourceHistoryView view = PlatformUtils . getResourceHistoryView ( ) ; if ( view != null ) { view . setEntries ( repositoryLoc , fullPath , verProps ) ; } } } catch ( Exception e ) { Activator . getDefault ( ) . displayError ( IStatus . ERROR , e . getMessage ( ) , e , true ) ; } finally { if ( response != null ) { try { response . close ( ) ; } catch ( IOException ioe ) { Activator . getDefault ( ) . writeLog ( IStatus . ERROR , ioe . getMessage ( ) , ioe ) ; } } }


signature:
public class ShowHistoryAction { /** * ( non - Javadoc )
 * @ see org . eclipse . ui . IActionDelegate # selectionChanged ( org . eclipse . jface . action . IAction , org . eclipse . jface . viewers . ISelection ) */
public void selectionChanged ( IAction action , ISelection selection ) { } }

implementation:
// Reset state to default
selectedFile = null ; selectedNode = null ; props = null ; action . setEnabled ( false ) ; if ( ! ( selection instanceof IStructuredSelection ) ) { return ; } IStructuredSelection sel = ( IStructuredSelection ) selection ; if ( sel . size ( ) != 1 ) { return ; } if ( sel . getFirstElement ( ) instanceof IFile ) { try { props = GuvnorMetadataUtils . getGuvnorMetadata ( ( IFile ) sel . getFirstElement ( ) ) ; if ( props != null ) { selectedFile = ( IFile ) sel . getFirstElement ( ) ; action . setEnabled ( true ) ; } } catch ( Exception e ) { Activator . getDefault ( ) . writeLog ( IStatus . ERROR , e . getMessage ( ) , e ) ; } } if ( sel . getFirstElement ( ) instanceof TreeObject ) { if ( ( ( TreeObject ) sel . getFirstElement ( ) ) . getNodeType ( ) == TreeObject . Type . RESOURCE ) { selectedNode = ( TreeObject ) sel . getFirstElement ( ) ; action . setEnabled ( true ) ; } }


signature:
public class ReteooVisitor { /** * Rete visits each of its ObjectTypeNodes . */
public void visitRete ( final Rete rete ) { } }

implementation: this . rootVertex = ( ReteVertex ) this . visitedNodes . get ( dotId ( rete ) ) ; if ( this . rootVertex == null ) { this . rootVertex = new ReteVertex ( rete ) ; this . visitedNodes . put ( dotId ( rete ) , this . rootVertex ) ; } this . graph . addChild ( this . rootVertex ) ; this . parentVertex = this . rootVertex ; for ( EntryPointNode node : rete . getEntryPointNodes ( ) . values ( ) ) { visit ( node ) ; }


signature:
public class ReteooVisitor { /** * Helper method to ensure nodes are not visited more than once . */
private void visitNode ( final Object node ) { } }

implementation: Object realNode = node ; if ( node instanceof ObjectHashMap . ObjectEntry ) { ObjectHashMap . ObjectEntry entry = ( ObjectHashMap . ObjectEntry ) node ; realNode = entry . getValue ( ) ; } visit ( realNode ) ;


signature:
public class ReteooVisitor { /** * The identity hashCode for the given object is used as its unique DOT
 * identifier . */
private static String dotId ( final Object object ) { } }

implementation: return Integer . toHexString ( System . identityHashCode ( object ) ) . toUpperCase ( ) ;


signature:
public class PropertyUpdate { /** * Adds a remove to the given propertyupdate and returns an editor on
 * its prop .
 * @ return an editor on a new prop */
public Prop addRemove ( ) { } }

implementation:
Element remove = appendChild ( root , "remove" ) ; // $ NON - NLS - 1 $
Element prop = appendChild ( remove , "prop" ) ; // $ NON - NLS - 1 $
Prop result = null ; try { result = new Prop ( prop ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; // $ NON - NLS - 1 $
} return result ;


signature:
public class PropertyUpdate { /** * Adds a set to the given propertyupdate and returns an editor on its
 * prop .
 * @ return an editor on a new prop */
public Prop addSet ( ) { } }

implementation:
Element set = appendChild ( root , "set" ) ; // $ NON - NLS - 1 $
Element prop = appendChild ( set , "prop" ) ; // $ NON - NLS - 1 $
try { return new Prop ( prop ) ; } catch ( MalformedElementException e ) { Assert . isTrue ( false , Policy . bind ( "assert.internalError" ) ) ; // $ NON - NLS - 1 $
return null ; // Never reached .
}