signature:
public class WrapperQueue { /** * { @ inheritDoc } */
public void accept ( Object owner , Object o ) { } }

implementation:
// Look up the element wrapper record for the element to be accepted .
RequeueElementWrapper < E > record = requeuedElementMap . get ( o ) ; if ( record != null ) { // If running in a transaction , create an accept operation to accept the item only upon commit of the
// transaction .
if ( transactional ) { record . state = AcquireState . Accepted ; txMethod . requestWriteOperation ( new AcceptRecord ( record ) ) ; } else { requeuedElementMap . remove ( o ) ; requeue . remove ( record ) ; } }


signature:
public class WrapperQueue { /** * { @ inheritDoc } */
public E take ( ) throws InterruptedException { } }

implementation: if ( ! isBlockingQueue ) { throw new UnsupportedOperationException ( "This operation is only supported on blocking queues." ) ; } return ( ( java . util . concurrent . BlockingQueue < E > ) queue ) . take ( ) ;


signature:
public class WrapperQueue { /** * { @ inheritDoc } */
public int drainTo ( Collection < ? super E > c ) { } }

implementation: if ( ! isBlockingQueue ) { throw new UnsupportedOperationException ( "This operation is only supported on blocking queues." ) ; } return ( ( java . util . concurrent . BlockingQueue < E > ) queue ) . drainTo ( c ) ;


signature:
public class WrapperQueue { /** * { @ inheritDoc } */
public boolean offer ( E o , long timeout , TimeUnit unit ) throws InterruptedException { } }

implementation: if ( ! isBlockingQueue ) { throw new UnsupportedOperationException ( "This operation is only supported on blocking queues." ) ; } return ( ( java . util . concurrent . BlockingQueue < E > ) queue ) . offer ( o , timeout , unit ) ;


signature:
public class WrapperQueue { /** * { @ inheritDoc } */
public void put ( E o ) throws InterruptedException { } }

implementation: if ( ! isBlockingQueue ) { throw new UnsupportedOperationException ( "This operation is only supported on blocking queues." ) ; } ( ( java . util . concurrent . BlockingQueue < E > ) queue ) . put ( o ) ;


signature:
public class WrapperQueue { /** * { @ inheritDoc } */
public int remainingCapacity ( ) { } }

implementation: if ( ! isBlockingQueue ) { throw new UnsupportedOperationException ( "This operation is only supported on blocking queues." ) ; } return ( ( java . util . concurrent . BlockingQueue < E > ) queue ) . remainingCapacity ( ) ;


signature:
public class WrapperQueue { /** * Places an element onto the requeue buffer .
 * @ param element The element to place onto the requeue buffer . */
private void requeue ( E element ) { } }

implementation: RequeueElementWrapper < E > record = new RequeueElementWrapper < E > ( element ) ; requeue . add ( record ) ; requeuedElementMap . put ( element , record ) ;


signature:
public class WrapperQueue { /** * Places an element onto the requeue buffer , in the acquired state by the specified owner .
 * @ param element The element to place onto the requeue buffer .
 * @ param owner The owner of the acquired element .
 * @ param acquired The acquired state to set on the element in the requeue .
 * @ return The requeue element wrapper for the requeued element . */
private RequeueElementWrapper < E > requeue ( E element , Object owner , AcquireState acquired ) { } }

implementation: RequeueElementWrapper < E > record = new RequeueElementWrapper < E > ( element ) ; record . state = acquired ; record . owner = owner ; requeue . add ( record ) ; requeuedElementMap . put ( element , record ) ; return record ;


signature:
public class WrapperQueue { /** * Atomically adds to the size and count , if the queue is running in atomic counting mode , or sizeable mode and the
 * element is sizeable .
 * @ param record The record to update the size and count for . */
private void incrementSizeAndCount ( E record ) { } }

implementation:
// Update the count for atomically counted queues .
if ( atomicallyCounted ) { count . incrementAndGet ( ) ; } // Update the size for sizeable elements and sizeable queues .
if ( sizeable && ( record instanceof Sizeable ) ) { dataSize . addAndGet ( ( ( Sizeable ) record ) . sizeof ( ) ) ; } else if ( sizeable ) { dataSize . incrementAndGet ( ) ; }


signature:
public class WrapperQueue { /** * Atomically subtracts from the size and count , if the queue is running in atomic counting mode , or sizeable mode
 * and the element is sizeable .
 * @ param record The record to update the size and count for . */
private void decrementSizeAndCount ( E record ) { } }

implementation:
// Update the count for atomically counted queues .
if ( atomicallyCounted ) { count . decrementAndGet ( ) ; } // Update the size for sizeable elements and sizeable queues .
if ( sizeable && ( record instanceof Sizeable ) ) { long recordSize = - ( ( Sizeable ) record ) . sizeof ( ) ; long oldSize = dataSize . getAndAdd ( recordSize ) ; long newSize = oldSize + recordSize ; signalOnSizeThresholdCrossing ( oldSize , newSize ) ; } else if ( sizeable ) { long oldSize = dataSize . getAndDecrement ( ) ; long newSize = oldSize - 1 ; signalOnSizeThresholdCrossing ( oldSize , newSize ) ; }


signature:
public class WrapperQueue { /** * Signals the signallable resource if the size crosses a threshold boundary in a downward direction .
 * @ param oldSize The old size .
 * @ param newSize The new size . */
private void signalOnSizeThresholdCrossing ( long oldSize , long newSize ) { } }

implementation: if ( signalable != null ) { if ( ( oldSize >= lowWaterSizeThreshold ) && ( newSize < lowWaterSizeThreshold ) ) { signalable . signalAll ( ) ; } else if ( ( oldSize >= highWaterSizeThreshold ) && ( newSize < highWaterSizeThreshold ) ) { signalable . signal ( ) ; } }


signature:
public class SimpleContext { /** * Retrieves the named object . If name is empty , returns a new instance of this context ( which represents the same
 * naming context as this context , but its environment may be modified independently and it may be accessed
 * concurrently ) .
 * @ param name The name to look up .
 * @ return The object associated with the name , if there is one .
 * @ throws NamingException If the name cannot be found in the context . */
public Object lookup ( String name ) throws NamingException { } }

implementation:
if ( "" . equals ( name ) ) { // Asking to look up this context itself . Create and return
// a new instance with its own independent environment .
return ( new SimpleContext ( myEnv ) ) ; } Object answer = bindings . get ( name ) ; if ( answer == null ) { throw new NameNotFoundException ( name + " not found" ) ; } return answer ;


signature:
public class SimpleContext { /** * Binds a name to an object . All intermediate contexts and the target context ( that named by all but terminal
 * atomic component of the name ) must already exist .
 * @ param name The name to bind ; may not be empty .
 * @ param obj The object to bind ; possibly null .
 * @ throws NamingException If the name already exists . */
public void bind ( String name , Object obj ) throws NamingException { } }

implementation: if ( "" . equals ( name ) ) { throw new InvalidNameException ( "Cannot bind empty name" ) ; } if ( bindings . get ( name ) != null ) { throw new NameAlreadyBoundException ( "Use rebind to override" ) ; } bindings . put ( name , obj ) ;


signature:
public class SimpleContext { /** * Binds a name to an object . All intermediate contexts and the target context ( that named by all but terminal
 * atomic component of the name ) must already exist .
 * @ param name The name to bind ; may not be empty .
 * @ param obj The object to bind ; possibly null .
 * @ throws NamingException If the name already exists or is illegal . */
public void bind ( Name name , Object obj ) throws NamingException { } }

implementation:
// Flat namespace ; no federation ; just call string version
bind ( name . toString ( ) , obj ) ;


signature:
public class SimpleContext { /** * Binds a name to an object , overwriting any existing binding . All intermediate contexts and the target context
 * ( that named by all but terminal atomic component of the name ) must already exist .
 * < p / > If the object is a DirContext , any existing attributes associated with the name are replaced with those of
 * the object . Otherwise , any existing attributes associated with the name remain unchanged .
 * @ param name The name to bind ; may not be empty .
 * @ param obj The object to bind ; possibly null .
 * @ throws NamingException If the name is illegal . */
public void rebind ( String name , Object obj ) throws NamingException { } }

implementation: if ( "" . equals ( name ) ) { throw new InvalidNameException ( "Cannot bind empty name" ) ; } bindings . put ( name , obj ) ;


signature:
public class SimpleContext { /** * Unbinds the named object . Removes the terminal atomic name in name from the target context - - that named by all but
 * the terminal atomic part of name .
 * < p / > This method is idempotent . It succeeds even if the terminal atomic name is not bound in the target context ,
 * but throws NameNotFoundException if any of the intermediate contexts do not exist .
 * < p / > Any attributes associated with the name are removed . Intermediate contexts are not changed .
 * @ param name The name to unbind .
 * @ throws NamingException If the name is illegal , or intermediate contexts do not exist . */
public void unbind ( String name ) throws NamingException { } }

implementation: if ( "" . equals ( name ) ) { throw new InvalidNameException ( "Cannot unbind empty name" ) ; } bindings . remove ( name ) ;


signature:
public class SimpleContext { /** * Binds a new name to the object bound to an old name , and unbinds the old name . Both names are relative to this
 * context . Any attributes associated with the old name become associated with the new name . Intermediate contexts
 * of the old name are not changed .
 * @ param oldname The name of the existing binding ; may not be empty .
 * @ param newname The new name of the binding ; may not be empty .
 * @ throws NamingException If newname is bound , oldname cannot be found or one of the names is illegal . */
public void rename ( String oldname , String newname ) throws NamingException { } }

implementation:
if ( "" . equals ( oldname ) || "" . equals ( newname ) ) { throw new InvalidNameException ( "Cannot rename empty name" ) ; } // Check if new name exists
if ( bindings . get ( newname ) != null ) { throw new NameAlreadyBoundException ( newname + " is already bound" ) ; } // Check if old name is bound
Object oldBinding = bindings . remove ( oldname ) ; if ( oldBinding == null ) { throw new NameNotFoundException ( oldname + " not bound" ) ; } bindings . put ( newname , oldBinding ) ;


signature:
public class SimpleContext { /** * Binds a new name to the object bound to an old name , and unbinds the old name . Both names are relative to this
 * context . Any attributes associated with the old name become associated with the new name . Intermediate contexts
 * of the old name are not changed .
 * @ param oldname The name of the existing binding ; may not be empty .
 * @ param newname The new name of the binding ; may not be empty .
 * @ throws NamingException If newname is bound , oldname cannot be found or one of the names is illegal . */
public void rename ( Name oldname , Name newname ) throws NamingException { } }

implementation:
// Flat namespace ; no federation ; just call string version
rename ( oldname . toString ( ) , newname . toString ( ) ) ;


signature:
public class SimpleContext { /** * Enumerates the names bound in the named context , along with the class names of objects bound to them . The
 * contents of any subcontexts are not included . If a binding is added to or removed from this context , its effect
 * on an enumeration previously returned is undefined .
 * @ param name The name of the context to list .
 * @ return An enumeration of the names and class names of the bindings in this context . Each element of the
 * enumeration is of type NameClassPair .
 * @ throws NamingException If the context is not known . */
public NamingEnumeration list ( String name ) throws NamingException { } }

implementation:
if ( "" . equals ( name ) ) { // listing this context
return new FlatNames ( bindings . keys ( ) ) ; } // Perhaps ` name ' names a context
Object target = lookup ( name ) ; if ( target instanceof Context ) { return ( ( Context ) target ) . list ( "" ) ; } throw new NotContextException ( name + " cannot be listed" ) ;


signature:
public class SimpleContext { /** * Enumerates the names bound in the named context , along with the objects bound to them . The contents of any
 * subcontexts are not included .
 * < p / > If a binding is added to or removed from this context , its effect on an enumeration previously returned is
 * undefined .
 * @ param name The name of the context to list .
 * @ return An enumeration of the bindings in this context . Each element of the enumeration is of type Binding .
 * @ throws NamingException If the context is not known . */
public NamingEnumeration listBindings ( String name ) throws NamingException { } }

implementation:
if ( "" . equals ( name ) ) { // listing this context
return new FlatBindings ( bindings . keys ( ) ) ; } // Perhaps ` name ' names a context
Object target = lookup ( name ) ; if ( target instanceof Context ) { return ( ( Context ) target ) . listBindings ( "" ) ; } throw new NotContextException ( name + " cannot be listed" ) ;


