_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q179500
PublicId.stringReplace
test
private static String stringReplace(String str, String oldStr, String newStr) { String result = ""; int pos = str.indexOf(oldStr); // System.out.println(str + ": " + oldStr + " => " + newStr); while (pos >= 0) { // System.out.println(str + " (" + pos + ")"); re...
java
{ "resource": "" }
q179501
StopWatch.start
test
public void start(final boolean reset) { if (!running) { if (reset) reset(); start = System.currentTimeMillis(); running = true; } }
java
{ "resource": "" }
q179502
StopWatch.stop
test
public long stop() { long lap = 0; if (running) { count++; stop = System.currentTimeMillis(); lap = stop - start; total += lap; running = false; } return lap; }
java
{ "resource": "" }
q179503
StopWatch.makeSynchronized
test
public static StopWatch makeSynchronized(final StopWatch watch) { return new Wrapper(watch) { /** The serialVersionUID */ private static final long serialVersionUID = -6284244000894114817L; public synchronized void start(final boolean reset) { this.watch.st...
java
{ "resource": "" }
q179504
HashCode.compareTo
test
public int compareTo(final Object obj) throws ClassCastException { HashCode hashCode = (HashCode)obj; return compareTo(hashCode.value); }
java
{ "resource": "" }
q179505
HashCode.generate
test
public static int generate(final byte[] bytes) { int hashcode = 0; for (int i=0; i<bytes.length; i++) { hashcode <<= 1; hashcode ^= bytes[i]; } return hashcode; }
java
{ "resource": "" }
q179506
HashCode.generate
test
public static int generate(final Object array[], final boolean deep) { int hashcode = 0; for (int i=0; i<array.length; i++) { if (deep && (array[i] instanceof Object[])) { hashcode ^= generate((Object[])array[i], true); } else { hashcode ^= array[i].hashCo...
java
{ "resource": "" }
q179507
LRUCachePolicy.create
test
public void create() { m_map = createMap(); m_list = createList(); m_list.m_maxCapacity = m_maxCapacity; m_list.m_minCapacity = m_minCapacity; m_list.m_capacity = m_maxCapacity; }
java
{ "resource": "" }
q179508
FieldBoundPropertyListener.setFieldValue
test
protected void setFieldValue(String value) { try { // filter property value value = filterValue(value); // coerce value to field type Class<?> type = fieldInstance.getField().getType(); PropertyEditor editor = PropertyEditors.findEditor(type); editor.setAsTex...
java
{ "resource": "" }
q179509
TextCatalogReader.nextToken
test
protected String nextToken() throws IOException { String token = ""; int ch, nextch; if (!tokenStack.empty()) { return (String) tokenStack.pop(); } // Skip over leading whitespace and comments while (true) { // skip leading whitespace ch = catfile.read(); while (ch <= '...
java
{ "resource": "" }
q179510
DateEditor.initialize
test
public static void initialize() { PrivilegedAction action = new PrivilegedAction() { public Object run() { String defaultFormat = System.getProperty("org.jboss.util.propertyeditor.DateEditor.format", "MMM d, yyyy"); String defaultLocale = System.getProperty("org....
java
{ "resource": "" }
q179511
Graph.addVertex
test
public boolean addVertex(Vertex<T> v) { if( verticies.containsValue(v) == false ) { verticies.put(v.getName(), v); return true; } return false; }
java
{ "resource": "" }
q179512
Graph.setRootVertex
test
public void setRootVertex(Vertex<T> root) { this.rootVertex = root; if( verticies.containsValue(root) == false ) addVertex(root); }
java
{ "resource": "" }
q179513
Graph.removeVertex
test
public boolean removeVertex(Vertex<T> v) { if (!verticies.containsValue(v)) return false; verticies.remove(v.getName()); if( v == rootVertex ) rootVertex = null; // Remove the edges associated with v for(int n = 0; n < v.getOutgoingEdgeCount(); n ++) { ...
java
{ "resource": "" }
q179514
Graph.depthFirstSearch
test
public void depthFirstSearch(Vertex<T> v, final Visitor<T> visitor) { VisitorEX<T, RuntimeException> wrapper = new VisitorEX<T, RuntimeException>() { public void visit(Graph<T> g, Vertex<T> v) throws RuntimeException { if (visitor != null) visitor.visit(g, v);...
java
{ "resource": "" }
q179515
Graph.dfsSpanningTree
test
public void dfsSpanningTree(Vertex<T> v, DFSVisitor<T> visitor) { v.visit(); if( visitor != null ) visitor.visit(this, v); for (int i = 0; i < v.getOutgoingEdgeCount(); i++) { Edge<T> e = v.getOutgoingEdge(i); if (!e.getTo().visited()) { if( vi...
java
{ "resource": "" }
q179516
Graph.findVertexByData
test
public Vertex<T> findVertexByData(T data, Comparator<T> compare) { Vertex<T> match = null; for(Vertex<T> v : verticies.values()) { if( compare.compare(data, v.getData()) == 0 ) { match = v; break; } } return match; }
java
{ "resource": "" }
q179517
Graph.findCycles
test
public Edge<T>[] findCycles() { ArrayList<Edge<T>> cycleEdges = new ArrayList<Edge<T>>(); // Mark all verticies as white for(int n = 0; n < verticies.size(); n ++) { Vertex<T> v = getVertex(n); v.setMarkState(VISIT_COLOR_WHITE); } for(int n = 0; n < verticies.siz...
java
{ "resource": "" }
q179518
DOMWriter.normalize
test
public static String normalize(String s, boolean canonical) { StringBuffer str = new StringBuffer(); int len = (s != null) ? s.length() : 0; for (int i = 0; i < len; i++) { char ch = s.charAt(i); switch (ch) { case '<': { str....
java
{ "resource": "" }
q179519
DOMUtils.parse
test
public static Element parse(String xmlString) throws IOException { try { return parse(new ByteArrayInputStream(xmlString.getBytes("UTF-8"))); } catch (IOException e) { log.error("Cannot parse: " + xmlString); throw e; } }
java
{ "resource": "" }
q179520
DOMUtils.parse
test
public static Element parse(InputStream xmlStream) throws IOException { try { Document doc = getDocumentBuilder().parse(xmlStream); Element root = doc.getDocumentElement(); return root; } catch (SAXException e) { throw new IOExc...
java
{ "resource": "" }
q179521
DOMUtils.parse
test
public static Element parse(InputSource source) throws IOException { try { Document doc = getDocumentBuilder().parse(source); Element root = doc.getDocumentElement(); return root; } catch (SAXException e) { throw new IOException...
java
{ "resource": "" }
q179522
DOMUtils.createElement
test
public static Element createElement(String localPart) { Document doc = getOwnerDocument(); log.trace("createElement {}" + localPart); return doc.createElement(localPart); }
java
{ "resource": "" }
q179523
DOMUtils.resolveQName
test
public static QName resolveQName(Element el, String qualifiedName) { QName qname; String prefix = ""; String namespaceURI = ""; String localPart = qualifiedName; int colIndex = qualifiedName.indexOf(":"); if (colIndex > 0) { prefix = qualifiedName...
java
{ "resource": "" }
q179524
DOMUtils.copyAttributes
test
public static void copyAttributes(Element destElement, Element srcElement) { NamedNodeMap attribs = srcElement.getAttributes(); for (int i = 0; i < attribs.getLength(); i++) { Attr attr = (Attr)attribs.item(i); String uri = attr.getNamespaceURI(); String q...
java
{ "resource": "" }
q179525
DOMUtils.hasChildElements
test
public static boolean hasChildElements(Node node) { NodeList nlist = node.getChildNodes(); for (int i = 0; i < nlist.getLength(); i++) { Node child = nlist.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) return true; } return fal...
java
{ "resource": "" }
q179526
DOMUtils.getChildElements
test
public static Iterator getChildElements(Node node) { ArrayList list = new ArrayList(); NodeList nlist = node.getChildNodes(); for (int i = 0; i < nlist.getLength(); i++) { Node child = nlist.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) ...
java
{ "resource": "" }
q179527
DOMUtils.getTextContent
test
public static String getTextContent(Node node, boolean replaceProps) { boolean hasTextContent = false; StringBuffer buffer = new StringBuffer(); NodeList nlist = node.getChildNodes(); for (int i = 0; i < nlist.getLength(); i++) { Node child = nlist.item(i); ...
java
{ "resource": "" }
q179528
DOMUtils.getChildElements
test
public static Iterator getChildElements(Node node, String nodeName) { return getChildElementsIntern(node, new QName(nodeName)); }
java
{ "resource": "" }
q179529
DOMUtils.getParentElement
test
public static Element getParentElement(Node node) { Node parent = node.getParentNode(); return (parent instanceof Element ? (Element)parent : null); }
java
{ "resource": "" }
q179530
DeadlockDetector.addWaiting
test
public void addWaiting(Object holder, Resource resource) { synchronized (waiting) { waiting.put(holder, resource); } }
java
{ "resource": "" }
q179531
DOMCatalogReader.readCatalog
test
public void readCatalog(Catalog catalog, InputStream is) throws IOException, CatalogException { DocumentBuilderFactory factory = null; DocumentBuilder builder = null; factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(false); factory.setValidating(false); try { ...
java
{ "resource": "" }
q179532
DOMCatalogReader.readCatalog
test
public void readCatalog(Catalog catalog, String fileUrl) throws MalformedURLException, IOException, CatalogException { URL url = new URL(fileUrl); URLConnection urlCon = url.openConnection(); readCatalog(catalog, urlCon.getInputStream()); }
java
{ "resource": "" }
q179533
VMID.getHostAddress
test
private static byte[] getHostAddress() { return (byte[]) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { return InetAddress.getLocalHost().getAddress(); } catch (Exception e) { return UN...
java
{ "resource": "" }
q179534
CatalogLocation.resolveEntity
test
public InputSource resolveEntity(String publicId, String systemId) throws MalformedURLException, IOException { String resolvedURI = catologResolver.resolveSystem(systemId); if (resolvedURI == null) { resolvedURI = catologResolver.resolvePublic(publicId, systemId); } if (resol...
java
{ "resource": "" }
q179535
SystemPropertyClassValue.setSystemPropertyClassValue
test
public static Throwable setSystemPropertyClassValue(String property, String className) { // Validation if (property == null || property.trim().length() == 0) throw new IllegalArgumentException("Null or empty property"); if (className == null || className.trim().length() == 0) thro...
java
{ "resource": "" }
q179536
Classes.displayClassInfo
test
public static void displayClassInfo(Class clazz, StringBuffer results) { // Print out some codebase info for the clazz ClassLoader cl = clazz.getClassLoader(); results.append("\n"); results.append(clazz.getName()); results.append("("); results.append(Integer.toHexString(clazz.hash...
java
{ "resource": "" }
q179537
Classes.describe
test
public static void describe(StringBuffer buffer, Class clazz) { if (clazz == null) buffer.append("**null**"); else { buffer.append("{class=").append(clazz.getName()); Class[] intfs = clazz.getInterfaces(); if (intfs.length > 0) { buffer.appen...
java
{ "resource": "" }
q179538
Classes.stripPackageName
test
public static String stripPackageName(final String classname) { int idx = classname.lastIndexOf(PACKAGE_SEPARATOR); if (idx != -1) return classname.substring(idx + 1, classname.length()); return classname; }
java
{ "resource": "" }
q179539
Classes.getPackageName
test
public static String getPackageName(final String classname) { if (classname.length() == 0) throw new EmptyStringException(); int index = classname.lastIndexOf(PACKAGE_SEPARATOR); if (index != -1) return classname.substring(0, index); return ""; }
java
{ "resource": "" }
q179540
Classes.forceLoad
test
public static void forceLoad(final Class type) { if (type == null) throw new NullArgumentException("type"); // don't attempt to force primitives to load if (type.isPrimitive()) return; // don't attempt to force java.* classes to load String packageName = Classes.getPackageNam...
java
{ "resource": "" }
q179541
Classes.getPrimitiveWrapper
test
public static Class getPrimitiveWrapper(final Class type) { if (!type.isPrimitive()) { throw new IllegalArgumentException("type is not a primitive class"); } for (int i = 0; i < PRIMITIVE_WRAPPER_MAP.length; i += 2) { if (type.equals(PRIMITIVE_WRAPPER_MAP[i])) ...
java
{ "resource": "" }
q179542
Classes.getAllInterfaces
test
public static void getAllInterfaces(List allIfaces, Class c) { while (c != null) { Class[] ifaces = c.getInterfaces(); for (int n = 0; n < ifaces.length; n ++) { allIfaces.add(ifaces[n]); } c = c.getSuperclass(); } }
java
{ "resource": "" }
q179543
Classes.getAllUniqueInterfaces
test
public static Class[] getAllUniqueInterfaces(Class c) { Set uniqueIfaces = new HashSet(); while (c != null ) { Class[] ifaces = c.getInterfaces(); for (int n = 0; n < ifaces.length; n ++) { uniqueIfaces.add(ifaces[n]); } c = c.getSuperclass()...
java
{ "resource": "" }
q179544
Classes.isPrimitiveWrapper
test
public static boolean isPrimitiveWrapper(final Class type) { for (int i = 0; i < PRIMITIVE_WRAPPER_MAP.length; i += 2) { if (type.equals(PRIMITIVE_WRAPPER_MAP[i + 1])) { return true; } } return false; }
java
{ "resource": "" }
q179545
Classes.instantiate
test
public static Object instantiate(Class expected, String property, String defaultClassName) { String className = getProperty(property, defaultClassName); Class clazz = null; try { clazz = loadClass(className); } catch (ClassNotFoundException e) { throw new N...
java
{ "resource": "" }
q179546
Classes.getAttributeGetter
test
public final static Method getAttributeGetter(Class cls, String attr) throws NoSuchMethodException { StringBuffer buf = new StringBuffer(attr.length() + 3); buf.append("get"); if(Character.isLowerCase(attr.charAt(0))) { buf.append(Character.toUpperCase(attr.charAt(0))) .a...
java
{ "resource": "" }
q179547
Classes.getAttributeSetter
test
public final static Method getAttributeSetter(Class cls, String attr, Class type) throws NoSuchMethodException { StringBuffer buf = new StringBuffer(attr.length() + 3); buf.append("set"); if(Character.isLowerCase(attr.charAt(0))) { buf.append(Character.toUpperCase(attr.charAt(0))) ...
java
{ "resource": "" }
q179548
Classes.convertToJavaClass
test
private final static Class convertToJavaClass(String name, ClassLoader cl) throws ClassNotFoundException { int arraySize = 0; while (name.endsWith("[]")) { name = name.substring(0, name.length() - 2); arraySize++; } ...
java
{ "resource": "" }
q179549
Classes.getProperty
test
private static String getProperty(final String name, final String defaultValue) { return (String) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return System.getProperty(name, defaultValue); } }); }
java
{ "resource": "" }
q179550
DefaultPropertyReader.getFilenames
test
public static String[] getFilenames(final String propertyName) throws PropertyException { String filenames[]; // check for singleton property first Object filename = PropertyManager.getProperty(propertyName); if (filename != null) { filenames = new String[] { String.valueOf(fi...
java
{ "resource": "" }
q179551
WeakSet.maintain
test
protected final void maintain() { WeakObject weak; while ((weak = (WeakObject)queue.poll()) != null) { set.remove(weak); } }
java
{ "resource": "" }
q179552
WeakSet.iterator
test
public Iterator iterator() { return new Iterator() { /** The set's iterator */ Iterator iter = set.iterator(); /** JBCOMMON-24, handle null values and multiple invocations of hasNext() */ Object UNKNOWN = new Object(); /** The next availab...
java
{ "resource": "" }
q179553
URLListerFactory.createURLLister
test
public URLLister createURLLister(String protocol) throws MalformedURLException { try { String className = (String) classes.get(protocol); if (className == null) { throw new MalformedURLException("No lister class defined for protocol "+protocol); } Class<?> clazz = ...
java
{ "resource": "" }
q179554
PropertyGroup.entrySet
test
@SuppressWarnings("unchecked") public Set entrySet() { final Set superSet = super.entrySet(true); return new java.util.AbstractSet() { private boolean isInGroup(Map.Entry entry) { String key = (String) entry.getKey(); return key.startsWith(basename); ...
java
{ "resource": "" }
q179555
PropertyGroup.addPropertyListener
test
protected void addPropertyListener(final BoundPropertyListener listener) { // get the bound property name String name = makePropertyName(listener.getPropertyName()); // get the bound listener list for the property List list = (List) boundListeners.get(name); // if list is null, then a...
java
{ "resource": "" }
q179556
PropertyGroup.removePropertyListener
test
protected boolean removePropertyListener(final BoundPropertyListener listener) { // get the bound property name String name = makePropertyName(listener.getPropertyName()); // get the bound listener list for the property List list = (List) boundListeners.get(name); boolean removed = fal...
java
{ "resource": "" }
q179557
PropertyEditors.isNull
test
public static final boolean isNull(final String value, final boolean trim, final boolean empty) { // For backwards compatibility if (disableIsNull) return false; // No value? if (value == null) return true; // Trim the text when requested String trimmed = trim ? ...
java
{ "resource": "" }
q179558
PropertyEditors.findEditor
test
public static PropertyEditor findEditor(final String typeName) throws ClassNotFoundException { // see if it is a primitive type first Class<?> type = Classes.getPrimitiveTypeForName(typeName); if (type == null) { // nope try look up ClassLoader loader = Thread.currentT...
java
{ "resource": "" }
q179559
PropertyEditors.registerEditor
test
public static void registerEditor(final String typeName, final String editorTypeName) throws ClassNotFoundException { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class<?> type = loader.loadClass(typeName); Class<?> editorType = loa...
java
{ "resource": "" }
q179560
PropertyEditors.convertValue
test
public static Object convertValue(String text, String typeName) throws ClassNotFoundException, IntrospectionException { // see if it is a primitive type first Class<?> typeClass = Classes.getPrimitiveTypeForName(typeName); if (typeClass == null) { ClassLoader loader = Thread...
java
{ "resource": "" }
q179561
ContextClassLoader.getContextClassLoader
test
public ClassLoader getContextClassLoader(final Thread thread) { return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return thread.getContextClassLoader(); } }); }
java
{ "resource": "" }
q179562
ApplicationDeadlockException.isADE
test
public static ApplicationDeadlockException isADE(Throwable t) { while (t!=null) { if (t instanceof ApplicationDeadlockException) { return (ApplicationDeadlockException)t; } else { t = t.getCause(); } } return null; ...
java
{ "resource": "" }
q179563
TimeoutFactory.schedule
test
public Timeout schedule(long time, TimeoutTarget target) { if (cancelled.get()) throw new IllegalStateException("TimeoutFactory has been cancelled"); if (time < 0) throw new IllegalArgumentException("Negative time"); if (target == null) throw new IllegalArgumentExce...
java
{ "resource": "" }
q179564
TimeoutFactory.doWork
test
private void doWork() { while (cancelled.get() == false) { TimeoutExt work = queue.take(); // Do work, if any if (work != null) { // Wrap the TimeoutExt with a runnable that invokes the target callback TimeoutWorker worker = new TimeoutWorker(wo...
java
{ "resource": "" }
q179565
Util.createSubcontext
test
public static Context createSubcontext(Context ctx, String name) throws NamingException { Name n = ctx.getNameParser("").parse(name); return createSubcontext(ctx, n); }
java
{ "resource": "" }
q179566
Util.lookup
test
public static Object lookup(String name, Class<?> clazz) throws Exception { InitialContext ctx = new InitialContext(); try { return lookup(ctx, name, clazz); } finally { ctx.close(); } }
java
{ "resource": "" }
q179567
Util.checkObject
test
protected static void checkObject(Context context, String name, Object object, Class clazz) throws Exception { Class objectClass = object.getClass(); if (clazz.isAssignableFrom(objectClass) == false) { StringBuffer buffer = new StringBuffer(100); buffer.append("Object at '").appen...
java
{ "resource": "" }
q179568
Util.appendClassInfo
test
protected static void appendClassInfo(StringBuffer buffer, Class clazz) { buffer.append("[class=").append(clazz.getName()); buffer.append(" classloader=").append(clazz.getClassLoader()); buffer.append(" interfaces={"); Class[] interfaces = clazz.getInterfaces(); for (int i=0; i<interfac...
java
{ "resource": "" }
q179569
State.getTransition
test
public Transition getTransition(String name) { Transition t = (Transition) allowedTransitions.get(name); return t; }
java
{ "resource": "" }
q179570
CatalogManager.readProperties
test
private synchronized void readProperties() { try { propertyFileURI = CatalogManager.class.getResource("/"+propertyFile); InputStream in = CatalogManager.class.getResourceAsStream("/"+propertyFile); if (in==null) { if (!ignoreMissingProperties) { System.err.println("Cannot find "+propertyFile)...
java
{ "resource": "" }
q179571
CatalogManager.queryVerbosity
test
private int queryVerbosity () { String verbStr = System.getProperty(pVerbosity); if (verbStr == null) { if (resources==null) readProperties(); if (resources==null) return defaultVerbosity; try { verbStr = resources.getString("verbosity"); } catch (MissingResourceException e) { return ...
java
{ "resource": "" }
q179572
CatalogManager.queryRelativeCatalogs
test
private boolean queryRelativeCatalogs () { if (resources==null) readProperties(); if (resources==null) return defaultRelativeCatalogs; try { String allow = resources.getString("relative-catalogs"); return (allow.equalsIgnoreCase("true") || allow.equalsIgnoreCase("yes") || allow.e...
java
{ "resource": "" }
q179573
CatalogManager.queryCatalogFiles
test
private String queryCatalogFiles () { String catalogList = System.getProperty(pFiles); fromPropertiesFile = false; if (catalogList == null) { if (resources == null) readProperties(); if (resources != null) { try { catalogList = resources.getString("catalogs"); fromPropertiesFile = true; ...
java
{ "resource": "" }
q179574
CatalogManager.getCatalogFiles
test
public Vector getCatalogFiles() { if (catalogFiles == null) { catalogFiles = queryCatalogFiles(); } StringTokenizer files = new StringTokenizer(catalogFiles, ";"); Vector catalogs = new Vector(); while (files.hasMoreTokens()) { String catalogFile = files.nextToken(); URL absURI = ...
java
{ "resource": "" }
q179575
CatalogManager.queryPreferPublic
test
private boolean queryPreferPublic () { String prefer = System.getProperty(pPrefer); if (prefer == null) { if (resources==null) readProperties(); if (resources==null) return defaultPreferPublic; try { prefer = resources.getString("prefer"); } catch (MissingResourceException e) { return...
java
{ "resource": "" }
q179576
CatalogManager.queryUseStaticCatalog
test
private boolean queryUseStaticCatalog () { String staticCatalog = System.getProperty(pStatic); if (useStaticCatalog == null) { if (resources==null) readProperties(); if (resources==null) return defaultUseStaticCatalog; try { staticCatalog = resources.getString("static-catalog"); } catc...
java
{ "resource": "" }
q179577
BootstrapResolver.resolveEntity
test
public InputSource resolveEntity (String publicId, String systemId) { String resolved = null; if (systemId != null && systemMap.containsKey(systemId)) { resolved = (String) systemMap.get(systemId); } else if (publicId != null && publicMap.containsKey(publicId)) { resolved = (String) publicMap.g...
java
{ "resource": "" }
q179578
BootstrapResolver.resolve
test
public Source resolve(String href, String base) throws TransformerException { String uri = href; int hashPos = href.indexOf("#"); if (hashPos >= 0) { uri = href.substring(0, hashPos); } String result = null; if (href != null && uriMap.containsKey(href)) { result = (String) uriM...
java
{ "resource": "" }
q179579
BootstrapResolver.makeAbsolute
test
private String makeAbsolute(String uri) { if (uri == null) { uri = ""; } try { URL url = new URL(uri); return url.toString(); } catch (MalformedURLException mue) { String dir = System.getProperty("user.dir"); String file = ""; if (dir.endsWith("/")) { file = "file:...
java
{ "resource": "" }
q179580
MarshalledValueInputStream.resolveClass
test
protected Class<?> resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { ClassLoader loader = Thread.currentThread().getContextClassLoader(); String className = v.getName(); try { // JDK 6, by default, only supports array types (ex. [[B) using Class...
java
{ "resource": "" }
q179581
MethodBoundPropertyListener.invokeSetter
test
protected void invokeSetter(String value) { try { // coerce value to field type Class<?> type = descriptor.getPropertyType(); PropertyEditor editor = PropertyEditors.findEditor(type); editor.setAsText(value); Object coerced = editor.getValue(); // System.out.p...
java
{ "resource": "" }
q179582
Namespaces.getLocalName
test
public static String getLocalName(Element element) { String name = element.getTagName(); if (name.indexOf(':') > 0) { name = name.substring(name.indexOf(':')+1); } return name; }
java
{ "resource": "" }
q179583
Namespaces.getNamespaceURI
test
public static String getNamespaceURI(Node node, String prefix) { if (node == null || node.getNodeType() != Node.ELEMENT_NODE) { return null; } if (prefix.equals("")) { if (((Element) node).hasAttribute("xmlns")) { return ((Element) node).getAttribute("xmlns"); } } else { String nsattr = "xmln...
java
{ "resource": "" }
q179584
Namespaces.getNamespaceURI
test
public static String getNamespaceURI(Element element) { String prefix = getPrefix(element); return getNamespaceURI(element, prefix); }
java
{ "resource": "" }
q179585
CollectionsUtil.list
test
public static List list(Enumeration e) { ArrayList result = new ArrayList(); while (e.hasMoreElements()) result.add(e.nextElement()); return result; }
java
{ "resource": "" }
q179586
FilePropertyReader.getInputStream
test
protected InputStream getInputStream(String filename) throws IOException { File file = new File(filename); return new FileInputStream(file); }
java
{ "resource": "" }
q179587
FilePropertyReader.loadProperties
test
protected void loadProperties(Properties props, String filename) throws IOException { if (filename == null) throw new NullArgumentException("filename"); if (filename.equals("")) throw new IllegalArgumentException("filename"); InputStream in = new BufferedInputStream(getInpu...
java
{ "resource": "" }
q179588
FilePropertyReader.readProperties
test
public Map readProperties() throws PropertyException, IOException { Properties props = new Properties(); // load each specified property file for (int i=0; i<filenames.length; i++) { loadProperties(props, filenames[i]); } return props; }
java
{ "resource": "" }
q179589
Vertex.addEdge
test
public boolean addEdge(Edge<T> e) { if (e.getFrom() == this) outgoingEdges.add(e); else if (e.getTo() == this) incomingEdges.add(e); else return false; return true; }
java
{ "resource": "" }
q179590
Vertex.addOutgoingEdge
test
public void addOutgoingEdge(Vertex<T> to, int cost) { Edge<T> out = new Edge<T>(this, to, cost); outgoingEdges.add(out); }
java
{ "resource": "" }
q179591
Vertex.addIncomingEdge
test
public void addIncomingEdge(Vertex<T> from, int cost) { Edge<T> out = new Edge<T>(this, from, cost); incomingEdges.add(out); }
java
{ "resource": "" }
q179592
Vertex.hasEdge
test
public boolean hasEdge(Edge<T> e) { if (e.getFrom() == this) return outgoingEdges.contains(e); else if (e.getTo() == this) return incomingEdges.contains(e); else return false; }
java
{ "resource": "" }
q179593
Vertex.remove
test
public boolean remove(Edge<T> e) { if (e.getFrom() == this) outgoingEdges.remove(e); else if (e.getTo() == this) incomingEdges.remove(e); else return false; return true; }
java
{ "resource": "" }
q179594
Vertex.findEdge
test
public Edge<T> findEdge(Vertex<T> dest) { for (Edge<T> e : outgoingEdges) { if (e.getTo() == dest) return e; } return null; }
java
{ "resource": "" }
q179595
Vertex.findEdge
test
public Edge<T> findEdge(Edge<T> e) { if (outgoingEdges.contains(e)) return e; else return null; }
java
{ "resource": "" }
q179596
Vertex.cost
test
public int cost(Vertex<T> dest) { if (dest == this) return 0; Edge<T> e = findEdge(dest); int cost = Integer.MAX_VALUE; if (e != null) cost = e.getCost(); return cost; }
java
{ "resource": "" }
q179597
JarUtils.jar
test
private static void jar(File src, String prefix, JarInfo info) throws IOException { JarOutputStream jout = info.out; if (src.isDirectory()) { // create / init the zip entry prefix = prefix + src.getName() + "/"; ZipEntry entry = new ZipEntry(prefix); ...
java
{ "resource": "" }
q179598
CompoundIterator.hasNext
test
public boolean hasNext() { for (; index < iters.length; index++) { if (iters[index] != null && iters[index].hasNext()) { return true; } } return false; }
java
{ "resource": "" }
q179599
TinyMachine.fireEvent
test
public void fireEvent(Object event) { if (event == null) { throw new IllegalArgumentException("Event must not be null."); } mTaskQueue.offer(Task.obtainTask(Task.CODE_FIRE_EVENT, event, -1)); if (!mQueueProcessed) processTaskQueue(); }
java
{ "resource": "" }