_id
stringlengths 2
7
| title
stringlengths 3
140
| partition
stringclasses 3
values | text
stringlengths 73
34.1k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q180500
|
WAMBaseMachine.resolveCallPoint
|
test
|
public WAMCallPoint resolveCallPoint(int functorName)
{
/*log.fine("public WAMCallPoint resolveCallPoint(int functorName): called");*/
WAMCallPoint result = (WAMCallPoint) symbolTable.get(functorName, SYMKEY_CALLPOINTS);
if (result == null)
{
result = new WAMCallPoint(-1, 0, functorName);
}
return result;
}
|
java
|
{
"resource": ""
}
|
q180501
|
WAMBaseMachine.setCodeAddress
|
test
|
protected WAMCallPoint setCodeAddress(int functorName, int offset, int length)
{
WAMCallPoint entry = new WAMCallPoint(offset, length, functorName);
symbolTable.put(functorName, SYMKEY_CALLPOINTS, entry);
// Keep a reverse lookup from address to functor name.
reverseTable.put(offset, functorName);
return entry;
}
|
java
|
{
"resource": ""
}
|
q180502
|
HierarchyAttribute.isSubCategory
|
test
|
public boolean isSubCategory(HierarchyAttribute comp)
{
// Check that the comparator is of the same type class as this one.
if (!comp.attributeClass.attributeClassName.equals(attributeClass.attributeClassName))
{
return false;
}
// Extract the path labels from this and the comparator.
List<String> otherPath = comp.getPathValue();
List<String> path = getPathValue();
// Check that the path length of the comparator is the same as this plus one or longer.
if (otherPath.size() <= path.size())
{
return false;
}
// Start by assuming that the paths prefixes are the same, then walk down both paths checking they are
// the same.
boolean subcat = true;
for (int i = 0; i < path.size(); i++)
{
// Check that the labels really are equal.
if (!otherPath.get(i).equals(path.get(i)))
{
subcat = false;
break;
}
}
return subcat;
}
|
java
|
{
"resource": ""
}
|
q180503
|
HierarchyAttribute.getId
|
test
|
public long getId()
{
// Find the category for this hierarchy attribute value.
Tree<CategoryNode> category = attributeClass.lookup.get(value);
// Extract and return the id.
return category.getElement().id;
}
|
java
|
{
"resource": ""
}
|
q180504
|
HierarchyAttribute.getValueAtLevel
|
test
|
public String getValueAtLevel(String level)
{
/*log.fine("public String getValueAtLevel(String level): called");*/
/*log.fine("level = " + level);*/
int index = attributeClass.levels.indexOf(level);
/*log.fine("index = " + index);*/
if (index == -1)
{
throw new IllegalArgumentException("Level name " + level +
" is not known to this hierarchy attribute type.");
}
return getValueAtLevel(index);
}
|
java
|
{
"resource": ""
}
|
q180505
|
HierarchyAttribute.getLastValue
|
test
|
public String getLastValue()
{
List<String> pathValue = getPathValue();
return pathValue.get(pathValue.size() - 1);
}
|
java
|
{
"resource": ""
}
|
q180506
|
HierarchyAttribute.writeObject
|
test
|
private void writeObject(ObjectOutputStream out) throws IOException
{
// Print out some information about the serialized object.
/*log.fine("Serialized hierarchy attribute = " + this);*/
/*log.fine("Serialized hierarchy attribute class = " + attributeClass);*/
/*log.fine("Serialized attribute classes in static class map are: ");*/
for (HierarchyClassImpl attributeClass : attributeClasses.values())
{
/*log.fine(attributeClass.toString());*/
}
// Perform default serialization.
// out.defaultWriteObject();
// Serialized the attribute by value, that is, its full path and the name of its attribute class.
List<String> pathValue = getPathValue();
String[] pathArrayValue = pathValue.toArray(new String[pathValue.size()]);
out.writeObject(pathArrayValue);
out.writeObject(attributeClass.getName());
}
|
java
|
{
"resource": ""
}
|
q180507
|
HierarchyAttribute.readObject
|
test
|
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
// Perform default de-serialization.
// in.defaultReadObject();
// Deserialize the attribute by value, from its attribute class and full path.
String[] pathArrayValue = (String[]) in.readObject();
String attributeClassName = (String) in.readObject();
// Re-create the attribute from its value representation.
HierarchyAttribute attr = getFactoryForClass(attributeClassName).createHierarchyAttribute(pathArrayValue);
// Copy the fields from the freshly constructed attribute into this one.
value = attr.value;
attributeClass = attr.attributeClass;
// Print out some information about the deserialized object.
/*log.fine("Deserialized hierarchy attribute = " + this);*/
/*log.fine("Deserialized hierarchy attribute class = " + attributeClass);*/
/*log.fine("Deserialized attribute classes in static class map are: ");*/
for (HierarchyClassImpl attributeClass : attributeClasses.values())
{
/*log.fine(attributeClass.toString());*/
}
}
|
java
|
{
"resource": ""
}
|
q180508
|
ManhattanHeuristic.computeH
|
test
|
public float computeH(EightPuzzleState state, HeuristicSearchNode searchNode)
{
// Get the parent heuristic search node.
HeuristicSearchNode parentNode = (HeuristicSearchNode) searchNode.getParent();
// Check if there is no parent, in which case this is the start state so the complete heuristic needs
// to be calculated.
if (parentNode == null)
{
// Used to hold the running total.
int h = 0;
// Loop over the whole board.
for (int j = 0; j < 3; j++)
{
for (int i = 0; i < 3; i++)
{
char nextTile = state.getTileAt(i, j);
// Look up the board position of the tile in the solution.
int goalX = state.getGoalXForTile(nextTile);
int goalY = state.getGoalYForTile(nextTile);
// Compute the manhattan distance and add it to the total.
int diffX = goalX - i;
diffX = (diffX < 0) ? -diffX : diffX;
int diffY = goalY - j;
diffY = (diffY < 0) ? -diffY : diffY;
h += diffX + diffY;
}
}
// Convert the result to a float and return it
return (float) h;
}
// There is a parent node so calculate the heuristic incrementally from it.
else
{
// Get the parent board state.
EightPuzzleState parentState = (EightPuzzleState) parentNode.getState();
// Get the parent heurstic value.
float h = parentNode.getH();
// Get the move that was played.
char playedMove = ((String) searchNode.getAppliedOp().getOp()).charAt(0);
// Get the position of the empty tile on the parent board.
int emptyX = parentState.getEmptyX();
int emptyY = parentState.getEmptyY();
// Work out which tile has been moved, this is the tile that now sits where the empty tile was.
char movedTile = state.getTileAt(emptyX, emptyY);
// The tile has either moved one step closer to its goal location or one step further away, decide which it
// is. Calculate the X or Y position that the tile moved from.
int oldX = 0;
int oldY = 0;
switch (playedMove)
{
case 'L':
{
oldX = emptyX - 1;
break;
}
case 'R':
{
oldX = emptyX + 1;
break;
}
case 'U':
{
oldY = emptyY - 1;
break;
}
case 'D':
{
oldY = emptyY + 1;
break;
}
default:
{
throw new IllegalStateException("Unkown operator: " + playedMove + ".");
}
}
// Calculate the change in heuristic.
int change = 0;
switch (playedMove)
{
// Catch the case where a horizontal move was made.
case 'L':
case 'R':
{
// Get the X position of the tile in the goal state and current state
int goalX = state.getGoalXForTile(movedTile);
int newX = emptyX;
// Calculate the change in the heuristic
int oldDiffX = oldX - goalX;
oldDiffX = (oldDiffX < 0) ? -oldDiffX : oldDiffX;
int newDiffX = newX - goalX;
newDiffX = (newDiffX < 0) ? -newDiffX : newDiffX;
change = newDiffX - oldDiffX;
break;
}
// Catch the case where a vertical move was made.
case 'U':
case 'D':
{
// Get the Y position of the tile in the goal state and current state
int goalY = state.getGoalYForTile(movedTile);
int newY = emptyY;
// Calculate the change in the heuristic
int oldDiffY = oldY - goalY;
oldDiffY = (oldDiffY < 0) ? -oldDiffY : oldDiffY;
int newDiffY = newY - goalY;
newDiffY = (newDiffY < 0) ? -newDiffY : newDiffY;
change = newDiffY - oldDiffY;
break;
}
default:
{
throw new IllegalStateException("Unkown operator: " + playedMove + ".");
}
}
// Return the parent heuristic plus or minus one.
return (change > 0) ? (h + 1.0f) : (h - 1.0f);
}
}
|
java
|
{
"resource": ""
}
|
q180509
|
HashMapXY.mod
|
test
|
private int mod(long c, int bucketSize)
{
return (int) ((c < 0) ? ((bucketSize + (c % bucketSize)) % bucketSize) : (c % bucketSize));
}
|
java
|
{
"resource": ""
}
|
q180510
|
MultipleUserErrorException.addErrorMessage
|
test
|
public void addErrorMessage(String key, String userMessage)
{
/*log.fine("addErrorMessage(String key, String userMessage): called");*/
/*log.fine("userMessage = " + userMessage);*/
errors.add(new UserReadableErrorImpl(key, userMessage));
}
|
java
|
{
"resource": ""
}
|
q180511
|
ErrorHandler.handleErrors
|
test
|
public static void handleErrors(Throwable exception, ActionErrors errors)
{
// Log the error.
log.log(Level.SEVERE, exception.getMessage(), exception);
if (exception.getCause() == null)
{
log.fine("Exception.getCause() is null");
}
// Unwrap the exception if it is a WrappedStrutsServletException, which is a place holder for returning
// other throwables from struts actions.
// See BaseAction and WrappedStrutsServletException for more information.
if ((exception instanceof WrappedStrutsServletException) && (exception.getCause() != null))
{
exception = exception.getCause();
log.fine("Unwrapped WrappedStrutsServletException");
}
// Create an error called 'exception' in the Struts errors for debugging purposes
// Debugging code can print this piece of html containing the exception stack trace at the bottom
// of the page for convenience.
Writer stackTrace = new StringWriter();
exception.printStackTrace(new PrintWriter(new HTMLFilter(stackTrace)));
errors.add("exception", new ActionError("error.general", stackTrace));
// Check if the exception is a user readable exception
if (exception instanceof UserReadableError)
{
UserReadableError userError = (UserReadableError) exception;
// Check that it contains a user readable message
if (userError.isUserReadable())
{
// Check if there is an error message key to use
if (userError.getUserMessageKey() != null)
{
errors.add("generalerror",
new ActionError(userError.getUserMessageKey(), userError.getUserMessageKey()));
}
// There is no error message key to use so default to error.general and pass the error message as an
// argument so that it will be displayed
else
{
errors.add("generalerror", new ActionError("error.general", userError.getUserMessage()));
}
return;
}
}
// Not a user reable exception so print a standard error message
errors.add("generalerror", new ActionError("error.internalerror"));
}
|
java
|
{
"resource": ""
}
|
q180512
|
HTMLFilter.write
|
test
|
public void write(String str, int off, int len) throws IOException
{
// Get just the portion of the input string to display
String inputString = str.substring(off, off + len);
StringBuffer outputString = new StringBuffer();
// Build a string tokenizer that uses '\n' as its splitting character
// Cycle through all tokens
for (StringTokenizer tokenizer = new StringTokenizer(inputString, "\n", true); tokenizer.hasMoreTokens();)
{
// Replace '\n' token with a <br>
String nextToken = tokenizer.nextToken();
if ("\n".equals(nextToken))
{
outputString.append("<br>");
}
else
{
outputString.append(nextToken);
}
}
// Write out the generated string
out.write(outputString.toString());
}
|
java
|
{
"resource": ""
}
|
q180513
|
ProtoDTMachine.classify
|
test
|
public Map<String, OrdinalAttribute> classify(State state) throws ClassifyingFailureException
{
// Start at the root of the decision tree.
DecisionTree currentNode = dt;
// Loop down the decision tree until a leaf node is found.
while (true) // !currentNode.isLeaf())
{
DecisionTreeElement element = currentNode.getElement();
// Check that the current element really is a decision.
if (element instanceof Decision)
{
Decision decision = (Decision) element;
// Apply the decision at the current node to the state to be classified to get a new tree.
currentNode = decision.decide(state); // , currentNode);
}
else if (element instanceof Assignment)
{
// Cast the element to an Assignment as this is the only type of leaf that is possible.
Assignment assignment = (Assignment) element;
// Return the assignment in a map.
Map<String, OrdinalAttribute> assignmentMap = new HashMap<String, OrdinalAttribute>();
assignmentMap.put(assignment.getPropertyName(), assignment.getAttribute());
return assignmentMap;
}
// It is possible that a node may be of type Pending if an incomplete tree has been used to
// run this classification on.
else
{
// Throw a classification exception due to an incomplete decision tree.
throw new ClassifyingFailureException("A node which is not a decision was encountered.", null);
}
// What happens if the decision could not operate on the state, either because of a missing property or
// because its property was not of the type that the decision was expecting? Can either throw an exception,
// return an empty assignment, or implement an algorithm for coping with missing properties.
}
}
|
java
|
{
"resource": ""
}
|
q180514
|
PartialOrdering.compare
|
test
|
public int compare(T a, T b)
{
boolean aRb = partialOrdering.evaluate(a, b);
if (!aRb)
{
return -1;
}
boolean bRa = partialOrdering.evaluate(b, a);
return (aRb && bRa) ? 0 : 1;
}
|
java
|
{
"resource": ""
}
|
q180515
|
DistributedList.iterator
|
test
|
public Iterator iterator()
{
try
{
DistributedIteratorImpl di;
di = new DistributedIteratorImpl(super.iterator());
return new ClientIterator(di);
}
catch (RemoteException e)
{
// Rethrow the RemoteException as a RuntimeException so as not to conflict with the interface of ArrayList
throw new IllegalStateException("There was a RemoteExcpetion.", e);
}
}
|
java
|
{
"resource": ""
}
|
q180516
|
BitHackUtils.intLogBase2
|
test
|
public static int intLogBase2(int value)
{
int temp1;
int temp2 = value >> 16;
if (temp2 > 0)
{
temp1 = temp2 >> 8;
return (temp1 > 0) ? (24 + LOG_TABLE_256[temp1]) : (16 + LOG_TABLE_256[temp2]);
}
else
{
temp1 = value >> 8;
return (temp1 > 0) ? (8 + LOG_TABLE_256[temp1]) : LOG_TABLE_256[value];
}
}
|
java
|
{
"resource": ""
}
|
q180517
|
BitHackUtils.intLogBase2v2
|
test
|
public static int intLogBase2v2(int value)
{
int temp;
if ((temp = value >> 24) > 0)
{
return 24 + LOG_TABLE_256[temp];
}
else if ((temp = value >> 16) > 0)
{
return 16 + LOG_TABLE_256[temp];
}
else if ((temp = value >> 8) > 0)
{
return 8 + LOG_TABLE_256[temp];
}
else
{
return LOG_TABLE_256[value];
}
}
|
java
|
{
"resource": ""
}
|
q180518
|
BitHackUtils.intLogBase10v2
|
test
|
public static int intLogBase10v2(int value)
{
return (value >= 1000000000)
? 9
: ((value >= 100000000)
? 8
: ((value >= 10000000)
? 7
: ((value >= 1000000)
? 6
: ((value >= 100000)
? 5
: ((value >= 10000)
? 4 : ((value >= 1000) ? 3 : ((value >= 100) ? 2 : ((value >= 10) ? 1 : 0))))))));
}
|
java
|
{
"resource": ""
}
|
q180519
|
BitHackUtils.intLogBase10v3
|
test
|
public static int intLogBase10v3(int value)
{
return (value < 10)
? 0
: ((value < 100)
? 1
: ((value < 1000)
? 2
: ((value < 10000)
? 3
: ((value < 100000)
? 4
: ((value < 1000000)
? 5
: ((value < 10000000)
? 6 : ((value < 100000000) ? 7 : ((value < 1000000000) ? 8 : 9))))))));
}
|
java
|
{
"resource": ""
}
|
q180520
|
BitHackUtils.intLogBase10
|
test
|
public static int intLogBase10(long value)
{
return (value >= 1000000000000000000L)
? 18
: ((value >= 100000000000000000L)
? 17
: ((value >= 10000000000000000L)
? 16
: ((value >= 1000000000000000L)
? 15
: ((value >= 100000000000000L)
? 14
: ((value >= 10000000000000L)
? 13
: ((value >= 1000000000000L)
? 12
: ((value >= 100000000000L)
? 11
: ((value >= 10000000000L)
? 10
: ((value >= 1000000000L)
? 9
: ((value >= 100000000L)
? 8
: ((value >= 10000000L)
? 7
: ((value >= 1000000L)
? 6
: ((value >= 100000L)
? 5
: ((value >= 10000L)
? 4
: ((value >= 1000L)
? 3
: ((value >= 100L)
? 2
: ((value >= 10L) ? 1 : 0)))))))))))))))));
}
|
java
|
{
"resource": ""
}
|
q180521
|
BitHackUtils.intLogBase10v2
|
test
|
public static int intLogBase10v2(long value)
{
return (value < 10)
? 0
: ((value < 100)
? 1
: ((value < 1000)
? 2
: ((value < 10000)
? 3
: ((value < 100000)
? 4
: ((value < 1000000)
? 5
: ((value < 10000000)
? 6
: ((value < 100000000)
? 7
: ((value < 1000000000L)
? 8
: ((value < 10000000000L)
? 9
: ((value < 100000000000L)
? 10
: ((value < 1000000000000L)
? 11
: ((value < 10000000000000L)
? 12
: ((value < 100000000000000L)
? 13
: ((value < 1000000000000000L)
? 14
: ((value < 10000000000000000L)
? 15
: ((value < 100000000000000000L)
? 16
: ((value < 1000000000000000000L)
? 17 : 18)))))))))))))))));
}
|
java
|
{
"resource": ""
}
|
q180522
|
BitHackUtils.getCharacterCountInt32
|
test
|
public static int getCharacterCountInt32(int value)
{
if (value >= 0)
{
return getCharacterCountUInt32(value);
}
else if (value == Integer.MIN_VALUE)
{
return getCharacterCountUInt32(Integer.MAX_VALUE) + 1;
}
else
{
return getCharacterCountUInt32(-value) + 1;
}
}
|
java
|
{
"resource": ""
}
|
q180523
|
BitHackUtils.getCharacterCountInt64
|
test
|
public static int getCharacterCountInt64(long value)
{
if (value >= 0)
{
return getCharacterCountUInt64(value);
}
else if (value == Long.MIN_VALUE)
{
return getCharacterCountUInt64(Long.MAX_VALUE) + 1;
}
else
{
return getCharacterCountUInt64(-value) + 1;
}
}
|
java
|
{
"resource": ""
}
|
q180524
|
BitHackUtils.getCharacterCountDecimal
|
test
|
public static int getCharacterCountDecimal(long integerValue, int scale)
{
boolean isNeg = integerValue < 0;
// Work out how many digits will be needed for the number, adding space for the minus sign, the decimal
// point and leading zeros if needed.
int totalDigits = BitHackUtils.getCharacterCountInt64(integerValue);
int totalLength = totalDigits;
if (isNeg)
{
totalDigits--; // Minus sign already accounted for.
}
if (scale > 0)
{
totalLength++; // For the decimal point.
if (scale >= totalDigits)
{
// For the leading zeros (+ 1 for the zero before decimal point).
totalLength += (scale - totalDigits) + 1;
}
}
else
{
// Add a zero for each negative point in scale
totalLength -= scale;
}
return totalLength;
}
|
java
|
{
"resource": ""
}
|
q180525
|
WAMCompiledQuery.setHead
|
test
|
public void setHead(Functor head, SizeableList<WAMInstruction> instructions)
{
this.head = head;
addInstructions(instructions);
}
|
java
|
{
"resource": ""
}
|
q180526
|
WAMCompiledQuery.emmitCode
|
test
|
public void emmitCode(ByteBuffer buffer, WAMMachine machine, WAMCallPoint callPoint) throws LinkageException
{
// Ensure that the size of the instruction listing does not exceed max int (highly unlikely).
if (sizeof() > Integer.MAX_VALUE)
{
throw new IllegalStateException("The instruction listing size exceeds Integer.MAX_VALUE.");
}
// Used to keep track of the size of the emitted code, in bytes, as it is written.
int length = 0;
// Insert the compiled code into the byte code machine's code area.
for (WAMInstruction instruction : instructions)
{
instruction.emmitCode(buffer, machine);
length += instruction.sizeof();
}
// Keep record of the machine that the code is hosted in, and the call point of the functor within the machine.
this.machine = machine;
this.callPoint = callPoint;
// Record the fact that the code is now linked into a machine.
this.status = LinkStatus.Linked;
}
|
java
|
{
"resource": ""
}
|
q180527
|
WorkFlowController.setCurrentScreen
|
test
|
protected void setCurrentScreen(WorkFlowScreenPanel screen)
{
// Remove any existing screen from the panel
panel.removeAll();
// Place the new screen into the panel
panel.add(screen);
// Check if the screen is not already in the stack of accessed screens. It may be if this is the second time
// the screen is visited foir example if the back button is used.
if (!accessedScreens.contains(screen))
{
// Add the screen to the stack of accessed screens
accessedScreens.push(screen);
}
// Update the work flow state to reflect the change to a new screen state
state.setCurrentScreenState(screen.getState());
// Keep track of the current screen in a local member variable
currentScreen = screen;
// Initialize the new screen
screen.initialize();
// Force the panel to redraw
panel.validate();
}
|
java
|
{
"resource": ""
}
|
q180528
|
UnaryPredicateConjunction.evaluate
|
test
|
public boolean evaluate(T t)
{
// Start by assuming that the candidate will be a member of the predicate.
boolean passed = true;
// Loop through all predicates and fail if any one of them does.
for (UnaryPredicate<T> predicate : chain)
{
if (!predicate.evaluate(t))
{
passed = false;
break;
}
}
return passed;
}
|
java
|
{
"resource": ""
}
|
q180529
|
ContextualProperties.getProperty
|
test
|
public String getProperty(String key)
{
// Try to get the callers class name and method name by examing the stack.
String className = null;
String methodName = null;
// Java 1.4 onwards only.
/*try
{
throw new Exception();
}
catch (Exception e)
{
StackTraceElement[] stack = e.getStackTrace();
// Check that the stack trace contains at least two elements, one for this method and one for the caller.
if (stack.length >= 2)
{
className = stack[1].getClassName();
methodName = stack[1].getMethodName();
}
}*/
// Java 1.5 onwards only.
StackTraceElement[] stack = Thread.currentThread().getStackTrace();
// Check that the stack trace contains at least two elements, one for this method and one for the caller.
if (stack.length >= 2)
{
className = stack[1].getClassName();
methodName = stack[1].getMethodName();
}
// Java 1.3 and before? Not sure, some horrible thing that parses the text spat out by printStackTrace?
return getProperty(className, methodName, key);
}
|
java
|
{
"resource": ""
}
|
q180530
|
ContextualProperties.getProperties
|
test
|
public String[] getProperties(String key)
{
// Try to get the callers class name and method name by throwing an exception an searching the stack frames.
String className = null;
String methodName = null;
/* Java 1.4 onwards only.
try {
throw new Exception();
} catch (Exception e) {
StackTraceElement[] stack = e.getStackTrace();
// Check that the stack trace contains at least two elements, one for this method and one for the caller.
if (stack.length >= 2) {
className = stack[1].getClassName();
methodName = stack[1].getMethodName();
}
}*/
return getProperties(className, methodName, key);
}
|
java
|
{
"resource": ""
}
|
q180531
|
ContextualProperties.getKeyIterator
|
test
|
protected Iterator getKeyIterator(final String base, final String modifier, final String key)
{
return new Iterator()
{
// The key ordering count always begins at the start of the ORDER array.
private int i;
public boolean hasNext()
{
return (useDefaults ? ((i < ORDER.length) && (ORDER[i] > ENVIRONMENT_DEFAULTS_CUTOFF))
: (i < ORDER.length));
}
public Object next()
{
// Check that there is a next element and return null if not.
if (!hasNext())
{
return null;
}
// Get the next ordering count.
int o = ORDER[i];
// Do bit matching on the count to choose which elements to include in the key.
String result =
(((o & E) != 0) ? (environment + ".") : "") + (((o & B) != 0) ? (base + ".") : "") +
(((o & M) != 0) ? (modifier + ".") : "") + key;
// Increment the iterator to get the next key on the next call.
i++;
return result;
}
public void remove()
{
// This method is not supported.
throw new UnsupportedOperationException("remove() is not supported on this key order iterator as " +
"the ordering cannot be changed");
}
};
}
|
java
|
{
"resource": ""
}
|
q180532
|
ContextualProperties.createArrayProperties
|
test
|
protected void createArrayProperties()
{
// Scan through all defined properties.
for (Object o : keySet())
{
String key = (String) o;
String value = super.getProperty(key);
// Split the property key into everything before the last '.' and after it.
int lastDotIndex = key.lastIndexOf('.');
String keyEnding = key.substring(lastDotIndex + 1, key.length());
String keyStart = key.substring(0, (lastDotIndex == -1) ? 0 : lastDotIndex);
// Check if the property key ends in an integer, in which case it is an array property.
int index = 0;
try
{
index = Integer.parseInt(keyEnding);
}
catch (NumberFormatException e)
{
// The ending is not an integer so its not an array.
// Exception can be ignored as it means this property is not an array.
e = null;
continue;
}
// Check if an array property already exists for this base name and create one if not.
ArrayList propArray = (ArrayList) arrayProperties.get(keyStart);
if (propArray == null)
{
propArray = new ArrayList();
arrayProperties.put(keyStart, propArray);
}
// Add the new property value to the array property for the index.
propArray.set(index, value);
}
}
|
java
|
{
"resource": ""
}
|
q180533
|
BaseThrottle.setRate
|
test
|
public void setRate(float hertz)
{
// Check that the argument is above zero.
if (hertz <= 0.0f)
{
throw new IllegalArgumentException("The throttle rate must be above zero.");
}
// Calculate the cycle time.
cycleTimeNanos = (long) (1000000000f / hertz);
// Reset the first pass flag.
firstCall = false;
firstCheckCall = false;
}
|
java
|
{
"resource": ""
}
|
q180534
|
UMinus.evaluate
|
test
|
protected NumericType evaluate(NumericType firstNumber)
{
// If the argument is a real number, then use real number arithmetic, otherwise use integer arithmetic.
if (firstNumber.isInteger())
{
return new IntLiteral(-firstNumber.intValue());
}
else
{
return new DoubleLiteral(-firstNumber.doubleValue());
}
}
|
java
|
{
"resource": ""
}
|
q180535
|
PropertyReaderBase.findProperties
|
test
|
protected void findProperties()
{
/*log.fine("findProperties: called");*/
// Try to load the properties from a file referenced by the system property matching
// the properties file name.
properties = getPropertiesUsingSystemProperty();
if (properties != null)
{
/*log.fine("loaded properties using the system property");*/
// The properties were succesfully located and loaded
return;
}
/*log.fine("failed to get properties from the system properties");*/
// Try to load the properties from a resource on the classpath using the current
// class loader
properties = getPropertiesUsingClasspath();
if (properties != null)
{
/*log.fine("loaded properties from the class path");*/
// The properties were succesfully located and loaded
return;
}
/*log.fine("failed to get properties from the classpath");*/
// Try to load the properties from a file relative to the current working directory
properties = getPropertiesUsingCWD();
if (properties != null)
{
/*log.fine("loaded properties from the current working directory");*/
// The properties were succesfully located and loaded
return;
}
/*log.fine("failed to get properties from the current working directory");*/
}
|
java
|
{
"resource": ""
}
|
q180536
|
PropertyReaderBase.getPropertiesUsingSystemProperty
|
test
|
protected Properties getPropertiesUsingSystemProperty()
{
/*log.fine("getPropertiesUsingSystemProperty: called");*/
// Get the path to the file from the system properties
/*log.fine("getPropertiesResourceName() = " + getPropertiesResourceName());*/
String path = System.getProperty(getPropertiesResourceName());
/*log.fine("properties resource name = " + getPropertiesResourceName());*/
/*log.fine("path = " + path);*/
// Use PropertiesHelper to try to load the properties from the path
try
{
return PropertiesHelper.getProperties(path);
}
catch (IOException e)
{
/*log.fine("Could not load properties from path " + path);*/
// Failure of this method is noted, so exception is ignored.
e = null;
}
return null;
}
|
java
|
{
"resource": ""
}
|
q180537
|
PropertyReaderBase.getPropertiesUsingClasspath
|
test
|
protected Properties getPropertiesUsingClasspath()
{
/*log.fine("getPropertiesUsingClasspath: called");*/
// Try to open the properties resource name as an input stream from the classpath
InputStream is = this.getClass().getClassLoader().getResourceAsStream(getPropertiesResourceName());
// Use PropertiesHelper to try to load the properties from the input stream if one was succesfully created
if (is != null)
{
try
{
return PropertiesHelper.getProperties(is);
}
catch (IOException e)
{
/*log.fine("Could not load properties from classpath");*/
// Failure of this method is noted, so exception is ignored.
e = null;
}
}
return null;
}
|
java
|
{
"resource": ""
}
|
q180538
|
PropertyReaderBase.getPropertiesUsingCWD
|
test
|
protected Properties getPropertiesUsingCWD()
{
/*log.fine("getPropertiesUsingCWD: called");*/
// Use PropertiesHelper to try to load the properties from a file or URl
try
{
return PropertiesHelper.getProperties(getPropertiesResourceName());
}
catch (IOException e)
{
/*log.fine("Could not load properties from file or URL " + getPropertiesResourceName());*/
// Failure of this method is noted, so exception is ignored.
e = null;
}
return null;
}
|
java
|
{
"resource": ""
}
|
q180539
|
BuiltInTransformVisitor.leaveFunctor
|
test
|
protected void leaveFunctor(Functor functor)
{
int pos = traverser.getPosition();
if (!traverser.isInHead() && (pos >= 0))
{
Functor transformed = builtInTransform.apply(functor);
if (functor != transformed)
{
/*log.fine("Transformed: " + functor + " to " + transformed.getClass());*/
BuiltInFunctor builtInFunctor = (BuiltInFunctor) transformed;
Term parentTerm = traverser.getParentContext().getTerm();
if (parentTerm instanceof Clause)
{
Clause parentClause = (Clause) parentTerm;
parentClause.getBody()[pos] = builtInFunctor;
}
else if (parentTerm instanceof Functor)
{
Functor parentFunctor = (Functor) parentTerm;
parentFunctor.getArguments()[pos] = builtInFunctor;
}
}
}
}
|
java
|
{
"resource": ""
}
|
q180540
|
Variable.getValue
|
test
|
public Term getValue()
{
Term result = this;
Term assignment = this.substitution;
// If the variable is assigned, loops down the chain of assignments until no more can be found. Whatever term
// is found at the end of the chain of assignments is the value of this variable.
while (assignment != null)
{
result = assignment;
if (!assignment.isVar())
{
break;
}
else
{
assignment = ((Variable) assignment).substitution;
}
}
return result;
}
|
java
|
{
"resource": ""
}
|
q180541
|
Variable.setSubstitution
|
test
|
public void setSubstitution(Term term)
{
Term termToBindTo = term;
// When binding against a variable, always bind to its storage cell and not the variable itself.
if (termToBindTo instanceof Variable)
{
Variable variableToBindTo = (Variable) term;
termToBindTo = variableToBindTo.getStorageCell(variableToBindTo);
}
substitution = termToBindTo;
}
|
java
|
{
"resource": ""
}
|
q180542
|
GreedySearch.createQueue
|
test
|
public Queue<SearchNode<O, T>> createQueue()
{
return new PriorityQueue<SearchNode<O, T>>(11, new GreedyComparator());
}
|
java
|
{
"resource": ""
}
|
q180543
|
SilentFailSocketAppender.cleanUp
|
test
|
public void cleanUp()
{
if (oos != null)
{
try
{
oos.close();
}
catch (IOException e)
{
LogLog.error("Could not close oos.", e);
}
oos = null;
}
if (connector != null)
{
// LogLog.debug("Interrupting the connector.");
connector.interrupted = true;
connector = null; // allow gc
}
}
|
java
|
{
"resource": ""
}
|
q180544
|
SilentFailSocketAppender.append
|
test
|
public void append(LoggingEvent event)
{
if (event == null)
{
return;
}
if (address == null)
{
errorHandler.error("No remote host is set for SocketAppender named \"" + this.name + "\".");
return;
}
if (oos != null)
{
try
{
if (locationInfo)
{
event.getLocationInformation();
}
oos.writeObject(event);
// LogLog.debug("=========Flushing.");
oos.flush();
if (++counter >= RESET_FREQUENCY)
{
counter = 0;
// Failing to reset the object output stream every now and
// then creates a serious memory leak.
// System.err.println("Doing oos.reset()");
oos.reset();
}
}
catch (IOException e)
{
oos = null;
LogLog.warn("Detected problem with connection: " + e);
if (reconnectionDelay > 0)
{
fireConnector();
}
}
}
}
|
java
|
{
"resource": ""
}
|
q180545
|
SilentFailSocketAppender.fireConnector
|
test
|
void fireConnector()
{
if (connector == null)
{
LogLog.debug("Starting a new connector thread.");
connector = new Connector();
connector.setDaemon(true);
connector.setPriority(Thread.MIN_PRIORITY);
connector.start();
}
}
|
java
|
{
"resource": ""
}
|
q180546
|
WAMCompiledTermsPrintingVisitor.initializePrinters
|
test
|
protected void initializePrinters()
{
int maxColumns = 0;
printers.add(new SourceClausePrinter(interner, symbolTable, traverser, maxColumns++, printTable));
printers.add(new PositionPrinter(interner, symbolTable, traverser, maxColumns++, printTable));
printers.add(new UnoptimizedLabelPrinter(interner, symbolTable, traverser, maxColumns++, printTable));
printers.add(new UnoptimizedByteCodePrinter(interner, symbolTable, traverser, maxColumns++, printTable));
printers.add(new LabelPrinter(interner, symbolTable, traverser, maxColumns++, printTable));
printers.add(new ByteCodePrinter(interner, symbolTable, traverser, maxColumns++, printTable));
}
|
java
|
{
"resource": ""
}
|
q180547
|
GlobalWriteLockWithWriteBehindTxMethod.commit
|
test
|
public void commit()
{
TxId txId = null;
// Check if in a higher transactional mode than none, otherwise commit does nothing.
if (!getIsolationLevel().equals(IsolationLevel.None))
{
// Extract the current transaction id.
txId = TxManager.getTxIdFromThread();
// Wait until the global write lock can be acquired by this transaction.
try
{
acquireGlobalWriteLock(txId);
}
catch (InterruptedException e)
{
// The commit was interrupted, so cannot succeed.
throw new IllegalStateException("Interrupted whilst commit is waiting for global write lock.", e);
}
// Check that this transaction has made changes to be committed.
List<TxOperation> alterations = txWrites.get(txId);
try
{
if (alterations != null)
{
// Loop through all the writes that the transaction wants to apply to the resource.
for (TxOperation nextAlteration : alterations)
{
// Apply the change and update the term resource.
nextAlteration.execute();
}
// Clear the write behind cache for this transaction as its work has been completed.
txWrites.remove(txId);
}
}
finally
{
// Release the global write lock.
releaseGlobalWriteLock();
}
}
}
|
java
|
{
"resource": ""
}
|
q180548
|
GlobalWriteLockWithWriteBehindTxMethod.rollback
|
test
|
public void rollback()
{
TxId txId = null;
// Check if in a higher transactional mode than none, otherwise commit does nothing.
if (!getIsolationLevel().equals(IsolationLevel.None))
{
// Extract the current transaction id.
txId = TxManager.getTxIdFromThread();
// Check that this transaction has made changes to be rolled back.
List<TxOperation> alterations = txWrites.get(txId);
if (alterations != null)
{
// Loop through all the writes that the transaction wants to apply to the resource.
for (TxOperation nextAlteration : alterations)
{
// Cancel the operation.
nextAlteration.cancel(false);
}
}
// Discard all the changes that the transaction was going to make.
txWrites.remove(txId);
}
}
|
java
|
{
"resource": ""
}
|
q180549
|
GlobalWriteLockWithWriteBehindTxMethod.requestWriteOperation
|
test
|
public void requestWriteOperation(TxOperation op)
{
// Check if in a higher transactional mode than none and capture the transaction id if so.
TxId txId = null;
if (getIsolationLevel().compareTo(IsolationLevel.None) > 0)
{
// Extract the current transaction id.
txId = TxManager.getTxIdFromThread();
// Ensure that this resource is enlisted with the current session.
enlistWithSession();
}
// For non-transactional isolation levels, apply the requested operation immediately.
if (getIsolationLevel().equals(IsolationLevel.None))
{
op.execute();
}
// Add the operation to the transaction write-behind cache for the transaction id, if using transactional
// isolation, to defer the operation untill commit time.
else
{
addCachedOperation(txId, op);
}
}
|
java
|
{
"resource": ""
}
|
q180550
|
GlobalWriteLockWithWriteBehindTxMethod.addCachedOperation
|
test
|
private void addCachedOperation(TxId txId, TxOperation cachedWriteOperation)
{
List<TxOperation> writeCache = txWrites.get(txId);
if (writeCache == null)
{
writeCache = new ArrayList<TxOperation>();
txWrites.put(txId, writeCache);
}
writeCache.add(cachedWriteOperation);
}
|
java
|
{
"resource": ""
}
|
q180551
|
GlobalWriteLockWithWriteBehindTxMethod.acquireGlobalWriteLock
|
test
|
private void acquireGlobalWriteLock(TxId txId) throws InterruptedException
{
// Get the global write lock to ensure only one thread at a time can execute this code.
globalLock.writeLock().lock();
// Use a try block so that the corresponding finally block guarantees release of the thread lock.
try
{
// Check that this transaction does not already own the lock.
if (!txId.equals(globalWriteLockTxId))
{
// Wait until the write lock becomes free.
while (globalWriteLockTxId != null)
{
globalWriteLockFree.await();
}
// Assign the global write lock to this transaction.
globalWriteLockTxId = txId;
}
}
finally
{
// Ensure that the thread lock is released once assignment of the write lock to the transaction is complete.
globalLock.writeLock().unlock();
}
}
|
java
|
{
"resource": ""
}
|
q180552
|
GlobalWriteLockWithWriteBehindTxMethod.releaseGlobalWriteLock
|
test
|
private void releaseGlobalWriteLock()
{
// Get the global write lock to ensure only one thread at a time can execute this code.
globalLock.writeLock().lock();
// Use a try block so that the corresponding finally block guarantees release of the thread lock.
try
{
// Release the global write lock, assigning it to no transaction.
globalWriteLockTxId = null;
// Signal that the write lock is now free.
globalWriteLockFree.signal();
}
// Ensure that the thread lock is released once assignment of the write lock to the transaction is complete.
finally
{
globalLock.writeLock().unlock();
}
}
|
java
|
{
"resource": ""
}
|
q180553
|
GlobalWriteLockWithWriteBehindTxMethod.enlistWithSession
|
test
|
private void enlistWithSession()
{
TxSession session = TxSessionImpl.getCurrentSession();
// Ensure that this resource is being used within a session.
if (session == null)
{
throw new IllegalStateException("Cannot access transactional resource outside of a session.");
}
// Ensure that this resource is enlisted with the session.
session.enlist(this);
}
|
java
|
{
"resource": ""
}
|
q180554
|
NestedMediaQueries.enter
|
test
|
@Override
public boolean enter(RuleSetNode ruleSetNode) {
ScopeNode scopeNode = NodeTreeUtils.getFirstChild(ruleSetNode, ScopeNode.class);
SelectorGroupNode selectorGroupNode = NodeTreeUtils.getFirstChild(ruleSetNode, SelectorGroupNode.class);
if (selectorGroupNode == null) {
return true;
}
List<SelectorNode> selectorNodes = NodeTreeUtils.getChildren(selectorGroupNode, SelectorNode.class);
if (selectorNodes.size() < 0) {
return true;
}
List<MediaQueryNode> mediaQueryNodes = NodeTreeUtils.getAndRemoveChildren(scopeNode, MediaQueryNode.class);
for (MediaQueryNode mediaQueryNode : mediaQueryNodes) {
ScopeNode mediaScopeNode = NodeTreeUtils.getFirstChild(mediaQueryNode, ScopeNode.class);
List<RuleSetNode> nestedRuleSets = NodeTreeUtils.getAndRemoveChildren(mediaScopeNode, RuleSetNode.class);
// if scope node for media query has anything more but whitespaces and rule sets than wrap it with rule set with the same selector group as outer rule set has
if (mediaScopeNode.getChildren().size() > NodeTreeUtils.getChildren(mediaScopeNode, WhiteSpaceCollectionNode.class).size()) {
RuleSetNode newRuleSetNode = new RuleSetNode();
ScopeNode newScopeNode = new ScopeNode();
newRuleSetNode.addChild(selectorGroupNode.clone());
newRuleSetNode.addChild(newScopeNode);
NodeTreeUtils.moveChildren(mediaScopeNode, newScopeNode);
mediaScopeNode.clearChildren();
mediaScopeNode.addChild(newRuleSetNode);
}
// adding outer selectors to every nested selectors
for (RuleSetNode nestedRuleSet : nestedRuleSets) {
List<SelectorGroupNode> nestedSelectorGroupNodes = NodeTreeUtils.getChildren(nestedRuleSet, SelectorGroupNode.class);
for (SelectorGroupNode nestedSelectorGroupNode : nestedSelectorGroupNodes) {
List<SelectorNode> nestedSelectorNodes = NodeTreeUtils.getAndRemoveChildren(nestedSelectorGroupNode, SelectorNode.class);
NodeTreeUtils.getAndRemoveChildren(nestedSelectorGroupNode, SpacingNode.class);
for (SelectorNode selectorNode : selectorNodes) {
for (SelectorNode nestedSelectorNode : nestedSelectorNodes) {
if (nestedSelectorNode.getChildren().get(0) != null) {
if (nestedSelectorNode.getChildren().get(0) instanceof SelectorSegmentNode) {
SelectorSegmentNode selectorSegmentNode = (SelectorSegmentNode) nestedSelectorNode.getChildren().get(0);
selectorSegmentNode.setCombinator(" ");
}
}
for (int j = selectorNode.getChildren().size() - 1; j >= 0; j--) {
if (selectorNode.getChildren().get(j) instanceof SelectorSegmentNode) {
SelectorSegmentNode selectorSegmentNode = (SelectorSegmentNode) selectorNode.getChildren().get(j).clone();
nestedSelectorNode.addChild(0, selectorSegmentNode);
}
}
nestedSelectorGroupNode.addChild(nestedSelectorNode);
nestedSelectorGroupNode.addChild(new SpacingNode(" "));
}
}
}
mediaScopeNode.addChild(nestedRuleSet);
}
if (ruleSetNode.getParent() != null) {
ruleSetNode.getParent().addChild(new SpacingNode("\n"));
ruleSetNode.getParent().addChild(mediaQueryNode);
}
}
return true;
}
|
java
|
{
"resource": ""
}
|
q180555
|
BatchSynchQueueBase.offer
|
test
|
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
{
if (e == null)
{
throw new IllegalArgumentException("The 'e' parameter may not be null.");
}
ReentrantLock lock = this.lock;
lock.lockInterruptibly();
long nanos = unit.toNanos(timeout);
try
{
do
{
if (insert(e, false))
{
return true;
}
try
{
nanos = notFull.awaitNanos(nanos);
}
catch (InterruptedException ie)
{
// Wake up another thread waiting on notFull, as the condition may be true, but this thread
// was interrupted so cannot make use of it.
notFull.signal();
throw ie;
}
}
while (nanos > 0);
return false;
}
finally
{
lock.unlock();
}
}
|
java
|
{
"resource": ""
}
|
q180556
|
BatchSynchQueueBase.poll
|
test
|
public E poll(long timeout, TimeUnit unit) throws InterruptedException
{
ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try
{
long nanos = unit.toNanos(timeout);
do
{
if (count != 0)
{
return extract(true, true).getElement();
}
try
{
nanos = notEmpty.awaitNanos(nanos);
}
catch (InterruptedException ie)
{
notEmpty.signal(); // propagate to non-interrupted thread
throw ie;
}
}
while (nanos > 0);
return null;
}
finally
{
lock.unlock();
}
}
|
java
|
{
"resource": ""
}
|
q180557
|
BatchSynchQueueBase.put
|
test
|
public void put(E e) throws InterruptedException
{
try
{
tryPut(e);
}
catch (SynchException ex)
{
// This exception is deliberately ignored. See the method comment for information about this.
ex = null;
}
}
|
java
|
{
"resource": ""
}
|
q180558
|
BatchSynchQueueBase.insert
|
test
|
protected boolean insert(E element, boolean unlockAndBlock)
{
// Create a new record for the data item.
SynchRecordImpl<E> record = new SynchRecordImpl<E>(element);
boolean result = buffer.offer(record);
if (result)
{
count++;
// Tell any waiting consumers that the queue is not empty.
notEmpty.signal();
if (unlockAndBlock)
{
// Allow other threads to read/write the queue.
lock.unlock();
// Wait until a consumer takes this data item.
record.waitForConsumer();
}
return true;
}
else
{
return false;
}
}
|
java
|
{
"resource": ""
}
|
q180559
|
ClientIterator.next
|
test
|
public Object next()
{
try
{
Object ob = source.next();
return ob;
}
catch (RemoteException e)
{
throw new IllegalStateException(e);
}
}
|
java
|
{
"resource": ""
}
|
q180560
|
ParsedProperties.getPropertyAsBoolean
|
test
|
public boolean getPropertyAsBoolean(String propName)
{
String prop = getProperty(propName);
return (prop != null) && Boolean.parseBoolean(prop);
}
|
java
|
{
"resource": ""
}
|
q180561
|
ParsedProperties.getPropertyAsInteger
|
test
|
public Integer getPropertyAsInteger(String propName)
{
String prop = getProperty(propName);
return (prop != null) ? Integer.valueOf(prop) : null;
}
|
java
|
{
"resource": ""
}
|
q180562
|
ParsedProperties.getPropertyAsLong
|
test
|
public Long getPropertyAsLong(String propName)
{
String prop = getProperty(propName);
return (prop != null) ? Long.valueOf(prop) : null;
}
|
java
|
{
"resource": ""
}
|
q180563
|
ScopeNode.callMixin
|
test
|
public ScopeNode callMixin(String name, ArgumentsNode arguments) {
List<ExpressionGroupNode> argumentList = (arguments != null) ? NodeTreeUtils.getChildren(arguments, ExpressionGroupNode.class) : Collections.<ExpressionGroupNode>emptyList();
if (argumentList.size() > _parameterDefinitions.size()) {
throw new IllegalMixinArgumentException(name, _parameterDefinitions.size());
}
// Clone scope and filter out any white space
ScopeNode mixinScope = clone();
NodeTreeUtils.filterLineBreaks(mixinScope);
// If arguments were passed, apply them
for (int i = 0; i < argumentList.size(); i++) {
ExpressionGroupNode argument = argumentList.get(i);
// Replace the value of the definition
VariableDefinitionNode parameter = mixinScope._parameterDefinitions.get(i);
parameter.clearChildren();
parameter.addChild(argument);
}
// Mark this scope's containing rule set as invisible since it has been used as a mixin
getParent().setVisible(false);
return mixinScope;
}
|
java
|
{
"resource": ""
}
|
q180564
|
ScopeNode.setAdditionVisitor
|
test
|
private void setAdditionVisitor() {
setAdditionVisitor(new InclusiveNodeVisitor() {
/**
* Add parameter set as a child for printing input, but also add each defined value to the variable map.
*/
@Override
public boolean add(ParametersNode node) {
for (VariableDefinitionNode variable : NodeTreeUtils.getChildren(node, VariableDefinitionNode.class)) {
_parameterDefinitions.add(variable);
add(variable);
}
return super.add(node);
}
/**
* Store the rule set's scope by selector group
*/
@Override
public boolean add(RuleSetNode node) {
SelectorGroupNode selectorGroup = NodeTreeUtils.getFirstChild(node, SelectorGroupNode.class);
for (SelectorNode selectorNode : NodeTreeUtils.getChildren(selectorGroup, SelectorNode.class)) {
StringBuilder sb = new StringBuilder();
for (Node selectorChild : selectorNode.getChildren()) {
sb.append(selectorChild.toString());
}
String selector = sb.toString();
// Mixins lock on first definition
if (!_selectorToRuleSetMap.containsKey(selector)) {
_selectorToRuleSetMap.put(selector, node);
}
}
return super.add(node);
}
/**
* Absorb all children of the given scope. This assumes that cloning is not necessary.
*/
@Override
public boolean add(ScopeNode node) {
NodeTreeUtils.moveChildren(node, ScopeNode.this);
return false; // Don't add the original scope itself
}
/**
* Store variable definitions in a map by name
*/
@Override
public boolean add(VariableDefinitionNode node) {
String name = node.getName();
// "Variables" lock on first definition
if (!_variableNameToValueMap.containsKey(name)) {
_variableNameToValueMap.put(name, NodeTreeUtils.getFirstChild(node, ExpressionGroupNode.class));
}
return super.add(node);
}
/**
* Store property nodes by name. If there are multiple properties for a given name, only retain the last one.
*/
@Override
public boolean add(PropertyNode node) {
String name = node.getName();
// If this is the IE-specific "filter" property, always add it
if (name.equals(FILTER_PROPERTY)) {
return super.add(node);
}
// If the value of this property node is a vendor-specific keyword, always add it
if (node.getChildren().get(0).toString().startsWith("-")) {
return super.add(node);
}
// Check if this property has been seen before
if (_propertyNameToNodeMap.containsKey(name)) {
PropertyNode oldPropertyNode = _propertyNameToNodeMap.get(name);
int oldPropertyIndex = getChildren().indexOf(oldPropertyNode);
if (oldPropertyNode.isVisible()) {
// Hide the unneeded property
oldPropertyNode.setVisible(false);
// Attempt to hide one surrounding white space node
if (!hideWhiteSpaceNode(oldPropertyIndex - 1)) {
hideWhiteSpaceNode(oldPropertyIndex + 1);
}
}
}
// Store the property as the latest for this name
_propertyNameToNodeMap.put(name, node);
return super.add(node);
}
});
}
|
java
|
{
"resource": ""
}
|
q180565
|
BacktrackingAlgorithm.backtrack
|
test
|
protected void backtrack(SearchNode checkNode)
{
while ((checkNode != null) && (checkNode.unexaminedSuccessorCount == 0))
{
Reversable undoState = (ReTraversable) checkNode.getState();
undoState.undoOperator();
checkNode = checkNode.getParent();
}
}
|
java
|
{
"resource": ""
}
|
q180566
|
WAMResolvingMachine.retrieveCode
|
test
|
public byte[] retrieveCode(WAMCallPoint callPoint)
{
byte[] result = new byte[callPoint.length];
codeBuffer.get(result, callPoint.entryPoint, callPoint.length);
return result;
}
|
java
|
{
"resource": ""
}
|
q180567
|
WAMResolvingMachine.executeAndExtractBindings
|
test
|
protected Set<Variable> executeAndExtractBindings(WAMCompiledQuery query)
{
// Execute the query and program. The starting point for the execution is the first functor in the query
// body, this will follow on to the subsequent functors and make calls to functors in the compiled programs.
boolean success = execute(query.getCallPoint());
// Used to collect the results in.
Set<Variable> results = null;
// Collect the results only if the resolution was successfull.
if (success)
{
results = new HashSet<Variable>();
// The same variable context is used accross all of the results, for common use of variables in the
// results.
Map<Integer, Variable> varContext = new HashMap<Integer, Variable>();
// For each of the free variables in the query, extract its value from the location on the heap pointed to
// by the register that holds the variable.
/*log.fine("query.getVarNames().size() = " + query.getVarNames().size());*/
for (byte reg : query.getVarNames().keySet())
{
int varName = query.getVarNames().get(reg);
if (query.getNonAnonymousFreeVariables().contains(varName))
{
int addr = derefStack(reg);
Term term = decodeHeap(addr, varContext);
results.add(new Variable(varName, term, false));
}
}
}
return results;
}
|
java
|
{
"resource": ""
}
|
q180568
|
WAMResolvingMachine.decodeHeap
|
test
|
protected Term decodeHeap(int start, Map<Integer, Variable> variableContext)
{
/*log.fine("private Term decodeHeap(int start = " + start + ", Map<Integer, Variable> variableContext = " +
variableContext + "): called");*/
// Used to hold the decoded argument in.
Term result = null;
// Dereference the initial heap pointer.
int addr = deref(start);
byte tag = getDerefTag();
int val = getDerefVal();
/*log.fine("addr = " + addr);*/
/*log.fine("tag = " + tag);*/
/*log.fine("val = " + val);*/
switch (tag)
{
case REF:
{
// Check if a variable for the address has already been created in this context, and use it if so.
Variable var = variableContext.get(val);
if (var == null)
{
var = new Variable(varNameId.decrementAndGet(), null, false);
variableContext.put(val, var);
}
result = var;
break;
}
case STR:
{
// Decode f/n from the STR data.
int fn = getHeap(val);
int f = fn & 0x00ffffff;
/*log.fine("fn = " + fn);*/
/*log.fine("f = " + f);*/
// Look up and initialize this functor name from the symbol table.
FunctorName functorName = getDeinternedFunctorName(f);
// Fill in this functors name and arity and allocate storage space for its arguments.
int arity = functorName.getArity();
Term[] arguments = new Term[arity];
// Loop over all of the functors arguments, recursively decoding them.
for (int i = 0; i < arity; i++)
{
arguments[i] = decodeHeap(val + 1 + i, variableContext);
}
// Create a new functor to hold the decoded data.
result = new Functor(f, arguments);
break;
}
case WAMInstruction.CON:
{
//Decode f/n from the CON data.
int f = val & 0x3fffffff;
/*log.fine("f = " + f);*/
// Create a new functor to hold the decoded data.
result = new Functor(f, null);
break;
}
case WAMInstruction.LIS:
{
FunctorName functorName = new FunctorName("cons", 2);
int f = internFunctorName(functorName);
// Fill in this functors name and arity and allocate storage space for its arguments.
int arity = functorName.getArity();
Term[] arguments = new Term[arity];
// Loop over all of the functors arguments, recursively decoding them.
for (int i = 0; i < arity; i++)
{
arguments[i] = decodeHeap(val + i, variableContext);
}
// Create a new functor to hold the decoded data.
result = new Functor(f, arguments);
break;
}
default:
throw new IllegalStateException("Encountered unknown tag type on the heap.");
}
return result;
}
|
java
|
{
"resource": ""
}
|
q180569
|
DirectMemento.capture
|
test
|
public void capture()
{
// Get the class of the object to build a memento for.
Class cls = ob.getClass();
// Iterate through the classes whole inheritence chain.
while (!cls.equals(Object.class))
{
// Get the classes fields.
Field[] attrs = cls.getDeclaredFields();
// Build a new map to put the fields in for the current class.
HashMap map = new HashMap();
// Cache the field values by the class name.
values.put(cls, map);
// Loop over all the fields in the current class.
for (Field attr : attrs)
{
// Make the field accessible (it may be protected or private).
attr.setAccessible(true);
// Check that the field should be captured.
if (shouldBeSaved(attr))
{
// Use a try block as access to the field may fail, although this should not happen because
// even private, protected and package fields have been made accessible.
try
{
// Cache the field by its name.
map.put(attr.getName(), attr.get(ob));
}
catch (IllegalAccessException e)
{
// The field could not be accessed but all fields have been made accessible so this should
// not happen.
throw new IllegalStateException("Field '" + attr.getName() +
"' could not be accessed but the 'setAccessible(true)' method was invoked on it.", e);
}
}
}
// Get the superclass for the next step of the iteration over the whole inheritence chain.
cls = cls.getSuperclass();
}
}
|
java
|
{
"resource": ""
}
|
q180570
|
DirectMemento.restore
|
test
|
public void restore(Object ob) throws NoSuchFieldException
{
/*log.fine("public void map(Object ob): called");*/
/*log.fine("class is " + ob.getClass());*/
// Iterate over the whole inheritence chain.
for (Object key : values.keySet())
{
// Get the next class from the cache.
Class cls = (Class) key;
// Get the cache of field values for the class.
Map vals = (HashMap) values.get(cls);
// Loop over all fields in the class.
for (Object o : vals.keySet())
{
// Get the next field name.
String attr = (String) o;
// Get the next field value.
Object val = vals.get(attr);
// Get a reference to the field in the object.
Field f = cls.getDeclaredField(attr);
// Make the field accessible (it may be protected, package or private).
f.setAccessible(true);
// Use a try block as writing to the field may fail.
try
{
// Write to the field.
f.set(ob, val);
}
catch (IllegalAccessException e)
{
// The field could not be written to but all fields have been made accessible so this should
// not happen.
throw new IllegalStateException("Field '" + f.getName() +
"' could not be accessed but the 'setAccessible(true)' method was invoked on it.", e);
}
}
}
}
|
java
|
{
"resource": ""
}
|
q180571
|
DirectMemento.get
|
test
|
public Object get(Class cls, String attr)
{
HashMap map;
// See if the class exists in the cache.
if (!values.containsKey(cls))
{
// Class not in cache so return null.
return null;
}
// Get the cache of field values for the class.
map = (HashMap) values.get(cls);
// Extract the specified field from the cache.
return map.get(attr);
}
|
java
|
{
"resource": ""
}
|
q180572
|
DirectMemento.put
|
test
|
public void put(Class cls, String attr, Object val)
{
/*log.fine("public void put(Class cls, String attr, Object val): called");*/
/*log.fine("class name is " + cls.getName());*/
/*log.fine("attribute is " + attr);*/
/*log.fine("value to set is " + val);*/
HashMap map;
// Check that the cache for the class exists in the cache.
if (values.containsKey(cls))
{
// Get the cache of field for the class.
map = (HashMap) values.get(cls);
}
else
{
// The class does not already exist in the cache to create a new cache for its fields.
map = new HashMap();
// Cache the new field cache against the class.
values.put(cls, map);
}
// Store the attribute in the field cache for the class.
map.put(attr, val);
}
|
java
|
{
"resource": ""
}
|
q180573
|
DirectMemento.getAllFieldNames
|
test
|
public Collection getAllFieldNames(Class cls)
{
/*log.fine("public Collection getAllFieldNames(Class cls): called");*/
// See if the class exists in the cache
if (!values.containsKey(cls))
{
// Class not in cache so return null
return null;
}
// Get the cache of fields for the class
Map map = (HashMap) values.get(cls);
// Return all the keys from cache of fields
return map.keySet();
}
|
java
|
{
"resource": ""
}
|
q180574
|
ProductionScriptGenMojo.execute
|
test
|
public void execute() throws MojoExecutionException, MojoFailureException
{
//log.debug("public void execute() throws MojoExecutionException: called");
// Turn each of the test runner command lines into a script.
for (String commandName : commands.keySet())
{
if (prodScriptOutDirectory != null)
{
writeUnixScript(commandName, prodScriptOutDirectory);
writeWindowsScript(commandName, prodScriptOutDirectory);
}
}
}
|
java
|
{
"resource": ""
}
|
q180575
|
LockFreeNQueue.offer
|
test
|
public boolean offer(E o)
{
/*log.fine("public boolean offer(E o): called");*/
/*log.fine("o = " + o);*/
// Ensure that the item to add is not null.
if (o == null)
{
throw new IllegalArgumentException("The 'o' parameter may not be null.");
}
// Derive the integer priority of the element using the priority function, shift it into this queues range if
// necessary and adjust it to any offset caused by lowest priority not equal to zero.
int level = priorityToLevel(p.apply(o));
/*log.fine("offer level = " + level);*/
// Create a new node to hold the new data element.
Node<E> newNode = new DataNode<E>(o, markers[level + 1]);
// Add the element to the tail of the queue with matching level, looping until this can complete as an atomic
// operation.
while (true)
{
// Get tail and next ref. Would expect next ref to be null, but other thread may update it.
Node<E> t = markers[level + 1].getTail();
Node<E> s = t.getNext();
/*log.fine("t = " + t);*/
/*log.fine("s = " + s);*/
// Recheck the tail ref, to ensure other thread has not already moved it. This can potentially prevent
// a relatively expensive compare and set from failing later on, if another thread has already shited
// the tail.
if (t == markers[level + 1].getTail())
{
/*log.fine("t is still the tail.");*/
// Check that the next element reference on the tail is the tail marker, to confirm that another thread
// has not updated it. Again, this may prevent a cas from failing later.
if (s == markers[level + 1])
{
/*log.fine("s is the tail marker.");*/
// Try to join the new tail onto the old one.
if (t.casNext(s, newNode))
{
// The tail join was succesfull, so now update the queues tail reference. No conflict should
// occurr here as the tail join was succesfull, so its just a question of updating the tail
// reference. A compare and set is still used because ...
markers[level + 1].casTail(t, newNode);
// Increment the queue size count.
count.incrementAndGet();
return true;
}
}
// Update the tail reference, other thread may also be doing the same.
else
{
// Why bother doing this at all? I suppose, because another thread may be stalled and doing this
// will enable this one to keep running.
// Update the tail reference for the queue because another thread has already added a new tail
// but not yet managed to update the tail reference.
markers[level + 1].casTail(t, s);
}
}
}
}
|
java
|
{
"resource": ""
}
|
q180576
|
LockFreeNQueue.poll
|
test
|
public E poll()
{
/*log.fine("public E poll(): called");*/
// This is used to keep track of the level of the list that is found to have data in it.
int currentLevel = 0;
while (true)
{
// This is used to locate the marker head of a list that contains data.
Marker<E> h = null;
// This is used to locate the potential data node of a list with data in it. Another thread may already
// have taken this data.
Node<E> first = null;
// Second data item, may also be tail marker, first data item of next list, or null at end of last list.
Node<E> second = null;
// Loop down any empty lists at the front of the queue until a list with data in it is found.
for (; currentLevel < n; currentLevel++)
{
h = markers[currentLevel];
first = h.getNext();
second = first.getNext();
// Check if the list at the current level is not empty and should be tried for data.
if (!h.isEmpty(markers[currentLevel + 1]))
{
break;
}
// Check if the current level is empty and is the last level, in which case return null.
else if (currentLevel == (n - 1))
{
// log.info("returning null from level loop.");
return null;
}
// Else if the current level is empty loop to the next one to see if it has data.
}
/*log.fine("current poll level = " + currentLevel);*/
// This is used to locate the tail of the list that has been found with data in it.
Node<E> t = markers[currentLevel + 1].getTail();
// Check that the first data item has not yet been taken. Another thread may already have taken it,
// in which case performing a relatively expensive cas on the head will fail. If first is still intact
// then second will be intact too.
if (first == h.getNext())
{
// Check if the queue has become empty.
if (h.isEmpty(markers[currentLevel + 1]))
{
// Another thread has managed to take data from the queue, leaving it empty.
// First won't be null. It may point to tail though...
if (first == null)
{
// Don't want to return here, want to try the next list. The list loop has a return null
// once it gets to the end to take care of that.
// log.info("returning null as first == null");
return null;
}
else
{
// Not sure yet why castail here? Does this repair a broken tail ref left after the last item
// was taken?
markers[currentLevel + 1].casTail(t, first);
}
}
// The queue contains data, so try to move its head marker reference from the first data item, onto the
// second item (which may be data, or the tail marker). If this succeeds, then the first data node
// has been atomically extracted from the head of the queue.
else if (h.casNext(first, second))
{
// h Does not refer to an empty queue, so first must be a data node.
DataNode<E> firstDataNode = ((DataNode<E>) first);
E item = firstDataNode.getItem();
// Even though the empty test did not indicate that the list was empty, it may contain null
// data items, because the remove method doesn't extract nodes on a remove. These need to be skipped
// over. Could they be removed here?
if (item != null)
{
firstDataNode.setItem(null);
/*log.fine("returing item = " + item);*/
// Decrement the queue size count.
count.decrementAndGet();
return item;
}
// else skip over deleted item, continue trying at this level. Go back an retry starting from same
// level. List at this level may now be empty, or may get the next item from it.
// else skip over marker element. just make markers return null for item to skip them? No, because
// need to advance currentLevel and get head and tail markers for the next level. but then, next
// level advance will occur when this level is retried and found to be empty won't it?
}
}
}
}
|
java
|
{
"resource": ""
}
|
q180577
|
UniformCostSearch.createSearchNode
|
test
|
public SearchNode<O, T> createSearchNode(T state)
{
return new SearchNode<O, T>(state);
}
|
java
|
{
"resource": ""
}
|
q180578
|
UniformCostSearch.createQueue
|
test
|
public Queue<SearchNode<O, T>> createQueue()
{
return new PriorityQueue<SearchNode<O, T>>(11, new UniformCostComparator());
}
|
java
|
{
"resource": ""
}
|
q180579
|
TermWalkers.simpleWalker
|
test
|
public static TermWalker simpleWalker(TermVisitor visitor)
{
DepthFirstBacktrackingSearch<Term, Term> search = new DepthFirstBacktrackingSearch<Term, Term>();
return new TermWalker(search, new DefaultTraverser(), visitor);
}
|
java
|
{
"resource": ""
}
|
q180580
|
TermWalkers.goalWalker
|
test
|
public static TermWalker goalWalker(UnaryPredicate<Term> unaryPredicate, TermVisitor visitor)
{
TermWalker walker = simpleWalker(visitor);
walker.setGoalPredicate(unaryPredicate);
return walker;
}
|
java
|
{
"resource": ""
}
|
q180581
|
TermWalkers.positionalWalker
|
test
|
public static TermWalker positionalWalker(PositionalTermVisitor visitor)
{
PositionalTermTraverser positionalTraverser = new PositionalTermTraverserImpl();
positionalTraverser.setContextChangeVisitor(visitor);
visitor.setPositionalTraverser(positionalTraverser);
return new TermWalker(new DepthFirstBacktrackingSearch<Term, Term>(), positionalTraverser, visitor);
}
|
java
|
{
"resource": ""
}
|
q180582
|
TermWalkers.positionalGoalWalker
|
test
|
public static TermWalker positionalGoalWalker(UnaryPredicate<Term> unaryPredicate, PositionalTermVisitor visitor)
{
TermWalker walker = positionalWalker(visitor);
walker.setGoalPredicate(unaryPredicate);
return walker;
}
|
java
|
{
"resource": ""
}
|
q180583
|
TermWalkers.positionalPostfixWalker
|
test
|
public static TermWalker positionalPostfixWalker(PositionalTermVisitor visitor)
{
PositionalTermTraverser positionalTraverser = new PositionalTermTraverserImpl();
positionalTraverser.setContextChangeVisitor(visitor);
visitor.setPositionalTraverser(positionalTraverser);
return new TermWalker(new PostFixSearch<Term, Term>(), positionalTraverser, visitor);
}
|
java
|
{
"resource": ""
}
|
q180584
|
PropertiesHelper.getProperties
|
test
|
public static Properties getProperties(InputStream is) throws IOException
{
/*log.fine("getProperties(InputStream): called");*/
// Create properties object laoded from input stream
Properties properties = new Properties();
properties.load(is);
return properties;
}
|
java
|
{
"resource": ""
}
|
q180585
|
PropertiesHelper.getProperties
|
test
|
public static Properties getProperties(File file) throws IOException
{
/*log.fine("getProperties(File): called");*/
// Open the file as an input stream
InputStream is = new FileInputStream(file);
// Create properties object loaded from the stream
Properties properties = getProperties(is);
// Close the file
is.close();
return properties;
}
|
java
|
{
"resource": ""
}
|
q180586
|
PropertiesHelper.getProperties
|
test
|
public static Properties getProperties(URL url) throws IOException
{
/*log.fine("getProperties(URL): called");*/
// Open the URL as an input stream
InputStream is = url.openStream();
// Create properties object loaded from the stream
Properties properties = getProperties(is);
// Close the url
is.close();
return properties;
}
|
java
|
{
"resource": ""
}
|
q180587
|
PropertiesHelper.getProperties
|
test
|
public static Properties getProperties(String pathname) throws IOException
{
/*log.fine("getProperties(String): called");*/
// Check that the path is not null
if (pathname == null)
{
return null;
}
// Check if the path is a URL
if (isURL(pathname))
{
// The path is a URL
return getProperties(new URL(pathname));
}
else
{
// Assume the path is a file name
return getProperties(new File(pathname));
}
}
|
java
|
{
"resource": ""
}
|
q180588
|
JTextGrid.computeGridSize
|
test
|
protected Dimension computeGridSize()
{
int cols = model.getWidth();
int rows = model.getHeight();
int horizSeparatorSize = 0;
for (int size : model.getHorizontalSeparators().values())
{
horizSeparatorSize += size;
}
int vertSeparatorSize = 0;
for (int size : model.getVerticalSeparators().values())
{
vertSeparatorSize += size;
}
return new Dimension(vertSeparatorSize + colToX(cols), horizSeparatorSize + rowToY(rows));
}
|
java
|
{
"resource": ""
}
|
q180589
|
JTextGrid.initializeFontMetrics
|
test
|
private void initializeFontMetrics()
{
if (!fontMetricsInitialized)
{
FontMetrics fontMetrics = getFontMetrics(getFont());
charWidth = fontMetrics.charWidth(' ');
charHeight = fontMetrics.getHeight();
descent = fontMetrics.getDescent();
fontMetricsInitialized = true;
}
}
|
java
|
{
"resource": ""
}
|
q180590
|
BaseState.addPropertyChangeListener
|
test
|
public void addPropertyChangeListener(PropertyChangeListener l)
{
// Check if the listneres list has been initialized
if (listeners == null)
{
// Listeneres list not intialized so create a new list
listeners = new ArrayList();
}
synchronized (listeners)
{
// Add the new listener to the list
listeners.add(l);
}
}
|
java
|
{
"resource": ""
}
|
q180591
|
BaseState.addPropertyChangeListener
|
test
|
public void addPropertyChangeListener(String p, PropertyChangeListener l)
{
// Check if the listeneres list has been initialized
if (listeners == null)
{
// Listeneres list not initialized so create a new list
listeners = new ArrayList();
}
synchronized (listeners)
{
// Add the new listener to the list
listeners.add(l);
}
}
|
java
|
{
"resource": ""
}
|
q180592
|
BaseState.removePropertyChangeListener
|
test
|
public void removePropertyChangeListener(String p, PropertyChangeListener l)
{
if (listeners == null)
{
return;
}
synchronized (listeners)
{
listeners.remove(l);
}
}
|
java
|
{
"resource": ""
}
|
q180593
|
BaseState.firePropertyChange
|
test
|
protected void firePropertyChange(PropertyChangeEvent evt)
{
/*log.fine("firePropertyChange: called");*/
// Take a copy of the event as a final variable so that it can be used in an inner class
final PropertyChangeEvent finalEvent = evt;
Iterator it;
// Check if the list of listeners is empty
if (listeners == null)
{
// There are no listeners so simply return without doing anything
return;
}
// synchronize on the list of listeners to prevent comodification
synchronized (listeners)
{
// Cycle through all listeners and notify them
it = listeners.iterator();
while (it.hasNext())
{
// Get the next listener from the list
final PropertyChangeListener l = (PropertyChangeListener) it.next();
// Notify the listener of the property change event
Runnable r =
new Runnable()
{
public void run()
{
// Fire a property change event
l.propertyChange(finalEvent);
}
};
// Run the property change event in the Swing event queue
SwingUtilities.invokeLater(r);
}
}
}
|
java
|
{
"resource": ""
}
|
q180594
|
DoubleRangeType.createInstance
|
test
|
public static Type createInstance(String name, double min, double max)
{
// Ensure that min is less than or equal to max.
if (min > max)
{
throw new IllegalArgumentException("'min' must be less than or equal to 'max'.");
}
synchronized (DOUBLE_RANGE_TYPES)
{
// Add the newly created type to the map of all types.
DoubleRangeType newType = new DoubleRangeType(name, min, max);
// Ensure that the named type does not already exist, unless it has an identical definition already, in which
// case the old definition can be re-used and the new one discarded.
DoubleRangeType oldType = DOUBLE_RANGE_TYPES.get(name);
if ((oldType != null) && !oldType.equals(newType))
{
throw new IllegalArgumentException("The type '" + name + "' already exists and cannot be redefined.");
}
else if ((oldType != null) && oldType.equals(newType))
{
return oldType;
}
else
{
DOUBLE_RANGE_TYPES.put(name, newType);
return newType;
}
}
}
|
java
|
{
"resource": ""
}
|
q180595
|
FaderImpl.doFade
|
test
|
public void doFade(ColorDelta target, String groupName)
{
FadeState fadeState = timers.get(groupName);
// Set up the color interpolator.
Iterator<Color> interpolator = new ColorInterpolator(startColor, endColor, 8).iterator();
if (fadeState == null)
{
// Create a new fade state for the target group, and a timer to run it.
Timer timer = new Timer(20, this);
fadeState = new FadeState(timer, target, interpolator);
timers.put(groupName, fadeState);
}
else
{
// Kill any previous fade and replace the target with the new one.
fadeState.timer.stop();
fadeState.target = target;
fadeState.interpolator = interpolator;
}
// Iterate to the initial color.
Color firstColor = fadeState.interpolator.next();
fadeState.target.changeColor(firstColor);
// Kick off the fade timer.
fadeState.timer.setActionCommand(groupName);
fadeState.timer.setInitialDelay(400);
fadeState.timer.start();
}
|
java
|
{
"resource": ""
}
|
q180596
|
SwingMainWindow.showHorizontalBar
|
test
|
private void showHorizontalBar()
{
// Left vertical bar.
Component bar = factory.createGripPanel(layout.getConsoleHeightResizer(), false);
frame.getContentPane().add(bar, DesktopAppLayout.STATUS_BAR);
}
|
java
|
{
"resource": ""
}
|
q180597
|
SwingMainWindow.showLeftBar
|
test
|
private void showLeftBar()
{
// Left vertical bar.
Component bar = factory.createGripPanel(layout.getLeftPaneWidthResizer(), true);
frame.getContentPane().add(bar, DesktopAppLayout.LEFT_VERTICAL_BAR);
}
|
java
|
{
"resource": ""
}
|
q180598
|
SwingMainWindow.showRightBar
|
test
|
private void showRightBar()
{
// Right vertical bar.
Component bar = factory.createGripPanel(layout.getRightPaneWidthResizer(), true);
frame.getContentPane().add(bar, DesktopAppLayout.RIGHT_VERTICAL_BAR);
}
|
java
|
{
"resource": ""
}
|
q180599
|
JsoupMicrodataDocument.sanitizeRadioControls
|
test
|
private static void sanitizeRadioControls(FormElement form)
{
Map<String, Element> controlsByName = new HashMap<String, Element>();
for (Element control : form.elements())
{
// cannot use Element.select since Element.hashCode collapses like elements
if ("radio".equals(control.attr("type")) && control.hasAttr("checked"))
{
String name = control.attr("name");
if (controlsByName.containsKey(name))
{
controlsByName.get(name).attr("checked", false);
}
controlsByName.put(name, control);
}
}
}
|
java
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.