signature:
public class SimpleContext { /** * Composes the name of this context with a name relative to this context . Given a name ( name ) relative to this
 * context , and the name ( prefix ) of this context relative to one of its ancestors , this method returns the
 * composition of the two names using the syntax appropriate for the naming system ( s ) involved . That is , if name
 * names an object relative to this context , the result is the name of the same object , but relative to the ancestor
 * context . None of the names may be null .
 * < p / > For example , if this context is named " wiz . com " relative to the initial context , then
 * < pre >
 * composeName ( " east " , " wiz . com " )
 * < / pre >
 * < p / > might return " east . wiz . com " . If instead this context is named " org / research " , then
 * < pre >
 * composeName ( " user / jane " , " org / research " )
 * < / pre >
 * < p / > might return " org / research / user / jane " while
 * < pre >
 * composeName ( " user / jane " , " research " )
 * < / pre >
 * < p / > returns " research / user / jane " .
 * @ param name A name relative to this context .
 * @ param prefix The name of this context relative to one of its ancestors .
 * @ return The composition of prefix and name .
 * @ throws NamingException If a naming exception is encountered . */
public String composeName ( String name , String prefix ) throws NamingException { } }

implementation: Name result = composeName ( new CompositeName ( name ) , new CompositeName ( prefix ) ) ; return result . toString ( ) ;


signature:
public class SimpleContext { /** * Adds a new environment property to the environment of this context . If the property already exists , its value is
 * overwritten . See class description for more details on environment properties .
 * @ param propName The name of the property .
 * @ param propVal The value of the property .
 * @ return The previous value of the property , or null if the property was not in the environment before . */
public Object addToEnvironment ( String propName , Object propVal ) { } }

implementation: if ( myEnv == null ) { myEnv = new Hashtable ( 5 , 0.75f ) ; } return myEnv . put ( propName , propVal ) ;


signature:
public class SimpleContext { /** * Removes an environment property from the environment of this context . See class description for more details on
 * environment properties .
 * @ param propName The name of the property to remove .
 * @ return The previous value of the property , or null if the property was not in the environment before . */
public Object removeFromEnvironment ( String propName ) { } }

implementation: if ( myEnv == null ) { return null ; } return myEnv . remove ( propName ) ;


signature:
public class Sizeof { /** * Repeatedly runs the garbage collector and finalization method of the JVM runtime system until the used memory
 * count becomes stable or 500 iterations occur , whichever happens soonest . If other threads are active then this
 * method is not likely to work as the used memory count will continually be changing . */
private static void runGCTillStable ( ) { } }

implementation:
// Possibly add another iteration in here to run this whole method 3 or 4 times .
long usedMem1 = usedMemory ( ) ; long usedMem2 = Long . MAX_VALUE ; // Repeatedly garbage collection until the used memory count becomes stable , or 500 iterations occur .
for ( int i = 0 ; ( usedMem1 < usedMem2 ) && ( i < 500 ) ; i ++ ) { // Force finalisation of all object pending finalisation .
RUNTIME . runFinalization ( ) ; // Return unused memory to the heap .
RUNTIME . gc ( ) ; // Allow other threads to run .
Thread . currentThread ( ) . yield ( ) ; // Keep the old used memory count from the last iteration and get a fresh reading .
usedMem2 = usedMem1 ; usedMem1 = usedMemory ( ) ; }


signature:
public class Parser { /** * This is the high - level rule at some scope ( either the root document or within a rule set / mixin ) .
 * Future : Imports */
Rule Scope ( ) { } }

implementation: return Sequence ( push ( new ScopeNode ( ) ) , ZeroOrMore ( FirstOf ( Declaration ( ) , MediaQuery ( ) , RuleSet ( ) , MixinReference ( ) , Sequence ( push ( new WhiteSpaceCollectionNode ( ) ) , Sp1Nodes ( ) ) ) , peek ( 1 ) . addChild ( pop ( ) ) ) ) ;


signature:
public class Parser { /** * media type name Optional ( and " ( " Css property " ) " ) */
Rule MediaType ( ) { } }

implementation: return Sequence ( push ( new MediaTypeNode ( ) ) , MediaTypeName ( ) , peek ( 1 ) . addChild ( pop ( ) ) , FirstOf ( Sequence ( MediaTypeRestriction ( ) , peek ( 1 ) . addChild ( pop ( ) ) ) , Optional ( Ws0 ( ) , push ( new SpacingNode ( " " ) ) , peek ( 1 ) . addChild ( pop ( ) ) ) ) , peek ( 1 ) . addChild ( pop ( ) ) ) ;


signature:
public class Parser { /** * Sequence ( Whitespace " and " Whitespace " ( " Css Property " ) " ) */
Rule MediaTypeRestriction ( ) { } }

implementation: return Sequence ( push ( new MediaTypeRestriction ( ) ) , Ws0 ( ) , "and" , Ws0 ( ) , '(' , Sequence ( Ident ( ) , peek ( ) . addChild ( new SimpleNode ( match ( ) ) ) , ':' , peek ( ) . addChild ( new SimpleNode ( ":" ) ) , Optional ( Ws0 ( ) ) , peek ( ) . addChild ( new SpacingNode ( " " ) ) , ExpressionPhrase ( ) ) , ')' , peek ( 1 ) . addChild ( pop ( ) ) ) ;


signature:
public class Parser { /** * " only " Whitespace */
Rule OnlyIndicator ( ) { } }

implementation: return Sequence ( "only" , peek ( ) . addChild ( new SimpleNode ( match ( ) ) ) , peek ( ) . addChild ( new SimpleNode ( " " ) ) , Ws0 ( ) ) ;


signature:
public class Parser { /** * ( Selectors ' { ' Ws0 / Class Ws0 Parameters Ws0 ' { ' Ws0 ) Scope Ws0 ' } ' Ws0
 * Ex : div , . class , body > p { . . . }
 * Future : Hidden */
Rule RuleSet ( ) { } }

implementation:
return Sequence ( FirstOf ( // Standard CSS rule set
Sequence ( SelectorGroup ( ) , push ( new RuleSetNode ( pop ( ) ) ) , '{' , Scope ( ) , peek ( 1 ) . addChild ( pop ( ) ) , Ws0 ( ) ) , // Mixin rule set , with possible arguments
Sequence ( ClassSelectorGroup ( ) , push ( new RuleSetNode ( pop ( ) ) ) , Ws0 ( ) , Parameters ( ) , Ws0 ( ) , '{' , Scope ( ) , peek ( 1 ) . addChild ( pop ( ) ) , peek ( 1 ) . addChild ( pop ( ) ) , Ws0 ( ) ) ) , '}' , Ws0Nodes ( ) ) ;


signature:
public class Parser { /** * ' ( ' Parameter Ws0 ( ' , ' Ws0 Parameter ) * ' ) ' */
Rule Parameters ( ) { } }

implementation: return Sequence ( '(' , Parameter ( ) , push ( new ParametersNode ( pop ( ) ) ) , Ws0 ( ) , ZeroOrMore ( ',' , Ws0 ( ) , Parameter ( ) , peek ( 1 ) . addChild ( pop ( ) ) ) , ')' , push ( new ScopeNode ( pop ( ) ) ) ) ;


signature:
public class Parser { /** * Variable Ws0 ' : ' Ws0 ExpressionPhrase */
Rule Parameter ( ) { } }

implementation: return Sequence ( Variable ( ) , push ( new VariableDefinitionNode ( match ( ) ) ) , peek ( ) . setVisible ( ! isParserTranslationEnabled ( ) ) , Ws0 ( ) , ':' , Ws0 ( ) , ExpressionPhrase ( ) , peek ( 1 ) . addChild ( new ExpressionGroupNode ( pop ( ) ) ) ) ;


signature:
public class Parser { /** * SelectorGroup ' ; ' Ws0
 * / Class Arguments ' ; ' Ws0 */
@ MemoMismatches Rule MixinReference ( ) { } }

implementation:
Var < String > name = new Var < String > ( ) ; return FirstOf ( // No arguments , reference an existing rule set ' s properties
Sequence ( SelectorGroup ( ) , ';' , resolveMixinReference ( NodeTreeUtils . getFirstChild ( ( InternalNode ) pop ( ) , SelectorNode . class ) . toString ( ) , null ) , Ws0Nodes ( ) ) , // Call a mixin , passing along some arguments
Sequence ( Class ( ) , name . set ( match ( ) ) , Arguments ( ) , Ws0 ( ) , ';' , resolveMixinReference ( name . get ( ) , ( ArgumentsNode ) pop ( ) ) , Ws0Nodes ( ) ) ) ;


signature:
public class Parser { /** * Selector Ws0 ( ' , ' Ws0 Selector ) * Ws0 */
@ MemoMismatches Rule SelectorGroup ( ) { } }

implementation: return Sequence ( Selector ( ) , push ( new SelectorGroupNode ( pop ( ) ) ) , Ws0Nodes ( ) , ZeroOrMore ( ',' , Ws0Nodes ( ) , Selector ( ) , peek ( 1 ) . addChild ( pop ( ) ) ) , Ws0Nodes ( ) ) ;


signature:
public class Parser { /** * SimpleSelector ( Combinator SimpleSelector ) * */
Rule Selector ( ) { } }

implementation:
Var < SelectorSegmentNode > selectorSegmentNode = new Var < SelectorSegmentNode > ( ) ; return Sequence ( push ( new SelectorNode ( ) ) , // First selector segment may have a combinator ( with nested rule sets )
Optional ( SymbolCombinator ( ) ) , selectorSegmentNode . set ( new SelectorSegmentNode ( match ( ) ) ) , SimpleSelector ( selectorSegmentNode ) , selectorSegmentNode . get ( ) . setSimpleSelector ( match ( ) ) , peek ( ) . addChild ( selectorSegmentNode . getAndClear ( ) ) , // Additional selector segments must have a combinator
ZeroOrMore ( Combinator ( ) , selectorSegmentNode . set ( new SelectorSegmentNode ( match ( ) ) ) , SimpleSelector ( selectorSegmentNode ) , selectorSegmentNode . get ( ) . setSimpleSelector ( match ( ) ) , peek ( ) . addChild ( selectorSegmentNode . getAndClear ( ) ) ) ) ;


signature:
public class Parser { /** * ( Ident / Variable ) Ws0 ' : ' Ws0 ExpressionPhrase ( Ws0 ' , ' Ws0 ExpressionPhrase ) * Sp0 ( ' ; ' / Ws0 & ' } ' )
 * / Ident Ws0 ' : ' Ws0 ' ; '
 * Ex : @ my - var : 12px ; height : 100 % ; */
Rule Declaration ( ) { } }

implementation:
return FirstOf ( Sequence ( FirstOf ( Sequence ( PropertyName ( ) , push ( new PropertyNode ( match ( ) ) ) ) , Sequence ( Variable ( ) , push ( new VariableDefinitionNode ( match ( ) ) ) , peek ( ) . setVisible ( ! isParserTranslationEnabled ( ) ) ) ) , Ws0 ( ) , ':' , Ws0 ( ) , push ( new ExpressionGroupNode ( ) ) , ExpressionPhrase ( ) , peek ( 1 ) . addChild ( pop ( ) ) , ZeroOrMore ( Ws0 ( ) , ',' , Ws0Nodes ( ) , ExpressionPhrase ( ) , peek ( 1 ) . addChild ( pop ( ) ) ) , Sp0 ( ) , FirstOf ( ';' , Sequence ( Ws0 ( ) , Test ( '}' ) ) ) , peek ( 1 ) . addChild ( pop ( ) ) ) , // Empty rules are ignored
Sequence ( Ident ( ) , push ( new PlaceholderNode ( ) ) , Ws0 ( ) , ':' , Ws0 ( ) , ';' ) ) ;


signature:
public class Parser { /** * Expression ( Operator Expression ) + Future : Operations
 * / Expression ( Ws1 Expression ) * Important ? */
Rule ExpressionPhrase ( ) { } }

implementation:
// Space - separated expressions
return Sequence ( Expression ( ) , push ( new ExpressionPhraseNode ( pop ( ) ) ) , ZeroOrMore ( Ws1 ( ) , Expression ( ) , peek ( 1 ) . addChild ( pop ( ) ) ) , Optional ( Ws0 ( ) , Important ( ) , peek ( 1 ) . addChild ( pop ( ) ) ) ) ;


