_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q180300
SimpleTree.addChild
test
public void addChild(Tree<E> child) { initChildren(); // Add the new child to the collection of children. children.add(child); // Set the type of this point in the tree to a node as it now has children. nodeOrLeaf = Type.Node; // Set the new childs parent to this. ...
java
{ "resource": "" }
q180301
SimpleTree.clearChildren
test
public void clearChildren() { // Check that their are children to clear. if (children != null) { // Loop over all the children setting their parent to null. for (Tree<E> child : children) { child.setParent(null); } ...
java
{ "resource": "" }
q180302
SequenceIterator.nextInternal
test
private E nextInternal() { // Check if the next soluation has already been cached, because of a call to hasNext. if (nextSolution != null) { return nextSolution; } // Otherwise, generate the next solution, if possible. nextSolution = nextInSequence(); ...
java
{ "resource": "" }
q180303
WAMCompiledClause.addInstructions
test
public void addInstructions(Functor body, SizeableList<WAMInstruction> instructions) { int oldLength; if (this.body == null) { oldLength = 0; this.body = new Functor[1]; } else { oldLength = this.body.length; this.body ...
java
{ "resource": "" }
q180304
WAMCompiledClause.addInstructionsAndThisToParent
test
private void addInstructionsAndThisToParent(SizeableList<WAMInstruction> instructions) { if (!addedToParent) { parent.addInstructions(this, instructions); addedToParent = true; } else { parent.addInstructions(instructions); } }
java
{ "resource": "" }
q180305
ButtonPanel.propertyChange
test
public void propertyChange(PropertyChangeEvent event) { /*log.fine("void propertyChange(PropertyChangeEvent): called");*/ // Check that the property change was sent by a WorkPanelState if (event.getSource() instanceof WorkPanelState) { // Get the state String...
java
{ "resource": "" }
q180306
ButtonPanel.registerWorkPanel
test
public void registerWorkPanel(WorkPanel panel) { // Set the work panel to listen for actions generated by the buttons okButton.addActionListener(panel); cancelButton.addActionListener(panel); applyButton.addActionListener(panel); // Register this to listen for changes to the...
java
{ "resource": "" }
q180307
DesktopAppLayout.updatePresentComponentFlags
test
private void updatePresentComponentFlags() { hasConsole = componentMap.containsKey(CONSOLE); hasStatusBar = componentMap.containsKey(STATUS_BAR); hasLeftBar = componentMap.containsKey(LEFT_VERTICAL_BAR); hasLeftPane = componentMap.containsKey(LEFT_PANE); hasRightBar = compone...
java
{ "resource": "" }
q180308
BigDecimalTypeImpl.createInstance
test
public static Type createInstance(String name, int precision, int scale, String min, String max) { synchronized (DECIMAL_TYPES) { // Add the newly created type to the map of all types. BigDecimalTypeImpl newType = new BigDecimalTypeImpl(name, precision, scale, min, max); ...
java
{ "resource": "" }
q180309
FreeNonAnonymousVariablePredicate.evaluate
test
public boolean evaluate(Term term) { if (term.isVar() && (term instanceof Variable)) { Variable var = (Variable) term; return !var.isBound() && !var.isAnonymous(); } return false; }
java
{ "resource": "" }
q180310
WAMOptimizer.optimize
test
private SizeableList<WAMInstruction> optimize(List<WAMInstruction> instructions) { StateMachine optimizeConstants = new OptimizeInstructions(symbolTable, interner); Iterable<WAMInstruction> matcher = new Matcher<WAMInstruction, WAMInstruction>(instructions.iterator(), optimizeConstants);...
java
{ "resource": "" }
q180311
LexicographicalCollectionComparator.compare
test
public int compare(Collection<T> c1, Collection<T> c2) { // Simultaneously iterator over both collections until one runs out. Iterator<T> i1 = c1.iterator(); Iterator<T> i2 = c2.iterator(); while (i1.hasNext() && i2.hasNext()) { T t1 = i1.next(); T t2...
java
{ "resource": "" }
q180312
DataStreamServlet.service
test
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { log.fine("void service(HttpServletRequest, HttpServletResponse): called"); // Read the parameters and attributes from the request String contentType = (String) request.getAttribute("contentTyp...
java
{ "resource": "" }
q180313
PageControlTag.doStartTag
test
public int doStartTag() throws JspException { log.fine("public int doStartTag(): called"); TagUtils tagUtils = TagUtils.getInstance(); // Get a reference to the PagedList. PagedList list = (PagedList) tagUtils.lookup(pageContext, name, property, scope); log.fine("list = " +...
java
{ "resource": "" }
q180314
PageControlTag.renderButton
test
private void renderButton(boolean render, int page, int index, String openDelim, String url, String text, boolean active) throws JspException { log.fine( "private void renderButton(boolean render, int page, int index, String openDelim, String url, String text, boolean active): called"); ...
java
{ "resource": "" }
q180315
AbstractLearningMethod.reset
test
public void reset() { maxSteps = 0; machineToTrain = null; inputExamples = new ArrayList<State>(); inputProperties = new HashSet<String>(); outputProperties = new HashSet<String>(); inputPropertiesSet = false; outputPropertiesSet = false; }
java
{ "resource": "" }
q180316
AbstractLearningMethod.initialize
test
protected void initialize() throws LearningFailureException { // Check that at least one training example has been set. if (inputExamples.isEmpty()) { throw new LearningFailureException("No training examples to learn from.", null); } // Check if an output propert...
java
{ "resource": "" }
q180317
HashArray.get
test
public V get(Object key) { // Get the index from the map Integer index = keyToIndex.get(key); // Check that the key is in the map if (index == null) { return null; } // Get the data from the array return data.get(index.intValue()); }
java
{ "resource": "" }
q180318
HashArray.getIndexOf
test
public int getIndexOf(Object key) { // Get the index from the map Integer index = keyToIndex.get(key); // Check that the key is in the map and return -1 if it is not. if (index == null) { return -1; } return index; }
java
{ "resource": "" }
q180319
HashArray.set
test
public V set(int index, V value) throws IndexOutOfBoundsException { // Check if the index does not already exist if (index >= data.size()) { throw new IndexOutOfBoundsException(); } return data.set(index, value); }
java
{ "resource": "" }
q180320
HashArray.remove
test
public V remove(Object key) { // Check if the key is in the map Integer index = keyToIndex.get(key); if (index == null) { return null; } // Leave the data in the array but remove its key keyToIndex.remove(key); keySet.remove(key); ...
java
{ "resource": "" }
q180321
HashArray.remove
test
public V remove(int index) throws IndexOutOfBoundsException { // Check that the index is not too large if (index >= data.size()) { throw new IndexOutOfBoundsException(); } // Get the key for the index by scanning through the key to index mapping for (K ne...
java
{ "resource": "" }
q180322
PropertyIntrospectorBase.hasProperty
test
public boolean hasProperty(String property) { // Check if a getter method exists for the property. Method getterMethod = getters.get(property); return getterMethod != null; }
java
{ "resource": "" }
q180323
PropertyIntrospectorBase.setProperty
test
protected void setProperty(Object callee, String property, Object value) { // Initialize this meta bean if it has not already been initialized. if (!initialized) { initialize(callee); } // Check that at least one setter method exists for the property. Met...
java
{ "resource": "" }
q180324
PropertyIntrospectorBase.getProperty
test
protected Object getProperty(Object callee, String property) { // Initialize this meta bean if it has not already been initialized. if (!initialized) { initialize(callee); } // Check if a getter method exists for the property being fetched. Method getterM...
java
{ "resource": "" }
q180325
PropertyIntrospectorBase.isAssignableFromPrimitive
test
private boolean isAssignableFromPrimitive(Class wrapperType, Class primitiveType) { boolean result = false; if (primitiveType.equals(boolean.class) && wrapperType.equals(Boolean.class)) { result = true; } else if (primitiveType.equals(byte.class) && wrapperType.e...
java
{ "resource": "" }
q180326
PropertyIntrospectorBase.initialize
test
private void initialize(Object callee) { // This is used to build up all the setter methods in. Map<String, List<Method>> settersTemp = new HashMap<String, List<Method>>(); // Get all the property getters and setters on this class. Method[] methods = callee.getClass().getMethods(); ...
java
{ "resource": "" }
q180327
Decision.decide
test
public DecisionTree decide(State state) { // Extract the value of the property being decided from state to be classified. OrdinalAttribute attributeValue = (OrdinalAttribute) state.getProperty(propertyName); // Extract the child decision tree that matches the property value, using the attri...
java
{ "resource": "" }
q180328
Decision.initializeLookups
test
public void initializeLookups(DecisionTree thisNode) { // Scan over all the decision trees children at this point inserting them into the lookup table depending // on the ordinal of the attribute value that matches them. for (Iterator<Tree<DecisionTreeElement>> i = thisNode.getChildIterator(...
java
{ "resource": "" }
q180329
PrologUnifier.unify
test
public List<Variable> unify(Term query, Term statement) { /*log.fine("unify(Term left = " + query + ", Term right = " + statement + "): called");*/ // Find all free variables in the query. Set<Variable> freeVars = TermUtils.findFreeNonAnonymousVariables(query); // Build up all the ...
java
{ "resource": "" }
q180330
PrologUnifier.unifyInternal
test
public boolean unifyInternal(Term left, Term right, List<Variable> leftTrail, List<Variable> rightTrail) { /*log.fine("public boolean unifyInternal(Term left = " + left + ", Term right = " + right + ", List<Variable> trail = " + leftTrail + "): called");*/ if (left == right) { ...
java
{ "resource": "" }
q180331
PrologUnifier.unifyVar
test
protected boolean unifyVar(Variable leftVar, Term rightTerm, List<Variable> leftTrail, List<Variable> rightTrail) { /*log.fine("protected boolean unifyVar(Variable var = " + leftVar + ", Term term = " + rightTerm + ", List<Variable> trail = " + leftTrail + "): called");*/ // Check if th...
java
{ "resource": "" }
q180332
InstructionCompiler.compileQuery
test
private void compileQuery(Clause clause) throws SourceCodeException { // Used to build up the compiled result in. WAMCompiledQuery result; // A mapping from top stack frame slots to interned variable names is built up in this. // This is used to track the stack positions that variab...
java
{ "resource": "" }
q180333
InstructionCompiler.findMaxArgumentsInClause
test
private int findMaxArgumentsInClause(Clause clause) { int result = 0; Functor head = clause.getHead(); if (head != null) { result = head.getArity(); } Functor[] body = clause.getBody(); if (body != null) { for (int i = 0; i ...
java
{ "resource": "" }
q180334
InstructionCompiler.allocatePermanentQueryRegisters
test
private void allocatePermanentQueryRegisters(Term clause, Map<Byte, Integer> varNames) { // Allocate local variable slots for all variables in a query. QueryRegisterAllocatingVisitor allocatingVisitor = new QueryRegisterAllocatingVisitor(symbolTable, varNames, null); PositionalT...
java
{ "resource": "" }
q180335
InstructionCompiler.gatherPositionAndOccurrenceInfo
test
private void gatherPositionAndOccurrenceInfo(Term clause) { PositionalTermTraverser positionalTraverser = new PositionalTermTraverserImpl(); PositionAndOccurrenceVisitor positionAndOccurrenceVisitor = new PositionAndOccurrenceVisitor(interner, symbolTable, positionalTraverser); p...
java
{ "resource": "" }
q180336
InstructionCompiler.displayCompiledPredicate
test
private void displayCompiledPredicate(Term predicate) { // Pretty print the clause. StringBuffer result = new StringBuffer(); PositionalTermVisitor displayVisitor = new WAMCompiledPredicatePrintingVisitor(interner, symbolTable, result); TermWalkers.positionalWalker(disp...
java
{ "resource": "" }
q180337
InstructionCompiler.displayCompiledQuery
test
private void displayCompiledQuery(Term query) { // Pretty print the clause. StringBuffer result = new StringBuffer(); PositionalTermVisitor displayVisitor = new WAMCompiledQueryPrintingVisitor(interner, symbolTable, result); TermWalkers.positionalWalker(displayVisitor)....
java
{ "resource": "" }
q180338
ByteBufferUtils.putPaddedInt32AsString
test
public static ByteBuffer putPaddedInt32AsString(ByteBuffer buffer, int value, int length) { // Ensure there is sufficient space in the buffer to hold the result. int charsRequired = BitHackUtils.getCharacterCountInt32(value); length = (charsRequired < length) ? length : charsRequired; ...
java
{ "resource": "" }
q180339
ByteBufferUtils.asString
test
public static String asString(ByteBuffer buffer, int length) { char[] chars = new char[length]; for (int i = 0; i < length; i++) { chars[i] = (char) buffer.get(i); } return String.valueOf(chars); }
java
{ "resource": "" }
q180340
EnumeratedStringAttribute.getStringValue
test
public String getStringValue() { // Check if the attribute class has been finalized yet. if (attributeClass.finalized) { // Fetch the string value from the attribute class. return attributeClass.lookupValue[value].label; } else { re...
java
{ "resource": "" }
q180341
EnumeratedStringAttribute.setStringValue
test
public void setStringValue(String value) throws IllegalArgumentException { Byte b = attributeClass.lookupByte.get(value); // Check if the value is not already a memeber of the attribute class. if (b == null) { // Check if the attribute class has been finalized yet. ...
java
{ "resource": "" }
q180342
LojixTermReader.read
test
private void read(Term term) { if (term.isNumber()) { NumericType numericType = (NumericType) term; if (numericType.isInteger()) { IntLiteral jplInteger = (IntLiteral) term; getContentHandler().startIntegerTerm(jplInteger.longValue...
java
{ "resource": "" }
q180343
ReflectionUtils.classExistsAndIsLoadable
test
public static boolean classExistsAndIsLoadable(String className) { try { Class.forName(className); return true; } catch (ClassNotFoundException e) { // Exception noted and ignored. e = null; return false; }...
java
{ "resource": "" }
q180344
ReflectionUtils.isSubTypeOf
test
public static boolean isSubTypeOf(Class parent, String className) { try { Class cls = Class.forName(className); return parent.isAssignableFrom(cls); } catch (ClassNotFoundException e) { // Exception noted and ignored. e = null;...
java
{ "resource": "" }
q180345
ReflectionUtils.isSubTypeOf
test
public static boolean isSubTypeOf(String parent, String child) { try { return isSubTypeOf(Class.forName(parent), Class.forName(child)); } catch (ClassNotFoundException e) { // Exception noted so can be ignored. e = null; return...
java
{ "resource": "" }
q180346
ReflectionUtils.isSubTypeOf
test
public static boolean isSubTypeOf(Class parentClass, Class childClass) { try { // Check that the child class can be cast as a sub-type of the parent. childClass.asSubclass(parentClass); return true; } catch (ClassCastException e) { ...
java
{ "resource": "" }
q180347
ReflectionUtils.forName
test
public static Class<?> forName(String className) { try { return Class.forName(className); } catch (ClassNotFoundException e) { throw new ReflectionUtilsException("ClassNotFoundException whilst finding class: " + className + ".", e); } }
java
{ "resource": "" }
q180348
ReflectionUtils.newInstance
test
public static <T> T newInstance(Class<T> cls) { try { return cls.newInstance(); } catch (InstantiationException e) { throw new ReflectionUtilsException("InstantiationException whilst instantiating class.", e); } catch (IllegalAccessExce...
java
{ "resource": "" }
q180349
ReflectionUtils.newInstance
test
public static <T> T newInstance(Constructor<T> constructor, Object[] args) { try { return constructor.newInstance(args); } catch (InstantiationException e) { throw new IllegalStateException(e); } catch (IllegalAccessException e) ...
java
{ "resource": "" }
q180350
ReflectionUtils.callMethodOverridingIllegalAccess
test
public static Object callMethodOverridingIllegalAccess(Object o, String method, Object[] params, Class[] paramClasses) { // Get the objects class. Class cls = o.getClass(); // Get the classes of the parameters. /*Class[] paramClasses = new Class[params.length]; for ...
java
{ "resource": "" }
q180351
ReflectionUtils.callMethod
test
public static Object callMethod(Object o, String method, Object[] params) { // Get the objects class. Class cls = o.getClass(); // Get the classes of the parameters. Class[] paramClasses = new Class[params.length]; for (int i = 0; i < params.length; i++) { ...
java
{ "resource": "" }
q180352
ReflectionUtils.callStaticMethod
test
public static Object callStaticMethod(Method method, Object[] params) { try { return method.invoke(null, params); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } catch (InvocationTargetException e) { ...
java
{ "resource": "" }
q180353
ReflectionUtils.getConstructor
test
public static <T> Constructor<T> getConstructor(Class<T> cls, Class[] args) { try { return cls.getConstructor(args); } catch (NoSuchMethodException e) { throw new IllegalStateException(e); } }
java
{ "resource": "" }
q180354
ReflectionUtils.findMatchingSetters
test
public static Set<Class> findMatchingSetters(Class obClass, String propertyName) { /*log.fine("private Set<Class> findMatchingSetters(Object ob, String propertyName): called");*/ Set<Class> types = new HashSet<Class>(); // Convert the first letter of the property name to upper case to match...
java
{ "resource": "" }
q180355
Queues.getTransactionalQueue
test
public static <E> Queue<E> getTransactionalQueue(java.util.Queue<E> queue) { return new WrapperQueue<E>(queue, new LinkedList<E>(), true, false, false); }
java
{ "resource": "" }
q180356
Queues.getTransactionalReQueue
test
public static <E> Queue<E> getTransactionalReQueue(java.util.Queue<E> queue, Collection<E> requeue) { return new WrapperQueue<E>(queue, requeue, true, false, false); }
java
{ "resource": "" }
q180357
TypeHelper.getTypeFromObject
test
public static Type getTypeFromObject(Object o) { // Check if the object is null, in which case its type cannot be derived. if (o == null) { return new UnknownType(); } // Check if the object is an attribute a and get its type that way if possible. if (o i...
java
{ "resource": "" }
q180358
BaseQueueSearch.reset
test
public void reset() { // Clear out the start states. startStates.clear(); enqueuedOnce = false; // Reset the queue to a fresh empty queue. queue = createQueue(); // Clear the goal predicate. goalPredicate = null; // Reset the maximum steps limit ...
java
{ "resource": "" }
q180359
BaseQueueSearch.search
test
public T search() throws SearchNotExhaustiveException { SearchNode<O, T> path = findGoalPath(); if (path != null) { return path.getState(); } else { return null; } }
java
{ "resource": "" }
q180360
IntRangeType.createInstance
test
public static Type createInstance(String name, int min, int 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 (INT_RANGE_TYPES) { ...
java
{ "resource": "" }
q180361
SchemaDefinitionImpl.addSupportedTZ
test
public void addSupportedTZ(String tzName) { if (!StringUtils.isBlank(tzName) && !tzNamesAliases.containsKey(tzName.trim())) { tzNamesAliases.put(tzName.trim(), tzName.trim()); if (LOG.isInfoEnabled()) { LOG.info("Endpoint " + this.getEndPointName() + " - add support of TZ...
java
{ "resource": "" }
q180362
SchemaDefinitionImpl.addTZAlternateDimension
test
public void addTZAlternateDimension(String orignalDimensionName, DimensionTable alternateDimension, String tzName) { addSupportedTZ(tzName); if (tzNamesAliases.containsValue(tzName)) { sqlTables.put(alternateDimension.getTableName(), alternateDimension); alternateDimensions.put(P...
java
{ "resource": "" }
q180363
SchemaDefinitionImpl.addDimension
test
public void addDimension(DimensionTable table, boolean mandatory) { sqlTables.put(table.getTableName(), table); dimensions.put(table.getDimensionName().toUpperCase(), table); if (mandatory) { mandatoryDimensionNames.add(table.getDimensionName().toUpperCase(Locale.ENGLISH)); }...
java
{ "resource": "" }
q180364
TermUtils.findFreeVariables
test
public static Set<Variable> findFreeVariables(Term query) { QueueBasedSearchMethod<Term, Term> freeVarSearch = new DepthFirstSearch<Term, Term>(); freeVarSearch.reset(); freeVarSearch.addStartState(query); freeVarSearch.setGoalPredicate(new FreeVariablePredicate()); return (...
java
{ "resource": "" }
q180365
TermUtils.findFreeNonAnonymousVariables
test
public static Set<Variable> findFreeNonAnonymousVariables(Term query) { QueueBasedSearchMethod<Term, Term> freeVarSearch = new DepthFirstSearch<Term, Term>(); freeVarSearch.reset(); freeVarSearch.addStartState(query); freeVarSearch.setGoalPredicate(new FreeNonAnonymousVariablePredica...
java
{ "resource": "" }
q180366
GreedyComparator.compare
test
public int compare(SearchNode object1, SearchNode object2) { float h1 = ((HeuristicSearchNode) object1).getH(); float h2 = ((HeuristicSearchNode) object2).getH(); return (h1 > h2) ? 1 : ((h1 < h2) ? -1 : 0); }
java
{ "resource": "" }
q180367
FileUtils.writeObjectToFile
test
public static void writeObjectToFile(String outputFileName, Object toWrite, boolean append) { // Open the output file. Writer resultWriter; try { resultWriter = new FileWriter(outputFileName, append); } catch (IOException e) { throw ne...
java
{ "resource": "" }
q180368
FileUtils.readStreamAsString
test
private static String readStreamAsString(BufferedInputStream is) { try { byte[] data = new byte[4096]; StringBuffer inBuffer = new StringBuffer(); int read; while ((read = is.read(data)) != -1) { String s = new String(dat...
java
{ "resource": "" }
q180369
BaseHeuristicSearch.createSearchNode
test
public SearchNode<O, T> createSearchNode(T state) { return new HeuristicSearchNode<O, T>(state, heuristic); }
java
{ "resource": "" }
q180370
TraceIndenter.generateTraceIndent
test
public String generateTraceIndent(int delta) { if (!useIndent) { return ""; } else { if (delta >= 1) { indentStack.push(delta); } else if (delta < 0) { indentStack.pop(); ...
java
{ "resource": "" }
q180371
DefaultBuiltIn.allocateArgumentRegisters
test
protected void allocateArgumentRegisters(Functor expression) { // Assign argument registers to functors appearing directly in the argument of the outermost functor. // Variables are never assigned directly to argument registers. int reg = 0; for (; reg < expression.getArity(); reg++...
java
{ "resource": "" }
q180372
DefaultBuiltIn.isLastBodyTermInArgPositionOnly
test
private boolean isLastBodyTermInArgPositionOnly(Term var, Functor body) { return body == symbolTable.get(var.getSymbolKey(), SymbolTableKeys.SYMKEY_VAR_LAST_ARG_FUNCTOR); }
java
{ "resource": "" }
q180373
ProtoDTLearningMethod.getMajorityClassification
test
private OrdinalAttribute getMajorityClassification(String property, Iterable<State> examples) throws LearningFailureException { /*log.fine("private OrdinalAttribute getMajorityClassification(String property, Collection<State> examples): called");*/ /*log.fine("property = " + property);*/ ...
java
{ "resource": "" }
q180374
ProtoDTLearningMethod.allHaveSameClassification
test
private boolean allHaveSameClassification(String property, Iterable<State> examples) { // Used to hold the value of the first attribute seen. OrdinalAttribute firstAttribute = null; // Flag used to indicate that the test passed successfully. boolean success = true; // Loop ...
java
{ "resource": "" }
q180375
ProtoDTLearningMethod.chooseBestPropertyToDecideOn
test
private String chooseBestPropertyToDecideOn(String outputProperty, Iterable<State> examples, Iterable<String> inputProperties) { /*log.fine("private String chooseBestPropertyToDecideOn(String outputProperty, Collection<State> examples, " + "Collection<String> inputProperties): called");*/ ...
java
{ "resource": "" }
q180376
TermBuilder.functor
test
public Functor functor(String name, Term... args) { int internedName = interner.internFunctorName(name, args.length); return new Functor(internedName, args); }
java
{ "resource": "" }
q180377
TermBuilder.var
test
public Variable var(String name) { boolean isAnonymous = name.startsWith("_"); int internedName = interner.internVariableName(name); return new Variable(internedName, null, isAnonymous); }
java
{ "resource": "" }
q180378
RedirectAction.executeWithErrorHandling
test
public ActionForward executeWithErrorHandling(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, ActionErrors errors) { log.fine("public ActionForward performWithErrorHandling(ActionMapping mapping, ActionForm form," + "HttpServletRequest re...
java
{ "resource": "" }
q180379
PagedList.get
test
public List<E> get(int index) { /*log.fine("public List<E> get(int index): called");*/ // Check that the index is not to large. int originalSize = original.size(); int size = (originalSize / pageSize) + (((originalSize % pageSize) == 0) ? 0 : 1); /*log.fine("originalSize = ...
java
{ "resource": "" }
q180380
Surface.setTexture
test
public void setTexture(Paint obj) { if (obj instanceof GradientPaint) { texture = new GradientPaint(0, 0, Color.white, getSize().width * 2, 0, Color.green); } else { texture = obj; } }
java
{ "resource": "" }
q180381
Surface.paintImmediately
test
public void paintImmediately(int x, int y, int w, int h) { RepaintManager repaintManager = null; boolean save = true; if (!isDoubleBuffered()) { repaintManager = RepaintManager.currentManager(this); save = repaintManager.isDoubleBufferingEnabled(); ...
java
{ "resource": "" }
q180382
Surface.createBufferedImage
test
protected BufferedImage createBufferedImage(int w, int h, int imgType) { BufferedImage bi = null; if (imgType == 0) { bi = (BufferedImage) createImage(w, h); } else if ((imgType > 0) && (imgType < 14)) { bi = new BufferedImage(w, h, imgType); ...
java
{ "resource": "" }
q180383
Surface.createGraphics2D
test
protected Graphics2D createGraphics2D(int width, int height, BufferedImage bi, Graphics g) { Graphics2D g2 = null; // Check if the buffered image is null if (bi != null) { // Create Graphics2D context for the buffered image g2 = bi.createGraphics(); }...
java
{ "resource": "" }
q180384
Surface.createBinaryImage
test
private BufferedImage createBinaryImage(int w, int h, int pixelBits) { int bytesPerRow = w * pixelBits / 8; if ((w * pixelBits % 8) != 0) { bytesPerRow++; } byte[] imageData = new byte[h * bytesPerRow]; IndexColorModel cm = null; switch (pixelBi...
java
{ "resource": "" }
q180385
Surface.createSGISurface
test
private BufferedImage createSGISurface(int w, int h, int pixelBits) { int rMask32 = 0xFF000000; int rMask16 = 0xF800; int gMask32 = 0x00FF0000; int gMask16 = 0x07C0; int bMask32 = 0x0000FF00; int bMask16 = 0x003E; DirectColorModel dcm = null; DataBuffe...
java
{ "resource": "" }
q180386
PostFixSearch.setQueueSearchAlgorithm
test
protected void setQueueSearchAlgorithm(QueueSearchAlgorithm<O, T> algorithm) { algorithm.setPeekAtHead(true); algorithm.setReverseEnqueueOrder(true); super.setQueueSearchAlgorithm(algorithm); }
java
{ "resource": "" }
q180387
IterativeBoundAlgorithm.search
test
public SearchNode search(QueueSearchState<O, T> initSearch, Collection<T> startStates, int maxSteps, int searchSteps) throws SearchNotExhaustiveException { // Iteratively increase the bound until a search succeeds. for (float bound = startBound;;) { // Set up the maximum ...
java
{ "resource": "" }
q180388
MaxStepsAlgorithm.search
test
public SearchNode search(QueueSearchState<O, T> initSearch, Collection<T> startStates, int maxSteps, int searchSteps) throws SearchNotExhaustiveException { // Initialize the queue with the start states set up in search nodes if this has not already been done. // This will only be done on the...
java
{ "resource": "" }
q180389
PrologParser.main
test
public static void main(String[] args) { try { SimpleCharStream inputStream = new SimpleCharStream(System.in, null, 1, 1); PrologParserTokenManager tokenManager = new PrologParserTokenManager(inputStream); Source<Token> tokenSource = new TokenSource(tokenManager);...
java
{ "resource": "" }
q180390
PrologParser.clause
test
public Clause clause() throws SourceCodeException { // Each new sentence provides a new scope in which to make variables unique. variableContext.clear(); Term term = term(); Clause clause = TermUtils.convertToClause(term, interner); if (clause == null) { ...
java
{ "resource": "" }
q180391
PrologParser.terms
test
public List<Term> terms(List<Term> terms) throws SourceCodeException { Term term; Token nextToken = tokenSource.peek(); switch (nextToken.kind) { case FUNCTOR: term = functor(); break; case LSQPAREN: term = listFunctor(); ...
java
{ "resource": "" }
q180392
PrologParser.functor
test
public Term functor() throws SourceCodeException { Token name = consumeToken(FUNCTOR); Term[] args = arglist(); consumeToken(RPAREN); int nameId = interner.internFunctorName((args == null) ? name.image : name.image.substring(0, name.image.length() - 1), (...
java
{ "resource": "" }
q180393
PrologParser.listFunctor
test
public Term listFunctor() throws SourceCodeException { // Get the interned names of the nil and cons functors. int nilId = interner.internFunctorName("nil", 0); int consId = interner.internFunctorName("cons", 2); // A list always starts with a '['. Token leftDelim = consumeT...
java
{ "resource": "" }
q180394
PrologParser.arglist
test
public Term[] arglist() throws SourceCodeException { Term term = term(); List<Term> result = TermUtils.flattenTerm(term, Term.class, ",", interner); return result.toArray(new Term[result.size()]); }
java
{ "resource": "" }
q180395
PrologParser.variable
test
public Term variable() throws SourceCodeException { Token name = consumeToken(VAR); // Intern the variables name. int nameId = interner.internVariableName(name.image); // Check if the variable already exists in this scope, or create a new one if it does not. // If the varia...
java
{ "resource": "" }
q180396
PrologParser.intLiteral
test
public Term intLiteral() throws SourceCodeException { Token valToken = consumeToken(INTEGER_LITERAL); NumericType result = new IntLiteral(Integer.parseInt(valToken.image)); // Set the position that the literal was parsed from. SourceCodePosition position = new SourceCod...
java
{ "resource": "" }
q180397
PrologParser.doubleLiteral
test
public Term doubleLiteral() throws SourceCodeException { Token valToken = consumeToken(FLOATING_POINT_LITERAL); NumericType result = new DoubleLiteral(Double.parseDouble(valToken.image)); // Set the position that the literal was parsed from. SourceCodePosition position = ...
java
{ "resource": "" }
q180398
PrologParser.stringLiteral
test
public Term stringLiteral() throws SourceCodeException { Token valToken = consumeToken(STRING_LITERAL); String valWithQuotes = valToken.image; StringLiteral result = new StringLiteral(valWithQuotes.substring(1, valWithQuotes.length() - 1)); // Set the position that the literal was...
java
{ "resource": "" }
q180399
PrologParser.peekAndConsumeDirective
test
public Directive peekAndConsumeDirective() throws SourceCodeException { if (peekAndConsumeTrace()) { return Directive.Trace; } if (peekAndConsumeInfo()) { return Directive.Info; } if (peekAndConsumeUser()) { return...
java
{ "resource": "" }