signature:
public class Parser { /** * Ident Arguments */
Rule Function ( ) { } }

implementation: return Sequence ( Ident ( ) , push ( new FunctionNode ( match ( ) ) ) , Arguments ( ) , peek ( 1 ) . addChild ( pop ( ) ) ) ;


signature:
public class Parser { /** * ' ( ' Ws0 ExpressionPhrase Ws0 ( ' , ' Ws0 ExpressionPhrase Ws0 ) * ' ) ' / ' ( ' Ws0 ' ) ' */
Rule Arguments ( ) { } }

implementation: return FirstOf ( Sequence ( Ws0 ( ) , '(' , Ws0 ( ) , ExpressionPhrase ( ) , push ( new ArgumentsNode ( new ExpressionGroupNode ( pop ( ) ) ) ) , Ws0 ( ) , ZeroOrMore ( ',' , Ws0 ( ) , ExpressionPhrase ( ) , peek ( 1 ) . addChild ( new ExpressionGroupNode ( pop ( ) ) ) , Ws0 ( ) ) , ')' ) , Sequence ( Ws0 ( ) , '(' , Ws0 ( ) , ')' , push ( new ArgumentsNode ( ) ) ) ) ;


signature:
public class Parser { /** * Ex : progid : DXImageTransform . Microsoft . gradient ( startColorstr = @ lightColor , endColorstr = @ darkColor ) */
Rule FilterFunction ( ) { } }

implementation: return Sequence ( Sequence ( "progid:" , OneOrMore ( FirstOf ( '.' , Ident ( ) ) ) ) , push ( new FunctionNode ( match ( ) ) ) , FilterArguments ( ) , peek ( 1 ) . addChild ( pop ( ) ) ) ;


signature:
public class Parser { /** * ' ( ' Ws0 FilterArgument Ws0 ( ' , ' Ws0 FilterArgument Ws0 ) * ' ) ' / ' ( ' Ws0 ' ) ' */
Rule FilterArguments ( ) { } }

implementation: return FirstOf ( Sequence ( '(' , Ws0 ( ) , FilterArgument ( ) , push ( new ArgumentsNode ( pop ( ) ) ) , Ws0 ( ) , ZeroOrMore ( ',' , Ws0 ( ) , FilterArgument ( ) , peek ( 1 ) . addChild ( pop ( ) ) , Ws0 ( ) ) , ')' ) , Sequence ( '(' , Ws0 ( ) , ')' , push ( new ArgumentsNode ( ) ) ) ) ;


signature:
public class Parser { /** * Ex : startColorstr = @ lightColor */
Rule FilterArgument ( ) { } }

implementation: return Sequence ( Ident ( ) , push ( new FilterArgumentNode ( match ( ) ) ) , Ws0 ( ) , '=' , Ws0 ( ) , Value ( ) , peek ( 1 ) . addChild ( pop ( ) ) ) ;


signature:
public class Parser { /** * Any token used as a value in an expression
 * Future : Accessors */
Rule Value ( ) { } }

implementation: return FirstOf ( Keyword ( ) , Literal ( ) , Function ( ) , VariableReference ( ) , URL ( ) , Font ( ) , AlphaFilter ( ) , ExpressionFunction ( ) , FilterFunction ( ) ) ;


signature:
public class Parser { /** * ' url ( ' ( String / [ - _ % $ / . & = : ; # + ? Alphanumeric ] + ) ' ) ' */
Rule URL ( ) { } }

implementation: return Sequence ( Sequence ( "url(" , Ws0 ( ) , FirstOf ( String ( ) , OneOrMore ( FirstOf ( AnyOf ( "-_%$/.&=:;#+?" ) , Alphanumeric ( ) ) ) ) , Ws0 ( ) , ')' ) , push ( new SimpleNode ( match ( ) ) ) ) ;


signature:
public class Parser { /** * ' alpha ( ' Ws0 ' opacity ' Ws0 ' = ' Ws0 Digit1 Ws0 ' ) ' */
Rule AlphaFilter ( ) { } }

implementation: return Sequence ( Sequence ( "alpha(" , Ws0 ( ) , "opacity" , Ws0 ( ) , '=' , Ws0 ( ) , Digit1 ( ) , Ws0 ( ) , ')' ) , push ( new SimpleNode ( match ( ) ) ) ) ;


signature:
public class Parser { /** * ' expression ( ' ( ! ( ' ) ' Ws0 [ ; } ] ) . ) * ' ) ; ' */
Rule ExpressionFunction ( ) { } }

implementation: return Sequence ( Sequence ( "expression(" , ZeroOrMore ( TestNot ( ')' , Ws0 ( ) , AnyOf ( ";}" ) ) , ANY ) , ')' ) , push ( new SimpleNode ( match ( ) ) ) ) ;


signature:
public class Parser { /** * Ident & Delimiter
 * Ex : blue , small , normal */
Rule Keyword ( ) { } }

implementation: return Sequence ( Sequence ( Ident ( ) , Test ( Delimiter ( ) ) ) , push ( new SimpleNode ( match ( ) ) ) ) ;


signature:
public class Parser { /** * Tokens that don ' t need to evaluated */
Rule Literal ( ) { } }

implementation: return Sequence ( FirstOf ( Color ( ) , MultiDimension ( ) , Dimension ( ) , String ( ) ) , push ( new SimpleNode ( match ( ) ) ) ) ;


signature:
public class Parser { /** * Alpha [ - Alphanumeric ] * & Delimiter / String */
Rule Font ( ) { } }

implementation: return Sequence ( FirstOf ( Sequence ( Alpha ( ) , ZeroOrMore ( FirstOf ( '-' , Alphanumeric ( ) ) ) , Test ( Delimiter ( ) ) ) , String ( ) ) , push ( new SimpleNode ( match ( ) ) ) ) ;


signature:
public class Parser { /** * Ex : ' hello ' / " hello " */
Rule String ( ) { } }

implementation: return FirstOf ( Sequence ( '\'' , ZeroOrMore ( TestNot ( '\'' ) , ANY ) , '\'' ) , Sequence ( '"' , ZeroOrMore ( TestNot ( '"' ) , ANY ) , '"' ) ) ;


signature:
public class Parser { /** * ' - ' ? Digit * ' . ' Digit + / ' - ' ? Digit + */
Rule Number ( ) { } }

implementation: return FirstOf ( Sequence ( Optional ( '-' ) , Digit0 ( ) , '.' , Digit1 ( ) ) , Sequence ( Optional ( '-' ) , Digit1 ( ) ) ) ;


signature:
public class Parser { /** * Ex : 0099dd / 09d */
Rule RGB ( ) { } }

implementation: return FirstOf ( Sequence ( Hex ( ) , Hex ( ) , Hex ( ) , Hex ( ) , Hex ( ) , Hex ( ) ) , Sequence ( Hex ( ) , Hex ( ) , Hex ( ) ) ) ;


signature:
public class Parser { /** * ' \ ' [ 0-9a - fA - F ] { 1,6 } wc ? */
Rule Unicode ( ) { } }

implementation: return Sequence ( '\\' , Hex ( ) , Optional ( Hex ( ) , Optional ( Hex ( ) , Optional ( Hex ( ) , Optional ( Hex ( ) , Optional ( Hex ( ) ) ) ) ) ) , Optional ( Whitespace ( ) ) ) ;


signature:
public class Parser { /** * unicode | ' \ ' [ ^ \ x0 - \ x1F ] */
Rule Escape ( ) { } }

implementation:
return Sequence ( Test ( '\\' ) , // for performance
FirstOf ( Unicode ( ) , Sequence ( '\\' , Sequence ( TestNot ( CharRange ( ( char ) 0 , ( char ) 31 ) ) , ANY ) ) ) ) ;


signature:
public class Parser { /** * Locates the referenced mixin in one of the scope nodes on the stack . If found , the mixin ' s
 * scope is cloned and placed onto the stack in place of the mixin reference . Additionally ,
 * any arguments are applied to the mixin ' s scope . */
boolean resolveMixinReference ( String name , ArgumentsNode arguments ) { } }

implementation:
if ( ! isParserTranslationEnabled ( ) ) { return push ( new PlaceholderNode ( new SimpleNode ( name ) ) ) ; } // Walk down the stack , looking for a scope node that knows about a given rule set
for ( Node node : getContext ( ) . getValueStack ( ) ) { if ( ! ( node instanceof ScopeNode ) ) { continue ; } ScopeNode scope = ( ScopeNode ) node ; RuleSetNode ruleSet = scope . getRuleSet ( name ) ; if ( ruleSet == null ) { continue ; } // Get the scope of the rule set we located and call it as a mixin
ScopeNode ruleSetScope = NodeTreeUtils . getFirstChild ( ruleSet , ScopeNode . class ) . callMixin ( name , arguments ) ; return push ( ruleSetScope ) ; } // Record error location
throw new UndefinedMixinException ( name ) ;


signature:
public class Parser { /** * Looks for a variable definition that matches the reference in the scope nodes on the stack .
 * If found , a reference node that can repeat this lookup later is placed on the stack , not the
 * current value itself . This is done because the value may change if the variable reference is
 * inside a mixin . */
boolean pushVariableReference ( String name ) { } }

implementation:
if ( ! isParserTranslationEnabled ( ) ) { return push ( new SimpleNode ( name ) ) ; } // Walk down the stack , looking for a scope node that knows about a given variable
for ( Node node : getContext ( ) . getValueStack ( ) ) { if ( ! ( node instanceof ScopeNode ) ) { continue ; } // Ensure that the variable exists
ScopeNode scope = ( ScopeNode ) node ; if ( ! scope . isVariableDefined ( name ) ) { continue ; } return push ( new VariableReferenceNode ( name ) ) ; } // Record error location
throw new UndefinedVariableException ( name ) ;


signature:
public class LoggerUtil { /** * 记录完善的异常日志信息 ( 包括堆栈信息 )
 * @ param e Exception */
public static String recordStackTraceMsg ( Exception e ) { } }

implementation: StringWriter stringWriter = new StringWriter ( ) ; PrintWriter writer = new PrintWriter ( stringWriter ) ; e . printStackTrace ( writer ) ; StringBuffer buffer = stringWriter . getBuffer ( ) ; return buffer . toString ( ) ;


signature:
public class TextTableImpl { /** * Updates the maximum row height for a row of the data table .
 * @ param row The row to update .
 * @ param height The max height reached . */
public void setMaxRowHeight ( int row , int height ) { } }

implementation: Integer previousValue = maxRowSizes . get ( row ) ; if ( previousValue == null ) { maxRowSizes . put ( row , height ) ; } else if ( previousValue < height ) { maxRowSizes . put ( row , height ) ; }


signature:
public class TextTableImpl { /** * { @ inheritDoc } */
public String put ( Integer col , Integer row , String value ) { } }

implementation: maxColumns = ( col > maxColumns ) ? col : maxColumns ; maxRows = ( row > maxRows ) ? row : maxRows ; updateMaxColumnWidth ( col , value . length ( ) ) ; String result = grid . put ( ( long ) col , ( long ) row , value ) ; updateListeners ( col , row ) ; return result ;


signature:
public class TextTableImpl { /** * { @ inheritDoc } */
public String get ( Integer col , Integer row ) { } }

implementation: return grid . get ( ( long ) col , ( long ) row ) ;


signature:
public class TextTableImpl { /** * { @ inheritDoc } */
public String remove ( Integer col , Integer row ) { } }

implementation: String result = grid . remove ( ( long ) col , ( long ) row ) ; updateListeners ( col , row ) ; return result ;


signature:
public class TextTableImpl { /** * { @ inheritDoc } */
public int getMaxColumnSize ( int col ) { } }

implementation: Integer result = maxColumnSizes . get ( col ) ; return ( result == null ) ? 0 : result ;


signature:
public class TextTableImpl { /** * { @ inheritDoc } */
public void labelCell ( String label , int col , int row ) { } }

implementation: cellLabels . put ( label , new Pair < Integer , Integer > ( col , row ) ) ;


signature:
public class TextTableImpl { /** * Notifies all interested listeners of an update to this model . */
protected void updateListeners ( int col , int row ) { } }

implementation: TextTableEvent event = new TextTableEvent ( this , row , col ) ; for ( TextTableListener listener : listeners ) { listener . changedUpdate ( event ) ; }


signature:
public class TextTableImpl { /** * Updates the maximum column width for a column of the data table .
 * @ param column The column to update .
 * @ param width The max width reached . */
private void updateMaxColumnWidth ( int column , int width ) { } }

implementation: Integer previousValue = maxColumnSizes . get ( column ) ; if ( previousValue == null ) { maxColumnSizes . put ( column , width ) ; } else if ( previousValue < width ) { maxColumnSizes . put ( column , width ) ; }


signature:
public class PageAction { /** * Updates the current page or index offset of a paged list in the session scope .
 * < p / > This perform method is the same as the normal perform method but it is called from inside an error wrapper
 * that catches all throwables . The wrapper automatically generates Struts error messages for any Java throwable
 * that may fall through this method .
 * < p / > Implementations should override this method to use the default error handling .
 * @ param mapping The ActionMapping used to select this instance
 * @ param form The optional ActionForm bean for this request ( if any )
 * @ param request The HTTP request .
 * @ param response The HTTP response .
 * @ param errors A struts errors object to write any error messages to .
 * @ return A struts forward to tell struts where to go after this action .
 * @ throws Exception Any exceptions are allowed to fall through to the top level handler . */
public ActionForward executeWithErrorHandling ( ActionMapping mapping , ActionForm form , HttpServletRequest request , HttpServletResponse response , ActionErrors errors ) throws Exception { } }

implementation:
// Get a reference to the session .
HttpSession session = request . getSession ( false ) ; // Extract the page form .
DynaActionForm pageForm = ( DynaActionForm ) form ; log . fine ( "pageForm = " + pageForm ) ; // Get the paged list object from the session .
String listingVarName = pageForm . getString ( VAR_NAME_PARAM ) ; log . fine ( "listingVarName = " + listingVarName ) ; PagedList pagedList = ( PagedList ) session . getAttribute ( listingVarName ) ; // Set its current page .
pagedList . setCurrentPage ( ( Integer ) pageForm . get ( NUMBER_PARAM ) ) ; // Set its index offset if one is specified .
Integer index = ( Integer ) pageForm . get ( INDEX_PARAM ) ; if ( index != null ) { pagedList . setCurrentIndex ( index ) ; } // Forward to the success location .
return mapping . findForward ( SUCCESS_FORWARD ) ;


signature:
public class PrologCompiler { /** * { @ inheritDoc }
 * < p / > Compiles a clause by replacing all free variable occurrences within domain clauses with stack storage
 * locations . The clause is set up as the binding context supplier to these variables . Query clauses are not set up
 * with stack variables , as the query can have its variables bound directly . */
public void compile ( Sentence < Clause > clauseSentence ) throws SourceCodeException { } }

implementation:
Clause clause = clauseSentence . getT ( ) ; PrologCompiledClause result = new PrologCompiledClause ( clause . getHead ( ) , clause . getBody ( ) ) ; // Create stack frame slots for all variables in a program .
if ( ! clause . isQuery ( ) ) { StackVariableTransform stackVariableTransform = new StackVariableTransform ( 0 , result ) ; result = ( PrologCompiledClause ) result . acceptTransformer ( stackVariableTransform ) ; // Set the required stack frame size on the compiled clause .
result . setStackSize ( stackVariableTransform . offset ) ; } // Apply the built - in transformation to map any built - ins to their implementations .
TermTransformer builtInTransformation = new BuiltInExpressionTransform ( interner ) ; result = ( PrologCompiledClause ) result . acceptTransformer ( builtInTransformation ) ; // Return the compiled version of the clause .
if ( clause . isQuery ( ) ) { observer . onQueryCompilation ( result ) ; } else { observer . onCompilation ( result ) ; }


signature:
public class BuiltInExpressionTransform { /** * Applies a built - in replacement transformation to functors . If the functor matches built - in , a
 * { @ link BuiltInFunctor } is created with a mapping to the functors built - in implementation , and the functors
 * arguments are copied into this new functor . If the functor does not match a built - in , it is returned unmodified .
 * @ param functor The functor to attempt to map onto a built - in .
 * @ return The functor umodified , or a { @ link BuiltInFunctor } replacement for it . */
public Functor transform ( Functor functor ) { } }

implementation: FunctorName functorName = interner . getFunctorFunctorName ( functor ) ; if ( builtInExpressions . containsKey ( functorName ) ) { Class < ? extends Functor > builtInExpressionClass = builtInExpressions . get ( functorName ) ; return ReflectionUtils . newInstance ( ReflectionUtils . getConstructor ( builtInExpressionClass , new Class [ ] { Integer . TYPE , Term [ ] . class } ) , new Object [ ] { functor . getName ( ) , functor . getArguments ( ) } ) ; } else { return functor ; }


signature:
public class HeuristicSearchNode { /** * Returns a new node based on a successor of this node . This new node will also be a HeuristicSearchNode .
 * @ param successor The successor state in the search space to create a new node for .
 * @ return A completely new heuristic search node for the successor state . This node will be of the correct
 * class , even for classes that sub - class this one .
 * @ exception SearchNotExhaustiveException If a new node cannot be created . This may happen due to class visibility
 * or class loading problems . */
public HeuristicSearchNode < O , T > makeNode ( Successor successor ) throws SearchNotExhaustiveException { } }

implementation:
HeuristicSearchNode < O , T > node = ( HeuristicSearchNode < O , T > ) super . makeNode ( successor ) ; // Make sure the new node has a reference to the heuristic evaluator
node . heuristic = this . heuristic ; // Compute h for the new node
node . computeH ( ) ; return node ;


signature:
public class BaseAction { /** * Processes the action providing default error handling . Implementation should override this method to provide
 * their own error handling if the default is not to be used .
 * @ param mapping The ActionMapping used to select this instance
 * @ param form The optional ActionForm bean for this request ( if any )
 * @ param request The HTTP request .
 * @ param response The HTTP response .
 * @ return A struts forward to tell struts where to go after this action .
 * @ exception IOException If an input / output error occurs .
 * @ exception ServletException If a servlet exception occurs . */
public ActionForward execute ( ActionMapping mapping , ActionForm form , HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { } }

implementation:
log . fine ( "ActionForward perform(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse): called" ) ; // Build an ActionErrors object to hold any errors that occurr
ActionErrors errors = new ActionErrors ( ) ; // Create reference to the session
HttpSession session = request . getSession ( ) ; // Use a try block to catch any errors that may occur
try { return executeWithErrorHandling ( mapping , form , request , response , errors ) ; } // Catch all exceptions here . This will forward to the error page in the event of
// any exception that falls through to this top level handler .
// Don ' t catch Throwable here as Errors should fall through to the JVM top level and will result in
// termination of the application .
catch ( Exception t ) { log . log ( Level . WARNING , "Caught a Throwable" , t ) ; // Don ' t Forward the error to the error handler to interpret it as a Struts error as the exception will
// automatically be translated by the error page .
// @ todo Could add code here to check if there is a ' error ' forward page defined . If there is then call
// the error handler to translate the throwable into Struts errors and then forward to the ' error ' page .
// This would mean that the error page defined in web . xml would be the default unless an action explicitly
// defined an alternative ' error ' forward .
// handleErrors ( t , errors ) ;
// Save all the error messages in the request so that they will be displayed
// request . setAttribute ( Action . ERROR _ KEY , errors ) ;
// Rethrow the error as a ServletException here to cause forwarding to error page defined in web . xml
throw new WrappedStrutsServletException ( t ) ; }


signature:
public class PreCompiler { /** * { @ inheritDoc } */
public void compile ( Sentence < Clause > sentence ) throws SourceCodeException { } }

implementation: Clause clause = sentence . getT ( ) ; substituteBuiltIns ( clause ) ; initialiseSymbolTable ( clause ) ; topLevelCheck ( clause ) ; if ( observer != null ) { if ( clause . isQuery ( ) ) { observer . onQueryCompilation ( sentence ) ; } else { observer . onCompilation ( sentence ) ; } }


signature:
public class PreCompiler { /** * Substitutes built - ins within a clause , with their built - in definitions .
 * @ param clause The clause to transform . */
private void substituteBuiltIns ( Term clause ) { } }

implementation: TermWalker walk = TermWalkers . positionalWalker ( new BuiltInTransformVisitor ( interner , symbolTable , null , builtInTransform ) ) ; walk . walk ( clause ) ;


signature:
public class PreCompiler { /** * Runs a symbol key traverser over the clause to be compiled , to ensure that all of its terms and sub - terms have
 * their symbol keys initialised .
 * @ param clause The clause to initialise the symbol keys of . */
private void initialiseSymbolTable ( Term clause ) { } }

implementation:
// Run the symbol key traverser over the clause , to ensure that all terms have their symbol keys correctly
// set up .
SymbolKeyTraverser symbolKeyTraverser = new SymbolKeyTraverser ( interner , symbolTable , null ) ; symbolKeyTraverser . setContextChangeVisitor ( symbolKeyTraverser ) ; TermWalker symWalker = new TermWalker ( new DepthFirstBacktrackingSearch < Term , Term > ( ) , symbolKeyTraverser , symbolKeyTraverser ) ; symWalker . walk ( clause ) ;


signature:
public class PreCompiler { /** * Finds and marks all functors within the clause that are considered to be top - level .
 * @ param clause The clause to top - level check . */
private void topLevelCheck ( Term clause ) { } }

implementation: TermWalker walk = TermWalkers . positionalWalker ( new TopLevelCheckVisitor ( interner , symbolTable , null ) ) ; walk . walk ( clause ) ;


signature:
public class Cut { /** * { @ inheritDoc } */
public SizeableLinkedList < WAMInstruction > compileBodyCall ( Functor expression , boolean isFirstBody , boolean isLastBody , boolean chainRule , int permVarsRemaining ) { } }

implementation: SizeableLinkedList < WAMInstruction > instructions = new SizeableLinkedList < WAMInstruction > ( ) ; if ( isFirstBody ) { instructions . add ( new WAMInstruction ( NeckCut ) ) ; } else { Integer cutLevelVarAllocation = ( Integer ) defaultBuiltIn . getSymbolTable ( ) . get ( CutLevelVariable . CUT_LEVEL_VARIABLE . getSymbolKey ( ) , SymbolTableKeys . SYMKEY_ALLOCATION ) ; instructions . add ( new WAMInstruction ( Cut , ( byte ) ( cutLevelVarAllocation & 0xff ) ) ) ; } return instructions ;


signature:
public class Cons { /** * Pretty prints a term relative to the symbol namings provided by the specified interner .
 * @ param interner The interner use to provide symbol names .
 * @ param isFirst < tt > true < / tt > if this is the first cons in a list , < tt > false < / tt > otherwise .
 * @ param printVarName < tt > true < / tt > if the names of bound variables should be printed , < tt > false < / tt > if just the
 * binding without the variable name should be printed .
 * @ param printBindings < tt > true < / tt > if variable binding values should be printed , < tt > false < / tt > if just the
 * variables name without any binding should be printed .
 * @ return A pretty printed string containing the term . */
private String listToString ( VariableAndFunctorInterner interner , boolean isFirst , boolean printVarName , boolean printBindings ) { } }

implementation: String result = "" ; if ( isFirst ) { result += "[" ; } result += arguments [ 0 ] . toString ( interner , printVarName , printBindings ) ; Term consArgument = arguments [ 1 ] . getValue ( ) ; if ( consArgument instanceof Cons ) { result += ", " + ( ( Cons ) consArgument ) . listToString ( interner , false , printVarName , printBindings ) ; } if ( isFirst ) { result += "]" ; } return result ;


signature:
public class SymbolTableImpl { /** * { @ inheritDoc } */
public void clear ( ) { } }

implementation:
// Clea all fields and records from the table .
fieldMap = new LinkedHashMap < L , CircularArrayMap < E > > ( ) ; hashFunction = new SequentialCuckooFunction < CompositeKey < K > > ( ) ;


signature:
public class SymbolTableImpl { /** * { @ inheritDoc } */
public boolean containsKey ( K primaryKey , L secondaryKey ) { } }

implementation:
// Check that the field exists in the table .
CircularArrayMap < E > field = fieldMap . get ( secondaryKey ) ; if ( field == null ) { return false ; } // Check that the symbol exists in the table .
CompositeKey < K > compositeKey = new CompositeKey < K > ( parentSequenceKey , primaryKey ) ; SymbolTableImpl < K , L , E > nextParentScope = parentScope ; while ( true ) { if ( hashFunction . containsKey ( compositeKey ) ) { break ; } if ( nextParentScope != null ) { compositeKey = new CompositeKey ( nextParentScope . parentSequenceKey , primaryKey ) ; nextParentScope = nextParentScope . parentScope ; } else { return false ; } } // Calculate the symbols index in the table , and use it to check if a value for that field exists .
E value = field . get ( hashFunction . apply ( compositeKey ) ) ; return value != null ;


signature:
public class SymbolTableImpl { /** * { @ inheritDoc } */
public E put ( K primaryKey , L secondaryKey , E value ) { } }

implementation:
// Create the field column for the secondary key , if it does not already exist .
CircularArrayMap < E > field = fieldMap . get ( secondaryKey ) ; if ( field == null ) { field = new CircularArrayMap < E > ( DEFAULT_INITIAL_FIELD_SIZE ) ; fieldMap . put ( secondaryKey , field ) ; } // Create the mapping for the symbol if it does not already exist .
Integer index = hashFunction . apply ( new CompositeKey < K > ( parentSequenceKey , primaryKey ) ) ; // Insert the new value for the field into the field map .
E oldValue = field . put ( index , value ) ; count ++ ; return oldValue ;


signature:
public class SymbolTableImpl { /** * { @ inheritDoc } */
public E remove ( K primaryKey , L secondaryKey ) { } }

implementation:
CompositeKey < K > compositeKey = new CompositeKey < K > ( parentSequenceKey , primaryKey ) ; // Check that the symbol exists in the table , and return null if not .
if ( ! hashFunction . containsKey ( compositeKey ) ) { return null ; } // Check that the field for the secondary key exists , and return null if not .
CircularArrayMap < E > field = fieldMap . get ( secondaryKey ) ; if ( field == null ) { return null ; } // Calculate the symbols index in the table , and use it to fetch remove a value for the field if one exists .
E oldValue = field . remove ( hashFunction . apply ( compositeKey ) ) ; // Check if the fields size has been reduced to zero , in which case purge that whole field from the symbol
// table .
if ( field . isEmpty ( ) ) { fieldMap . remove ( secondaryKey ) ; } // Check if an item was really removed from the table , and decrement the size count if so .
if ( oldValue != null ) { count -- ; } return oldValue ;


signature:
public class SymbolTableImpl { /** * { @ inheritDoc } */
public SymbolTable < K , L , E > enterScope ( K key ) { } }

implementation:
// Create an entry in the sequence function for the key , if one does not already exist .
int scopeSequenceKey = hashFunction . apply ( new CompositeKey < K > ( parentSequenceKey , key ) ) ; // Create a new child table for the symbol within this table at depth one greater than this .
return new SymbolTableImpl < K , L , E > ( this , fieldMap , hashFunction , depth , scopeSequenceKey ) ;


signature:
public class SymbolTableImpl { /** * { @ inheritDoc } */
public SymbolKey getSymbolKey ( K key ) { } }

implementation:
// Create an entry in the sequence function for the key , if one does not already exist .
int scopeSequenceKey = hashFunction . apply ( new CompositeKey < K > ( parentSequenceKey , key ) ) ; return new SymbolKeyImpl ( scopeSequenceKey ) ;


signature:
public class SymbolTableImpl { /** * { @ inheritDoc } */
public E get ( SymbolKey key , L secondaryKey ) { } }

implementation:
// Extract the sequence key from the symbol key .
int sequenceKey = ( ( SymbolKeyImpl ) key ) . sequenceKey ; // Check that the field for the secondary key exists , and return null if not .
CircularArrayMap < E > field = fieldMap . get ( secondaryKey ) ; if ( field == null ) { return null ; } // Look up the value directly by its sequence key .
return field . get ( sequenceKey ) ;


signature:
public class SymbolTableImpl { /** * { @ inheritDoc } */
public E put ( SymbolKey key , L secondaryKey , E value ) { } }

implementation:
// Extract the sequence key from the symbol key .
int sequenceKey = ( ( SymbolKeyImpl ) key ) . sequenceKey ; // Create the field column for the secondary key , if it does not already exist .
CircularArrayMap < E > field = fieldMap . get ( secondaryKey ) ; if ( field == null ) { field = new CircularArrayMap < E > ( DEFAULT_INITIAL_FIELD_SIZE ) ; fieldMap . put ( secondaryKey , field ) ; } // Insert the new value for the field into the field map .
E oldValue = field . put ( sequenceKey , value ) ; count ++ ; return oldValue ;


signature:
public class SymbolTableImpl { /** * { @ inheritDoc } */
public void clearUpToLowMark ( L secondaryKey ) { } }

implementation: CircularArrayMap < E > field = fieldMap . get ( secondaryKey ) ; if ( field != null ) { field . clearUpToLowMark ( ) ; }


signature: public class JsoupRadioControl { @ Override public void setValue ( String value ) { } }

implementation: checkArgument ( ! UNCHECKED_VALUE . equals ( value ) , "Cannot uncheck radio control" ) ; getForm ( ) . elements ( ) . select ( byControlGroup ( ) ) . removeAttr ( "checked" ) ; super . setValue ( value ) ;


signature:
public class TopLevelStandaloneController { /** * { @ inheritDoc }
 * < p / > Creates the debugger application from its components . */
public void open ( ) { } }

implementation:
// Set up colors .
componentFactory . setColorScheme ( new DarkColorScheme ( componentFactory . getColorFactory ( ) ) ) ; // Build the main window frame .
mainWindow = componentFactory . createMainWindow ( ) ; mainWindow . showMainWindow ( ) ; // Create and initialize the register monitor .
registerMonitorController = new RegisterMonitorController ( componentFactory , mainWindow ) ; registerMonitorController . open ( ) ; // Create and initialize the memory layout monitor .
memoryLayoutMonitorController = new MemoryLayoutMonitorController ( componentFactory , mainWindow ) ; memoryLayoutMonitorController . open ( ) ; // Create and initialize the byte code view and breakpoint monitor .
codeStepController = new CodeStepController ( componentFactory , mainWindow ) ; codeStepController . open ( ) ; // Build the top - level machine monitor , hooking it up to the child components .
RegisterSetMonitor registerMonitor = registerMonitorController . getRegisterMonitor ( ) ; MemoryLayoutMonitor layoutMonitor = memoryLayoutMonitorController . getLayoutMonitor ( ) ; BreakpointMonitor breakpointMonitor = codeStepController . getBreakpointMonitor ( ) ; ByteCodeMonitor byteCodeMonitor = codeStepController . getByteCodeMonitor ( ) ; machineMonitor = new MachineMonitor ( registerMonitor , layoutMonitor , breakpointMonitor , byteCodeMonitor ) ;


signature:
public class LessThan { /** * Evaluates the arithmetic comparison on its two numeric arguments .
 * @ param firstNumber The first argument .
 * @ param secondNumber The second argument .
 * @ return The result of performing the arithmetic comparison on its arguments . */
protected boolean evaluate ( NumericType firstNumber , NumericType secondNumber ) { } }

implementation:
// If either of the arguments is a real number , then use real number arithmetic , otherwise use integer arithmetic .
if ( firstNumber . isInteger ( ) && secondNumber . isInteger ( ) ) { return firstNumber . intValue ( ) < secondNumber . intValue ( ) ; } else { return firstNumber . doubleValue ( ) < secondNumber . doubleValue ( ) ; }


signature:
public class StartStopLifecycleBase { /** * Makes a transaction from the Initial state to the Running state , or no transition if the current state is not
 * Initial . */
public void running ( ) { } }

implementation: try { stateLock . writeLock ( ) . lock ( ) ; if ( state == State . Initial ) { state = State . Running ; stateChange . signalAll ( ) ; } } finally { stateLock . writeLock ( ) . unlock ( ) ; }


signature:
public class StartStopLifecycleBase { /** * Makes a transaction from the Running state to the Shutdown state , or no transition if the current state is not
 * Running . */
public void terminating ( ) { } }

implementation: try { stateLock . writeLock ( ) . lock ( ) ; if ( state == State . Running ) { state = State . Shutdown ; stateChange . signalAll ( ) ; } } finally { stateLock . writeLock ( ) . unlock ( ) ; }


signature:
public class StartStopLifecycleBase { /** * Makes a transaction from the Running or Shutdown state to the Terminated state , or no transition if the current
 * state is not Running or Shutdown . */
public void terminated ( ) { } }

implementation: try { stateLock . writeLock ( ) . lock ( ) ; if ( ( state == State . Shutdown ) || ( state == State . Running ) ) { state = State . Terminated ; stateChange . signalAll ( ) ; } } finally { stateLock . writeLock ( ) . unlock ( ) ; }


signature:
public class StartStopLifecycleBase { /** * { @ inheritDoc } */
public boolean awaitTermination ( long timeout , TimeUnit unit ) throws InterruptedException { } }

implementation: try { stateLock . writeLock ( ) . lock ( ) ; while ( state != State . Terminated ) { if ( ! stateChange . await ( timeout , unit ) ) { return false ; } } } finally { stateLock . writeLock ( ) . unlock ( ) ; } return true ;


signature:
public class EventListenerSupport { /** * { @ inheritDoc } */
public void addListener ( L listener ) { } }

implementation:
// Ensure update to the list , and rebuilding the active array happens atomically .
synchronized ( listenersLock ) { listeners . add ( listener ) ; activeListeners = new ArrayList < L > ( listeners ) ; }


signature:
public class EventListenerSupport { /** * { @ inheritDoc } */
public void removeListener ( L listener ) { } }

implementation:
// Ensure update to the list , and rebuilding the active array happens atomically .
synchronized ( listenersLock ) { listeners . remove ( listener ) ; activeListeners = new ArrayList < L > ( listeners ) ; }


signature:
public class BaseBuiltIn { /** * { @ inheritDoc } */
public void createContinuationStates ( ResolutionState state ) { } }

implementation: BuiltInFunctor nextGoal = state . getGoalStack ( ) . peek ( ) ; state . createContinuationStatesForGoal ( nextGoal ) ;


signature:
public class FibonacciHeap { /** * Inserts the specified element into this heap .
 * @ param o The data element to add to the heap .
 * @ return True if it was succesfully added , false if not . ( This implmentation always returns true ) . 86 */
public boolean offer ( E o ) { } }

implementation:
// Make a new node out of the new data element .
Node newNode = new Node ( o ) ; // Check if there is already a minimum element .
if ( minNode != null ) { // There is already a minimum element , so add this new element to its right .
newNode . next = minNode . next ; newNode . prev = minNode ; minNode . next . prev = newNode ; minNode . next = newNode ; // Compare the new element with the minimum and update the minimum if neccessary .
updateMinimum ( newNode ) ; } // There is not already a minimum element .
else { // Update the new element previous and next references to refer to itself so that it forms a doubly linked
// list with only one element . This leaves the data structure in a suitable condition for adding more
// elements .
newNode . next = newNode ; newNode . prev = newNode ; // Set the minimum element to be the new data element .
minNode = newNode ; } // Increment the count of data elements in this collection .
size ++ ; // Return true to indicate that the new data element was accepted into the heap .
return true ;


signature:
public class FibonacciHeap { /** * Retrieves and removes the ( head ) minimum element of this heap , or null if this heap is empty .
 * @ return The head element of the hea , or null if the heap is empty . */
public E poll ( ) { } }

implementation:
// Check if there is only one element in the heap .
if ( size == 1 ) { E result = minNode . element ; // Set the minimum to null .
minNode = null ; // Decrease the count of elements in the heap .
size -- ; return result ; } // Check that there is a minimum element to return .
else if ( minNode != null ) { // Get the minimum value that is to be returned .
E result = minNode . element ; // Promote the minimum nodes children into the root list but don ' t update their parent references . Updating
// their parent references will be done later .
if ( minNode . degree > 0 ) { insertNodes ( minNode , minNode . child ) ; } // Cut the minimum node out of the root list and update the minimum to be old minimums next node . This
// node may not really be the minimum but it is taken to be the initial candidate for a new minimum . The
// real minimum will be scanned for later .
minNode . next . prev = minNode . prev ; minNode . prev . next = minNode . next ; minNode = minNode . next ; // The consolidation process will merge all the binomial trees of the same order until there are none
// of duplicate size left . As each binomial tree of order k , Bk , holds 2 ^ k nodes the biggest tree
// possible for a heap of n nodes will be log to the base 2 of the next biggest power of 2 above or
// equal to n . The next section of code creates an array with this many elements , indexed by the order
// of the binomial tree , that is used to keep track of what tree orders currently exist during the
// consolidation process .
Node [ ] tree = ( Node [ ] ) Array . newInstance ( minNode . getClass ( ) , ceilingLog2 ( size - 1 ) + 1 ) ; // Loop through the root list , setting parent references to null and consolidating the remainder of the heap
// into binomial trees . The loop begins at the next node after the min node and finishes on the min node
// itself . This means that the min node is always the very last in the root list to be examined and
// consolidated ensuring that it cannot have been removed from the root list before the loop gets to it . The
// terminal min node is explicitly referenced because the consolidation process will update the min node
// during the loop .
Node nextNode = null ; Node nextNextNode = minNode . next ; Node terminalNode = minNode ; do { // Move on to the next node .
nextNode = nextNextNode ; // Work out what the next next node will be at the start of the loop as manipulations durings
// the loop may override the next node reference of the current next node .
nextNextNode = nextNode . next ; // Update parent references to null .
nextNode . parent = null ; // Update the minimum if the current root list element is smaller than the current best candidate .
updateMinimum ( nextNode ) ; // Consolidate the remainder of the heap into binomial trees by merging duplicate trees of equal size .
// Loop until no tree with the same size as the current one exists .
int degree = nextNode . degree ; Node parentNode = nextNode ; while ( tree [ degree ] != null ) { // Clear the binomial tree of this size from the tree array as it is about to be merged with the
// current node and a new tree of twice the size created .
Node mergeNode = tree [ degree ] ; tree [ degree ] = null ; // Compare the roots of the two trees to be merged to decide which is the smaller and should form
// the single root of the merged tree .
if ( compare ( mergeNode , parentNode ) < 0 ) { // Swap the two nodes .
Node temp = mergeNode ; mergeNode = parentNode ; parentNode = temp ; } // Cut the tree rooted by the larger root node from the root list .
mergeNode . next . prev = mergeNode . prev ; mergeNode . prev . next = mergeNode . next ; mergeNode . next = mergeNode ; mergeNode . prev = mergeNode ; // Paste the tree rooted by the larger root node into the tree with the smaller root node .
mergeNode . parent = parentNode ; // Check if the smaller node ( the parent ) already has some children .
if ( parentNode . child != null ) { // Stitch the larger node into the circular doubly linked list of children .
insertNodes ( parentNode . child , mergeNode ) ; // Update all the parent references of the newly added children .
} // The smaller node does not already have children .
else { // Set the larger node ( of degree 1 ) as its first child .
parentNode . child = mergeNode ; // Make sure the child node forms a doubly linked list with itself .
mergeNode . next = mergeNode ; mergeNode . prev = mergeNode ; } // Bump up by one the order of the smaller root node to which the other tree of equal size was
// added .
parentNode . degree ++ ; // Continue the scan for duplicate trees on the next larger degree .
degree ++ ; } tree [ degree ] = parentNode ; } while ( nextNode != terminalNode ) ; /* * String out = " At End : [ " ; for ( int i = 0 ; i < tree . length ; i + + ) out + = ( i = = tree . length - 1 ) ? tree [ i ] :
 * tree [ i ] + " , " ; out + = " ] " ; log . info ( out ) ; */
// Decrease the count of elements in the heap .
size -- ; // Return the minimum element .
return result ; } // There is no minimum element so return null .
else { return null ; }


signature:
public class FibonacciHeap { /** * Calculates the smallest integer value , m , such that m ^ 2 > = n . The ceiling log2 of n .
 * @ param n The value to calulate ceiling log 2 of .
 * @ return The smallest integer value , m , such that m ^ 2 > = n .
 * @ todo This can possibly be done more neatly . Consult Hackers Delight or aggregate . org for the following
 * algorithm : y = ( x & ( x - 1 ) ) ; y | = - y ; y > > = ( WORDBITS - 1 ) ; x | = ( x > > 1 ) ; x | = ( x > > 2 ) ; x | = ( x > > 4 ) ;
 * x | = ( x > > 8 ) ; x | = ( x > > 16 ) ; # ifdef LOG0UNDEFINED return ( ones ( x ) - 1 - y ) ; # else return ( ones ( x > > 1 ) -
 * y ) ; # endif */
private static int ceilingLog2 ( int n ) { } }


signature:
public class FibonacciHeap { /** * Compares the specified node with the minimum and updates the minimum if neccessary . If a comparator was used to
 * create this heap then this comparator is used to perform the comparison . If no comparator was set then the
 * natural ordering of the element type is used . The element must implement the Comparable interface to support a
 * natural ordering . If it does not there will be a class cast exception thrown .
 * @ param node the node to compare with the current minimum .
 * @ throws ClassCastException if the element in the specified node cannot be compared with elements currently in the
 * heap according to the heap ' s ordering .
 * @ todo Use the compare method . */
private void updateMinimum ( Node node ) { } }

implementation:
// Check if a comparator was set .
if ( entryComparator != null ) { // Use the comparator to compare the candidate new minimum with the current one and check if the new one
// should be set .
if ( entryComparator . compare ( node . element , minNode . element ) < 0 ) { // Update the minimum node .
minNode = node ; } } // No comparator was set so use the natural ordering .
else { // Cast the candidate new minimum element into a Comparable and compare it with the existing minimum
// to check if the new one should be set .
if ( ( ( Comparable ) node . element ) . compareTo ( minNode . element ) < 0 ) { // Update the minimum node .
minNode = node ; } }


signature:
public class FibonacciHeap { /** * Compares two heap nodes . The comparison performed is dependant on whether a comparator has been set or the
 * natural ordering is to be used .
 * @ param node1 The first node to compare .
 * @ param node2 The second node to compare .
 * @ return a negative integer , zero , or a positive integer as this object is less than , equal to , or greater than
 * the specified object . */
private int compare ( Node node1 , Node node2 ) { } }

implementation:
// Check if a comparator was set .
if ( entryComparator != null ) { // Use the comparator to compare .
return entryComparator . compare ( node1 . element , node2 . element ) ; } // No comparator was set so use the natural ordering .
else { // Cast one of the elements into a Comparable and compare it with the other .
return ( ( Comparable ) node1 . element ) . compareTo ( node2 . element ) ; }


signature:
public class FibonacciHeap { /** * Inserts a single node or a circular doubly linked list of nodes into a list next to the specified node . I does
 * not matter if the specified nodes are singletons or part of a chain as they will be correctly linked in in either
 * case so long as their prev and next references form a loop with themselves .
 * @ param node the node or node within a chain that the new node chain is to be inserted next to .
 * @ param newNode a single node or a node within a chain that is to be linked into the root list next to the minimum
 * node . */
private void insertNodes ( Node node , Node newNode ) { } }

implementation:
// Keep a reference to the next node in the node ' s chain as this will be overwritten when attaching the node
// or chain into the root list .
Node oldNodeNext = newNode . next ; // Break open the node ' s chain and attach it into the root list .
newNode . next . prev = node ; newNode . next = node . next ; // Break open the root list chain and attach it to the new node or chain .
node . next . prev = newNode ; node . next = oldNodeNext ;


signature:
public class BreakpointMonitor { /** * Pauses any calling thread , until { @ link # released } is invoked . */
public void pause ( ) { } }

implementation:
try { lock . lock ( ) ; try { released . await ( ) ; } catch ( InterruptedException e ) { // Exception set to null as compensation action of returning immediately with current thread interrupted
// is taken .
e = null ; Thread . currentThread ( ) . interrupt ( ) ; return ; } } finally { lock . unlock ( ) ; }


signature:
public class TimeoutMap { /** * Restarts the sweep alogirithm . Useful after a kill has stopped it . */
public void restart ( ) { } }

implementation:
// Clear the sweep thread kill flag .
sweepThreadKillFlag = false ; // Start the sweep thread running with low priority .
cacheSweepThread = new Thread ( ) { public void run ( ) { sweep ( ) ; } } ; cacheSweepThread . setPriority ( Thread . MIN_PRIORITY ) ; cacheSweepThread . start ( ) ;


signature:
public class TimeoutMap { /** * Returns the value to which this map maps the specified key . Returns < tt > null < / tt > if the map contains no mapping
 * for this key . A return value of < tt > null < / tt > does not < i > necessarily < / i > indicate that the map contains no
 * mapping for the key ; it ' s also possible that the map explicitly maps the key to < tt > null < / tt > . The < tt >
 * containsKey < / tt > operation may be used to distinguish these two cases .
 * < p > More formally , if this map contains a mapping from a key < tt > k < / tt > to a value < tt > v < / tt > such that < tt >
 * ( key = = null ? k = = null : key . equals ( k ) ) < / tt > , then this method returns < tt > v < / tt > ; otherwise it returns < tt >
 * null < / tt > . ( There can be at most one such mapping . )
 * @ param key Key whose associated value is to be returned .
 * @ return The value to which this map maps the specified key , or < tt > null < / tt > if the map contains no mapping for
 * this key .
 * @ throws ClassCastException If the key is of an inappropriate type for this map ( optional ) .
 * @ throws NullPointerException If the key is < tt > null < / tt > and this map does not permit < tt > null < / tt > keys
 * ( optional ) .
 * @ see # containsKey ( Object ) */
public Object get ( Object key ) { } }

implementation:
// Synchronize on the cache to ensure its integrity in a multi - threaded environment .
synchronized ( cache ) { // Try to extract the matching element as an ElementMonitor ,
ElementMonitor monitor = ( ElementMonitor ) cache . get ( key ) ; // If the element is not null then return its value , else null .
// Also upgrade the timestamp of the matching element to the present to show that it has been recently
// accessed .
if ( monitor != null ) { // Upgrade the timestamp .
long t = System . currentTimeMillis ( ) ; monitor . lastTouched = t ; // Return the element .
return monitor . element ; } else { return null ; } }


signature:
public class TimeoutMap { /** * Associates the specified value with the specified key in this map ( optional operation ) . If the map previously
 * contained a mapping for this key , the old value is replaced by the specified value . ( A map < tt > m < / tt > is said to
 * contain a mapping for a key < tt > k < / tt > if and only if { @ link # containsKey ( Object ) m . containsKey ( k ) } would return
 * < tt > true < / tt > . ) )
 * @ param key Key with which the specified value is to be associated .
 * @ param value Value to be associated with the specified key .
 * @ return Previous value associated with specified key , or < tt > null < / tt > if there was no mapping for key . A < tt >
 * null < / tt > return can also indicate that the map previously associated < tt > null < / tt > with the specified
 * key , if the implementation supports < tt > null < / tt > values .
 * @ throws UnsupportedOperationException If the < tt > put < / tt > operation is not supported by this map .
 * @ throws ClassCastException If the class of the specified key or value prevents it from being stored in
 * this map .
 * @ throws IllegalArgumentException If some aspect of this key or value prevents it from being stored in this
 * map .
 * @ throws NullPointerException If this map does not permit < tt > null < / tt > keys or values , and the specified
 * key or value is < tt > null < / tt > . */
public Object put ( Object key , Object value ) { } }

implementation:
// Synchronize on the cache to ensure its integrity in a multi - threaded environment .
synchronized ( cache ) { // Create a new ElementMonitor in the cache for the new element .
// Timestamp the new element with the present time .
long t = System . currentTimeMillis ( ) ; // Extract the element value out of the replaced element monitor if any .
ElementMonitor replaced = ( ElementMonitor ) cache . put ( key , new ElementMonitor ( value , t ) ) ; if ( replaced != null ) { return replaced . element ; } else { return null ; } }


signature:
public class TimeoutMap { /** * Removes the mapping for this key from this map if it is present ( optional operation ) . More formally , if this map
 * contains a mapping from key < tt > k < / tt > to value < tt > v < / tt > such that < code > ( key = = null ? k = = null :
 * key . equals ( k ) ) < / code > , that mapping is removed . ( The map can contain at most one such mapping . )
 * < p > Returns the value to which the map previously associated the key , or < tt > null < / tt > if the map contained no
 * mapping for this key . ( A < tt > null < / tt > return can also indicate that the map previously associated < tt > null < / tt >
 * with the specified key if the implementation supports < tt > null < / tt > values . ) The map will not contain a mapping
 * for the specified key once the call returns .
 * @ param key key whose mapping is to be removed from the map .
 * @ return previous value associated with specified key , or < tt > null < / tt > if there was no mapping for key .
 * @ throws ClassCastException if the key is of an inappropriate type for this map ( optional ) .
 * @ throws NullPointerException if the key is < tt > null < / tt > and this map does not permit < tt > null < / tt > keys
 * ( optional ) .
 * @ throws UnsupportedOperationException if the < tt > remove < / tt > method is not supported by this map . */
public Object remove ( Object key ) { } }

implementation:
// Synchronize on the cache to ensure its integrity in a multi - threaded environment .
synchronized ( cache ) { // Remove the element from the marked heap ( if it exists in the heap ) and from the cache .
marked . remove ( key ) ; return cache . remove ( key ) ; }


signature:
public class TimeoutMap { /** * Copies all of the mappings from the specified map to this map ( optional operation ) . The effect of this call is
 * equivalent to that of calling { @ link # put ( Object , Object ) put ( k , v ) } on this map once for each mapping from key
 * < tt > k < / tt > to value < tt > v < / tt > in the specified map . The behavior of this operation is unspecified if the
 * specified map is modified while the operation is in progress .
 * @ param t Mappings to be stored in this map .
 * @ throws UnsupportedOperationException if the < tt > putAll < / tt > method is not supported by this map .
 * @ throws ClassCastException if the class of a key or value in the specified map prevents it from being
 * stored in this map .
 * @ throws IllegalArgumentException some aspect of a key or value in the specified map prevents it from being
 * stored in this map .
 * @ throws NullPointerException if the specified map is < tt > null < / tt > , or if this map does not permit < tt >
 * null < / tt > keys or values , and the specified map contains < tt > null < / tt > keys
 * or values . */
public void putAll ( Map t ) { } }

implementation:
// Synchronize on the cache to ensure its integrity in a multi - threaded environment .
synchronized ( cache ) { // Iterate over all elements in the map to add , placing each of them into an ElementMonitor before
// putting them into the cache .
for ( Object nextKey : t . keySet ( ) ) { Object nextValue = t . get ( nextKey ) ; // Delegate to the put method to wrap the new item in an ElementMonitor .
cache . put ( nextKey , nextValue ) ; } }


signature:
public class TimeoutMap { /** * Garbage collects the cache , sweeping out any elements that have timed out . This method should really only be
 * invoked in a seperate thread as it does not return ( at least not until the { @ link # sweepThreadKillFlag } is set ) .
 * @ todo Should really check that the sweep time has actually expired when the thread wakes up . */
private void sweep ( ) { } }

implementation:
/* log . fine ( " private void sweep ( ) : called " ) ; */
// Loop until the thread is terminated .
while ( true ) { // Take a marked copy of the cache to examine for timed out elements .
// Synchronize on the cache to ensure its integrity in a multi - threaded environment .
synchronized ( cache ) { /* log . fine ( " \ tMarking " + cache . size ( ) + " objects . " ) ; */
// Take a copy of everything in the cache into the marked heap .
marked . putAll ( cache ) ; } // Use synchronized block to own this objects monitor so that it can be waited on .
// This is needed so that the kill method , and other methods , can wake this thread up .
synchronized ( this ) { // Use a try block as the thread may be woken up during the pause time between sweeps .
try { // Halt the thread between sweeps , configured by the sweepTime property .
wait ( sweepTime ) ; } catch ( InterruptedException e ) { // Ignore this , interuption conditions will be tested later .
} } // TODO : Should really check that sweepTime has expired .
// Check the sweep thread kill flag to see if the sweep algorithm has been stopped .
if ( sweepThreadKillFlag ) { return ; } // Create a counter to count the number of elements removed from the cache .
int i = 0 ; // Create a map to copy the marked heap into . This is done because the following code must iterate
// over the marked heap whilst modifying it . A copy is used to generate all the keys to iterate over so
// that the iterator is not disturbed by its underlying data structure being simultaneously modified .
Map copy = new HashMap ( ) ; // Synchronize on the cache to ensure its integrity in a multi - threaded environment .
synchronized ( cache ) { // Put everything in the marked cache into the copy .
copy . putAll ( marked ) ; } // Loop over the copy of the marked heap looking for timed out elements .
for ( Object nextKey : copy . keySet ( ) ) { // Get the key of the next element from the copy of the marked heap .
// Extract the current element from the copy of the marked heap as an ElementMonitor object .
ElementMonitor nextMonitor = ( ElementMonitor ) copy . get ( nextKey ) ; // Get the current time in milliseconds .
long t = System . currentTimeMillis ( ) ; // Check if the current element has not been accessed for a while , configured by the
// sweepExpiryTime property .
if ( ( t - nextMonitor . lastTouched ) > sweepExpiryTime ) { // Synchronize on the cache to ensure its integrity in a multi - threaded environment .
synchronized ( cache ) { // Remove the out of date element from the marked heap and from the cache .
marked . remove ( nextKey ) ; cache . remove ( nextKey ) ; /* log . fine ( " Element removed from the cache " + nextKey ) ; */
// Increment the count of invalidated elements .
i ++ ; } } } /* log . fine ( i + " objects removed . " ) ; */
}


signature: public class ControlGroupTck { @ Test public void getNameReturnsName ( ) { } }

implementation: server ( ) . enqueue ( new MockResponse ( ) . setBody ( "" + "<form name='f'>" + "<input type='text' name='x'/>" + "</form>" + "" ) ) ; String actual = newBrowser ( ) . get ( url ( server ( ) ) ) . getForm ( "f" ) . getControlGroup ( "x" ) . getName ( ) ; assertThat ( "form control group name" , actual , is ( "x" ) ) ;


signature: public class ControlGroupTck { @ Test public void getControlsReturnsControl ( ) { } }

implementation: server ( ) . enqueue ( new MockResponse ( ) . setBody ( "" + "<form name='f'>" + "<input type='text' name='x'/>" + "</form>" + "" ) ) ; List < Control > actual = newBrowser ( ) . get ( url ( server ( ) ) ) . getForm ( "f" ) . getControlGroup ( "x" ) . getControls ( ) ; assertThat ( "form control group control" , actual , contains ( control ( "x" ) ) ) ;


signature:
public class Searches { /** * Finds the set of all goals of a search .
 * @ param < T > The traversable state type of the search .
 * @ param method The search method to find all goals of .
 * @ return A set of all goals found . */
public static < T > Set < T > setOf ( SearchMethod < T > method ) { } }

implementation: Set < T > result = new HashSet < T > ( ) ; findAll ( result , method ) ; return result ;


signature:
public class Searches { /** * Finds a bag of all goals of a search .
 * @ param < T > The traversable state type of the search .
 * @ param method The search method to find all goals of .
 * @ return A bag of all goals found . */
public static < T > Collection < T > bagOf ( SearchMethod < T > method ) { } }

implementation: Collection < T > result = new ArrayList < T > ( ) ; findAll ( result , method ) ; return result ;


signature:
public class Searches { /** * Finals all solutions to a search and inserts them into the specified collection .
 * @ param < T > The traversable state type of the search .
 * @ param result The collection to build up the results in .
 * @ param method The search to run . */
private static < T > void findAll ( Collection < T > result , SearchMethod < T > method ) { } }

implementation: for ( Iterator < T > i = allSolutions ( method ) ; i . hasNext ( ) ; ) { T nextSoltn = i . next ( ) ; result . add ( nextSoltn ) ; }


signature:
public class CodeStepController { /** * { @ inheritDoc }
 * < p / > Creates the register monitor component and hooks it up to the register set . */
public void open ( ) { } }

implementation:
// Build a text grid panel in the central position .
grid = componentFactory . createTextGrid ( ) ; mainWindow . showCentrePane ( componentFactory . createTextGridPanel ( grid ) ) ; paneController = mainWindow . getCentreController ( ) ; paneController . showVerticalScrollBar ( ) ; // Build a table model on the text grid , to display the code in .
table = ( EnhancedTextTable ) grid . createTable ( 0 , 0 , 20 , 20 ) ; breakpointMonitor = new BreakpointMonitorImpl ( ) ; byteCodeMonitor = new ByteCodeMonitor ( table ) ; // Attach listeners for user events on the table .
grid . addTextGridSelectionListener ( new SelectionHandler ( ) ) ; // Register some keyboard shortcuts to control the code stepping .
KeyShortcutMap shortcutMap = componentFactory . getKeyShortcutMap ( ) ; mainWindow . setKeyShortcut ( shortcutMap . getStep ( ) , "step" , new Step ( ) ) ; mainWindow . setKeyShortcut ( shortcutMap . getStepOver ( ) , "step_over" , new StepOver ( ) ) ; mainWindow . setKeyShortcut ( shortcutMap . getResume ( ) , "resume" , new Resume ( ) ) ;


signature:
public class Filterator { /** * Generates the next element in the sequence .
 * @ return The next element from the sequence if one is available , or < tt > null < / tt > if the sequence is complete . */
public T nextInSequence ( ) { } }

implementation:
T result = null ; // Loop until a filtered element is found , or the source iterator is exhausted .
while ( source . hasNext ( ) ) { S next = source . next ( ) ; result = mapping . apply ( next ) ; if ( result != null ) { break ; } } return result ;


signature:
public class BaseByteArrayCodeMachine { /** * { @ inheritDoc } */
public ByteBuffer getCodeBuffer ( CallPoint callPoint ) { } }

implementation: ByteBuffer buffer = ByteBuffer . wrap ( code , callPoint . entryPoint , callPoint . length ) ; buffer . order ( ByteOrder . LITTLE_ENDIAN ) ; return buffer ;


signature:
public class Call { /** * { @ inheritDoc } */
public SizeableLinkedList < WAMInstruction > compileBodyArguments ( Functor expression , boolean isFirstBody , FunctorName clauseName , int bodyNumber ) { } }

implementation:
// Build the argument to call in the usual way .
return defaultBuiltIn . compileBodyArguments ( expression , isFirstBody , clauseName , bodyNumber ) ;


signature:
public class Call { /** * { @ inheritDoc } */
public SizeableLinkedList < WAMInstruction > compileBodyCall ( Functor expression , boolean isFirstBody , boolean isLastBody , boolean chainRule , int permVarsRemaining ) { } }

implementation:
// Used to build up the results in .
SizeableLinkedList < WAMInstruction > instructions = new SizeableLinkedList < WAMInstruction > ( ) ; // Generate the call or tail - call instructions , followed by the call address , which is f _ n of the
// called program .
if ( isLastBody ) { // Deallocate the stack frame at the end of the clause , but prior to calling the last
// body predicate .
// This is not required for chain rules , as they do not need a stack frame .
if ( ! chainRule ) { instructions . add ( new WAMInstruction ( WAMInstruction . WAMInstructionSet . Deallocate ) ) ; } instructions . add ( new WAMInstruction ( WAMInstruction . WAMInstructionSet . CallInternal , ( byte ) ( permVarsRemaining & 0xff ) , new FunctorName ( "execute" , 1 ) ) ) ; } else { instructions . add ( new WAMInstruction ( WAMInstruction . WAMInstructionSet . CallInternal , ( byte ) ( permVarsRemaining & 0xff ) , new FunctorName ( "call" , 1 ) ) ) ; } return instructions ;


signature:
public class BeanMemento { /** * Restores the properties currently in this memento to the specified object .
 * @ param ob The object to which the values from this memento should be restored .
 * @ param values The map of values to restore .
 * @ throws NoSuchFieldException If a setter method could not be found for a property . */
public static void restoreValues ( Object ob , Map < String , Object > values ) throws NoSuchFieldException { } }

implementation:
/* log . fine ( " public void restore ( Object ob ) : called " ) ; */
/* log . fine ( " Object to restore to has the type : " + ob . getClass ( ) ) ; */
// Get the class of th object to restore to .
Class obClass = ob . getClass ( ) ; // Loop over all the stored properties .
for ( String propName : values . keySet ( ) ) { // Get the cached property from this mementos store .
Object nextValue = values . get ( propName ) ; /* log . fine ( " Next property to restore is : " + propName ) ; */
/* log . fine ( " Next value to restore is : " + nextValue ) ; */
// Used to hold the value to set .
Object paramValue ; // Used to hold the type of the value to set .
Class paramType ; // Check if the value store is a null .
if ( nextValue == null ) { paramValue = null ; paramType = null ; } // Check if the value to store is a multi type data object .
else if ( nextValue instanceof TypeConverter . MultiTypeData ) { /* log . fine ( " The value to restore is a multi typed data object . " ) ; */
TypeConverter . MultiTypeData multiValue = ( TypeConverter . MultiTypeData ) nextValue ; // Get the types ( classes ) of all the possible ' setter ' methods for the property .
Set < Class > setterTypes = ReflectionUtils . findMatchingSetters ( ob . getClass ( ) , propName ) ; /* log . fine ( " setterTypes = " + setterTypes ) ; */
// Use the type converter to get the best matching type with the multi data .
paramType = TypeConverter . bestMatchingConversion ( multiValue , setterTypes ) ; // Convert the multi data to an object of the appropriate type .
paramValue = TypeConverter . convert ( multiValue , paramType ) ; } // The value to store is not a multi type .
else { /* log . fine ( " The value to restore is a simply typed data object . " ) ; */
// Get the type and value of the plain type to set .
paramValue = nextValue ; paramType = nextValue . getClass ( ) ; } /* log . fine ( " paramValue = " + paramValue ) ; */
/* log . fine ( " paramType = " + paramType ) ; */
// Call the setter method with the new property value , checking first that the property has a matching
// ' setter ' method .
Method setterMethod ; try { // Convert the first letter of the property name to upper case to match against the upper case version
// of it that will be in the setter method name . For example the property test will have a setter method
// called setTest .
String upperPropertyName = Character . toUpperCase ( propName . charAt ( 0 ) ) + propName . substring ( 1 ) ; // Try to find an appropriate setter method on the object to call .
setterMethod = obClass . getMethod ( "set" + upperPropertyName , paramType ) ; // Call the setter method with the new property value .
Object [ ] params = new Object [ ] { paramValue } ; setterMethod . invoke ( ob , params ) ; } catch ( NoSuchMethodException e ) { // Do nothing as properties may have getters but no setter for read only properties .
/* log . log ( java . util . logging . Level . FINE , " A setter method could not be found for " + propName + " . " , e ) ; */
/* / / The object does not have a matching setter method for the type .
 NoSuchFieldException nsfe = new NoSuchFieldException ( " The object does not have a matching setter " +
 " method ' set " + propName + " ' . " ) ;
 nsfe . initCause ( e ) ;
 throw nsfe ; */
} catch ( IllegalAccessException e ) { /* log . log ( java . util . logging . Level . FINE , " IllegalAccessException during call to setter method . " , e ) ; */
} catch ( InvocationTargetException e ) { /* log . log ( java . util . logging . Level . FINE , " InvocationTargetException during call to setter method . " , e ) ; */
} }


signature:
public class BeanMemento { /** * Gets the value of the named property of the specified class .
 * @ param cls The class in which the property to get is declared . This is ignored as only properties of the
 * top - level bean class are used by this memento . Properties higher up the inheritence chain can be
 * overriden .
 * @ param property The name of the property .
 * @ return The object value of the property .
 * @ throws NoSuchFieldException If the named field does not exist on the class . */
public Object get ( Class cls , String property ) throws NoSuchFieldException { } }

implementation:
// Check that the field exists .
if ( ! values . containsKey ( property ) ) { throw new NoSuchFieldException ( "The property, " + property + ", does not exist on the underlying class." ) ; } // Try to find a matching property cached in this memento .
return values . get ( property ) ;


signature:
public class BeanMemento { /** * Sets the value of the named property as a multi type object .
 * @ param cls The class in which the property is declared . This is ignored as only properties of the top - level
 * bean class are used by this memento . Properties higher up the inheritance chain can be overriden .
 * @ param property The name of the property to set .
 * @ param value The multi type object to set that value from . */
public void put ( Class cls , String property , TypeConverter . MultiTypeData value ) { } }

implementation:
/* log . fine ( " public void put ( String property , TypeConverter . MultiTypeData value ) : called " ) ; */
/* log . fine ( " property = " + property ) ; */
/* log . fine ( " value = " + value ) ; */
// Store the multi typed data under the specified property name .
values . put ( property , value ) ;


signature:
public class BeanMemento { /** * Places the specified value into the memento based on the property ' s declaring class and name .
 * @ param cls The class in which the property is declared . This is ignored as only properties of the top - level
 * bean class are used by this memento . Properties higher up the inheritance chain can be overriden .
 * @ param property The name of the property .
 * @ param value The value to store into this memento . */
public void put ( Class cls , String property , Object value ) { } }

implementation:
// Store the new data under the specified property name .
values . put ( property , value ) ;


signature:
public class BeanMemento { /** * Captures the fields of the associated object .
 * @ param ignoreNull < tt > true < / tt > iff null fields should be ignored , < tt > false < / tt > if null fields should be
 * captured as nulls . */
private void capture ( boolean ignoreNull ) { } }

implementation:
// Get the class of the object to build a memento for .
Class cls = ob . getClass ( ) ; // Iterate through all the public methods of the class including all super - interfaces and super - classes .
Method [ ] methods = cls . getMethods ( ) ; for ( Method nextMethod : methods ) { // Get the next method .
/* log . fine ( " nextMethod = " + nextMethod . getName ( ) ) ; */
// Check if the method is a ' getter ' method , is public and takes no arguments .
String methodName = nextMethod . getName ( ) ; if ( methodName . startsWith ( "get" ) && ( methodName . length ( ) >= 4 ) && Character . isUpperCase ( methodName . charAt ( 3 ) ) && Modifier . isPublic ( nextMethod . getModifiers ( ) ) && ( nextMethod . getParameterTypes ( ) . length == 0 ) ) { String propName = Character . toLowerCase ( methodName . charAt ( 3 ) ) + methodName . substring ( 4 ) ; /* log . fine ( methodName + " is a valid getter method for the property " + propName + " . " ) ; */
try { // Call the ' getter ' method to extract the properties value .
Object [ ] params = new Object [ ] { } ; Object value = nextMethod . invoke ( ob , params ) ; /* log . fine ( " The result of calling the getter method is : " + value ) ; */
// Store the property value for the object .
if ( ! ignoreNull || ( value != null ) ) { values . put ( propName , value ) ; } } catch ( IllegalAccessException e ) { /* log . log ( java . util . logging . Level . FINE , " IllegalAccessException during call to getter method . " , e ) ; */
throw new IllegalStateException ( e ) ; } catch ( InvocationTargetException e ) { /* log . log ( java . util . logging . Level . FINE , " InvocationTargetException during call to getter method . " , e ) ; */
throw new IllegalStateException ( e ) ; } } // Should also check if the method is a ' setter ' method , is public and takes exactly one argument .
}


signature:
public class WAMNativeInterpreter { /** * Creates the interpreter and launches its top - level run loop .
 * @ param args The command line arguments . */
public static void main ( String [ ] args ) { } }

implementation:
try { SymbolTableImpl < Integer , String , Object > symbolTable = new SymbolTableImpl < Integer , String , Object > ( ) ; WAMResolvingMachine machine = new WAMResolvingNativeMachine ( symbolTable ) ; Parser < Clause , Token > parser = new SentenceParser ( machine ) ; parser . setTokenSource ( TokenSource . getTokenSourceForInputStream ( System . in ) ) ; LogicCompiler < Clause , WAMCompiledPredicate , WAMCompiledQuery > compiler = new WAMCompiler ( symbolTable , machine ) ; ResolutionEngine < Clause , WAMCompiledPredicate , WAMCompiledQuery > engine = new WAMEngine ( parser , machine , compiler , machine ) ; engine . reset ( ) ; ResolutionInterpreter < WAMCompiledPredicate , WAMCompiledQuery > interpreter = new ResolutionInterpreter < WAMCompiledPredicate , WAMCompiledQuery > ( engine ) ; interpreter . interpreterLoop ( ) ; } catch ( Exception e ) { /* log . log ( java . util . logging . Level . SEVERE , e . getMessage ( ) , e ) ; */
e . printStackTrace ( new PrintStream ( System . err ) ) ; System . exit ( - 1 ) ; }


signature:
public class GripComponentMouseMover { /** * { @ inheritDoc }
 * < p / > Changes the cursor to the move variant , and records that the mouse is pressed . */
public void mousePressed ( MouseEvent e ) { } }

implementation: gripComponent . setCursor ( moveCursor ) ; pressed = true ; lastY = e . getYOnScreen ( ) ; lastX = e . getXOnScreen ( ) ;


signature:
public class GripComponentMouseMover { /** * { @ inheritDoc }
 * < p / > Applies mouse dragging as a resizing delta to the re - sizer . */
public void mouseDragged ( MouseEvent e ) { } }

implementation: if ( pressed ) { int deltaY = e . getYOnScreen ( ) - lastY ; lastY = e . getYOnScreen ( ) ; int deltaX = e . getXOnScreen ( ) - lastX ; lastX = e . getXOnScreen ( ) ; boolean revalidate = false ; if ( deltaY != 0 ) { resizeable . deltaY ( - deltaY ) ; revalidate = true ; } if ( deltaX != 0 ) { resizeable . deltaX ( - deltaX ) ; revalidate = true ; } if ( revalidate ) { SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { gripComponent . getParent ( ) . revalidate ( ) ; } } ) ; } }


signature: public class MicrobrowserTck { @ Test public void getRequestsPath ( ) throws InterruptedException { } }

implementation: server ( ) . enqueue ( new MockResponse ( ) ) ; newBrowser ( ) . get ( url ( server ( ) , "/x" ) ) ; assertThat ( "request path" , server ( ) . takeRequest ( ) . getPath ( ) , is ( "/x" ) ) ;


signature: public class AbstractHypermedia { public final Link getLink ( String rel ) { } }

implementation: List < Link > links = getLinks ( rel ) ; if ( links . isEmpty ( ) ) { throw new LinkNotFoundException ( rel ) ; } return links . get ( 0 ) ;


signature:
public class FifoStack { /** * Pops the first object placed on the stack off of it and returns it .
 * @ return The first object placed on the stack . */
public E pop ( ) { } }

implementation: E ob ; if ( size ( ) == 0 ) { return null ; } ob = get ( 0 ) ; remove ( 0 ) ; return ob ;


signature:
public class Matcher { /** * { @ inheritDoc } */
public T nextInSequence ( ) { } }

implementation:
T result = null ; // Poll results from the buffer until no more are available , but only once the state machine has flushed
// the buffer .
if ( flushMode ) { result = buffer . poll ( ) ; if ( result != null ) { return result ; } flushMode = false ; } // Feed input from the source into the state machine , until some results become available on the buffer .
while ( source . hasNext ( ) ) { S next = source . next ( ) ; fsm . apply ( next ) ; if ( flushMode ) { result = buffer . poll ( ) ; if ( result != null ) { return result ; } flushMode = false ; } } // Once the end of the input source is reached , inform the state machine of this , and try and poll any
// buffered results .
fsm . end ( ) ; if ( flushMode ) { result = buffer . poll ( ) ; } return result ;


signature:
public class SimpleMonitor { /** * { @ inheritDoc } */
public void onReset ( WAMResolvingMachineDPI dpi ) { } }

implementation: System . out . println ( "reset" ) ; tableModel = new TextTableImpl ( ) ; layoutRegisters = new InternalMemoryLayoutBean ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) ; layoutRegisters . addPropertyChangeListener ( this ) ; layoutRegisters . updateRegisters ( layoutRegisters ) ; internalRegisters = new InternalRegisterBean ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , false ) ; internalRegisters . addPropertyChangeListener ( this ) ; internalRegisters . updateRegisters ( dpi . getInternalRegisters ( ) ) ;


signature:
public class SimpleMonitor { /** * { @ inheritDoc } */
public void onCodeUpdate ( WAMResolvingMachineDPI dpi , int start , int length ) { } }

implementation: System . out . println ( "Code updated, " + length + " bytes at " + start + "." ) ; tableModel = new TextTableImpl ( ) ; ByteBuffer code = dpi . getCodeBuffer ( start , length ) ; SizeableList < WAMInstruction > instructions = WAMInstruction . disassemble ( start , length , code , dpi . getVariableAndFunctorInterner ( ) , dpi ) ; int row = 0 ; for ( WAMInstruction instruction : instructions ) { if ( instruction . getLabel ( ) != null ) { tableModel . put ( 0 , row , instruction . getLabel ( ) . toPrettyString ( ) ) ; } tableModel . put ( 1 , row , instruction . toString ( ) ) ; row ++ ; } printTable ( tableModel ) ;