_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q178000
LZMAEncoderNormal.updateOptStateAndReps
test
private void updateOptStateAndReps() { int optPrev = opts[optCur].optPrev; assert optPrev < optCur; if (opts[optCur].prev1IsLiteral) { --optPrev; if (opts[optCur].hasPrev2) { opts[optCur].state.set(opts[opts[optCur].optPrev2].state); if (opts[optCur].backPrev2 < REPS) opts[optCur].state.updateLongRep(); else opts[optCur].state.updateMatch(); } else { opts[optCur].state.set(opts[optPrev].state); } opts[optCur].state.updateLiteral(); } else { opts[optCur].state.set(opts[optPrev].state); } if (optPrev == optCur - 1) { // Must be either a short rep or a literal. assert opts[optCur].backPrev == 0 || opts[optCur].backPrev == -1; if (opts[optCur].backPrev == 0) opts[optCur].state.updateShortRep(); else opts[optCur].state.updateLiteral(); System.arraycopy(opts[optPrev].reps, 0, opts[optCur].reps, 0, REPS); } else { int back; if (opts[optCur].prev1IsLiteral && opts[optCur].hasPrev2) { optPrev = opts[optCur].optPrev2; back = opts[optCur].backPrev2; opts[optCur].state.updateLongRep(); } else { back = opts[optCur].backPrev; if (back < REPS) opts[optCur].state.updateLongRep(); else opts[optCur].state.updateMatch(); } if (back < REPS) { opts[optCur].reps[0] = opts[optPrev].reps[back]; int rep; for (rep = 1; rep <= back; ++rep) opts[optCur].reps[rep] = opts[optPrev].reps[rep - 1]; for (; rep < REPS; ++rep) opts[optCur].reps[rep] = opts[optPrev].reps[rep]; } else { opts[optCur].reps[0] = back - REPS; System.arraycopy(opts[optPrev].reps, 0, opts[optCur].reps, 1, REPS - 1); } } }
java
{ "resource": "" }
q178001
LZMAEncoderNormal.calc1BytePrices
test
private void calc1BytePrices(int pos, int posState, int avail, int anyRepPrice) { // This will be set to true if using a literal or a short rep. boolean nextIsByte = false; int curByte = lz.getByte(0); int matchByte = lz.getByte(opts[optCur].reps[0] + 1); // Try a literal. int literalPrice = opts[optCur].price + literalEncoder.getPrice(curByte, matchByte, lz.getByte(1), pos, opts[optCur].state); if (literalPrice < opts[optCur + 1].price) { opts[optCur + 1].set1(literalPrice, optCur, -1); nextIsByte = true; } // Try a short rep. if (matchByte == curByte && (opts[optCur + 1].optPrev == optCur || opts[optCur + 1].backPrev != 0)) { int shortRepPrice = getShortRepPrice(anyRepPrice, opts[optCur].state, posState); if (shortRepPrice <= opts[optCur + 1].price) { opts[optCur + 1].set1(shortRepPrice, optCur, 0); nextIsByte = true; } } // If neither a literal nor a short rep was the cheapest choice, // try literal + long rep0. if (!nextIsByte && matchByte != curByte && avail > MATCH_LEN_MIN) { int lenLimit = Math.min(niceLen, avail - 1); int len = lz.getMatchLen(1, opts[optCur].reps[0], lenLimit); if (len >= MATCH_LEN_MIN) { nextState.set(opts[optCur].state); nextState.updateLiteral(); int nextPosState = (pos + 1) & posMask; int price = literalPrice + getLongRepAndLenPrice(0, len, nextState, nextPosState); int i = optCur + 1 + len; while (optEnd < i) opts[++optEnd].reset(); if (price < opts[i].price) opts[i].set2(price, optCur, 0); } } }
java
{ "resource": "" }
q178002
LZMAEncoderNormal.calcLongRepPrices
test
private int calcLongRepPrices(int pos, int posState, int avail, int anyRepPrice) { int startLen = MATCH_LEN_MIN; int lenLimit = Math.min(avail, niceLen); for (int rep = 0; rep < REPS; ++rep) { int len = lz.getMatchLen(opts[optCur].reps[rep], lenLimit); if (len < MATCH_LEN_MIN) continue; while (optEnd < optCur + len) opts[++optEnd].reset(); int longRepPrice = getLongRepPrice(anyRepPrice, rep, opts[optCur].state, posState); for (int i = len; i >= MATCH_LEN_MIN; --i) { int price = longRepPrice + repLenEncoder.getPrice(i, posState); if (price < opts[optCur + i].price) opts[optCur + i].set1(price, optCur, rep); } if (rep == 0) startLen = len + 1; int len2Limit = Math.min(niceLen, avail - len - 1); int len2 = lz.getMatchLen(len + 1, opts[optCur].reps[rep], len2Limit); if (len2 >= MATCH_LEN_MIN) { // Rep int price = longRepPrice + repLenEncoder.getPrice(len, posState); nextState.set(opts[optCur].state); nextState.updateLongRep(); // Literal int curByte = lz.getByte(len, 0); int matchByte = lz.getByte(0); // lz.getByte(len, len) int prevByte = lz.getByte(len, 1); price += literalEncoder.getPrice(curByte, matchByte, prevByte, pos + len, nextState); nextState.updateLiteral(); // Rep0 int nextPosState = (pos + len + 1) & posMask; price += getLongRepAndLenPrice(0, len2, nextState, nextPosState); int i = optCur + len + 1 + len2; while (optEnd < i) opts[++optEnd].reset(); if (price < opts[i].price) opts[i].set3(price, optCur, rep, len, 0); } } return startLen; }
java
{ "resource": "" }
q178003
LZMAEncoderNormal.calcNormalMatchPrices
test
private void calcNormalMatchPrices(int pos, int posState, int avail, int anyMatchPrice, int startLen) { // If the longest match is so long that it would not fit into // the opts array, shorten the matches. if (matches.len[matches.count - 1] > avail) { matches.count = 0; while (matches.len[matches.count] < avail) ++matches.count; matches.len[matches.count++] = avail; } if (matches.len[matches.count - 1] < startLen) return; while (optEnd < optCur + matches.len[matches.count - 1]) opts[++optEnd].reset(); int normalMatchPrice = getNormalMatchPrice(anyMatchPrice, opts[optCur].state); int match = 0; while (startLen > matches.len[match]) ++match; for (int len = startLen; ; ++len) { int dist = matches.dist[match]; // Calculate the price of a match of len bytes from the nearest // possible distance. int matchAndLenPrice = getMatchAndLenPrice(normalMatchPrice, dist, len, posState); if (matchAndLenPrice < opts[optCur + len].price) opts[optCur + len].set1(matchAndLenPrice, optCur, dist + REPS); if (len != matches.len[match]) continue; // Try match + literal + rep0. First get the length of the rep0. int len2Limit = Math.min(niceLen, avail - len - 1); int len2 = lz.getMatchLen(len + 1, dist, len2Limit); if (len2 >= MATCH_LEN_MIN) { nextState.set(opts[optCur].state); nextState.updateMatch(); // Literal int curByte = lz.getByte(len, 0); int matchByte = lz.getByte(0); // lz.getByte(len, len) int prevByte = lz.getByte(len, 1); int price = matchAndLenPrice + literalEncoder.getPrice(curByte, matchByte, prevByte, pos + len, nextState); nextState.updateLiteral(); // Rep0 int nextPosState = (pos + len + 1) & posMask; price += getLongRepAndLenPrice(0, len2, nextState, nextPosState); int i = optCur + len + 1 + len2; while (optEnd < i) opts[++optEnd].reset(); if (price < opts[i].price) opts[i].set3(price, optCur, dist + REPS, len, 0); } if (++match == matches.count) break; } }
java
{ "resource": "" }
q178004
UTF8Reader.expectedByte
test
private void expectedByte(int position, int count) throws UTFDataFormatException { throw new UTFDataFormatException( Localizer.getMessage("jsp.error.xml.expectedByte", Integer.toString(position), Integer.toString(count))); }
java
{ "resource": "" }
q178005
UTF8Reader.invalidByte
test
private void invalidByte(int position, int count, int c) throws UTFDataFormatException { throw new UTFDataFormatException( Localizer.getMessage("jsp.error.xml.invalidByte", Integer.toString(position), Integer.toString(count))); }
java
{ "resource": "" }
q178006
TldScanner.scanTlds
test
private void scanTlds() throws JasperException { mappings = new HashMap<String, String[]>(); // Make a local copy of the system jar cache jarTldCacheLocal.putAll(jarTldCache); try { processWebDotXml(); scanJars(); processTldsInFileSystem("/WEB-INF/"); } catch (JasperException ex) { throw ex; } catch (Exception ex) { throw new JasperException( Localizer.getMessage("jsp.error.internal.tldinit"), ex); } }
java
{ "resource": "" }
q178007
TldScanner.scanTld
test
private TldInfo scanTld(String resourcePath, String entryName, InputStream stream) throws JasperException { try { // Parse the tag library descriptor at the specified resource path TreeNode tld = new ParserUtils().parseXMLDocument( resourcePath, stream, isValidationEnabled); String uri = null; TreeNode uriNode = tld.findChild("uri"); if (uriNode != null) { uri = uriNode.getBody(); } ArrayList<String> listeners = new ArrayList<String>(); Iterator<TreeNode>listenerNodes = tld.findChildren("listener"); while (listenerNodes.hasNext()) { TreeNode listener = listenerNodes.next(); TreeNode listenerClass = listener.findChild("listener-class"); if (listenerClass != null) { String listenerClassName = listenerClass.getBody(); if (listenerClassName != null) { listeners.add(listenerClassName); } } } return new TldInfo(uri, entryName, listeners.toArray(new String[listeners.size()])); } finally { if (stream != null) { try { stream.close(); } catch (Throwable t) { // do nothing } } } }
java
{ "resource": "" }
q178008
JspRuntimeContext.addWrapper
test
public void addWrapper(String jspUri, JspServletWrapper jsw) { jsps.remove(jspUri); jsps.put(jspUri,jsw); }
java
{ "resource": "" }
q178009
JspRuntimeContext.getParentClassLoader
test
public ClassLoader getParentClassLoader() { ClassLoader parentClassLoader = Thread.currentThread().getContextClassLoader(); if (parentClassLoader == null) { parentClassLoader = this.getClass().getClassLoader(); } return parentClassLoader; }
java
{ "resource": "" }
q178010
JspRuntimeContext.setBytecode
test
public void setBytecode(String name, byte[] bytecode) { if (bytecode == null) { bytecodes.remove(name); bytecodeBirthTimes.remove(name); return; } bytecodes.put(name, bytecode); bytecodeBirthTimes.put(name, Long.valueOf(System.currentTimeMillis())); }
java
{ "resource": "" }
q178011
JspRuntimeContext.getBytecodeBirthTime
test
public long getBytecodeBirthTime(String name) { Long time = bytecodeBirthTimes.get(name); return (time != null? time.longValue(): 0); }
java
{ "resource": "" }
q178012
JspRuntimeContext.saveBytecode
test
public void saveBytecode(String className, String classFileName) { byte[] bytecode = getBytecode(className); if (bytecode != null) { try { FileOutputStream fos = new FileOutputStream(classFileName); fos.write(bytecode); fos.close(); } catch (IOException ex) { context.log("Error in saving bytecode for " + className + " to " + classFileName, ex); } } }
java
{ "resource": "" }
q178013
JspRuntimeContext.checkCompile
test
private void checkCompile() { for (JspServletWrapper jsw: jsps.values()) { if (jsw.isTagFile()) { // Skip tag files in background compiliations, since modified // tag files will be recompiled anyway when their client JSP // pages are compiled. This also avoids problems when the // tag files and their clients are not modified simultaneously. continue; } JspCompilationContext ctxt = jsw.getJspEngineContext(); // JspServletWrapper also synchronizes on this when // it detects it has to do a reload synchronized(jsw) { try { ctxt.compile(); } catch (FileNotFoundException ex) { ctxt.incrementRemoved(); } catch (Throwable t) { jsw.getServletContext().log( Localizer.getMessage("jsp.error.background.compile"), t); } } } }
java
{ "resource": "" }
q178014
JspRuntimeContext.initClassPath
test
private void initClassPath() { /* Classpath can be specified in one of two ways, depending on whether the compilation is embedded or invoked from Jspc. 1. Calculated by the web container, and passed to Jasper in the context attribute. 2. Jspc directly invoke JspCompilationContext.setClassPath, in case the classPath initialzed here is ignored. */ StringBuilder cpath = new StringBuilder(); String sep = System.getProperty("path.separator"); cpath.append(options.getScratchDir() + sep); String cp = (String) context.getAttribute(Constants.SERVLET_CLASSPATH); if (cp == null || cp.equals("")) { cp = options.getClassPath(); } if (cp != null) { classpath = cpath.toString() + cp; } // START GlassFish Issue 845 if (classpath != null) { try { classpath = URLDecoder.decode(classpath, "UTF-8"); } catch (UnsupportedEncodingException e) { if (log.isLoggable(Level.FINE)) log.log(Level.FINE, "Exception decoding classpath : " + classpath, e); } } // END GlassFish Issue 845 }
java
{ "resource": "" }
q178015
JspRuntimeContext.threadStart
test
protected void threadStart() { // Has the background thread already been started? if (thread != null) { return; } // Start the background thread threadDone = false; thread = new Thread(this, threadName); thread.setDaemon(true); thread.start(); }
java
{ "resource": "" }
q178016
JspRuntimeContext.threadStop
test
protected void threadStop() { if (thread == null) { return; } threadDone = true; thread.interrupt(); try { thread.join(); } catch (InterruptedException e) { ; } thread = null; }
java
{ "resource": "" }
q178017
JspRuntimeContext.run
test
public void run() { // Loop until the termination semaphore is set while (!threadDone) { // Wait for our check interval threadSleep(); // Check for included files which are newer than the // JSP which uses them. try { checkCompile(); } catch (Throwable t) { t.printStackTrace(); log.log(Level.SEVERE, Localizer .getMessage("jsp.error.recompile"), t); } } }
java
{ "resource": "" }
q178018
ChannelServiceImpl.findByName
test
private Optional<ChannelInstance> findByName ( final String name ) { if ( name == null ) { return empty (); } final String id = this.manager.accessCall ( KEY_STORAGE, ChannelServiceAccess.class, channels -> { return channels.mapToId ( name ); } ); return findById ( id ); }
java
{ "resource": "" }
q178019
ChannelServiceImpl.findChannel
test
private ChannelInstance findChannel ( final By by ) { final Optional<ChannelInstance> channel; try ( Locked l = lock ( this.readLock ) ) { channel = find ( by ); } if ( !channel.isPresent () ) { throw new ChannelNotFoundException ( by.toString () ); } return channel.get (); }
java
{ "resource": "" }
q178020
ChannelServiceImpl.updateDeployGroupCache
test
private void updateDeployGroupCache ( final ChannelServiceAccess model ) { // this will simply rebuild the complete map // clear first this.deployKeysMap.clear (); // fill afterwards for ( final Map.Entry<String, Set<String>> entry : model.getDeployGroupMap ().entrySet () ) { final String channelId = entry.getKey (); final List<DeployGroup> groups = entry.getValue ().stream ().map ( groupId -> model.getDeployGroup ( groupId ) ).collect ( Collectors.toList () ); this.deployKeysMap.putAll ( channelId, groups ); } }
java
{ "resource": "" }
q178021
ChannelServiceImpl.listGroups
test
@Override public List<DeployGroup> listGroups ( final int position, final int count ) { return this.manager.accessCall ( KEY_STORAGE, ChannelServiceAccess.class, model -> { return split ( model.getDeployGroups (), position, count ); } ); }
java
{ "resource": "" }
q178022
Streams.copy
test
public static long copy ( final InputStream in, final OutputStream out ) throws IOException { Objects.requireNonNull ( in ); Objects.requireNonNull ( out ); final byte[] buffer = new byte[COPY_BUFFER_SIZE]; long result = 0; int rc; while ( ( rc = in.read ( buffer ) ) >= 0 ) { result += rc; out.write ( buffer, 0, rc ); } return result; }
java
{ "resource": "" }
q178023
Parser.parse
test
public static Node.Nodes parse(ParserController pc, String path, JspReader reader, Node parent, boolean isTagFile, boolean directivesOnly, URL jarFileUrl, String pageEnc, String jspConfigPageEnc, boolean isDefaultPageEncoding, boolean hasBom) throws JasperException { Parser parser = new Parser(pc, reader, isTagFile, directivesOnly, jarFileUrl, hasBom); Node.Root root = new Node.Root(reader.mark(), parent, false); root.setPageEncoding(pageEnc); root.setJspConfigPageEncoding(jspConfigPageEnc); root.setIsDefaultPageEncoding(isDefaultPageEncoding); root.setHasBom(hasBom); if (hasBom) { // Consume (remove) BOM, so it won't appear in page output char bomChar = (char) reader.nextChar(); if (bomChar != 0xFEFF) { parser.err.jspError( reader.mark(), "jsp.error.invalidBom", Integer.toHexString(bomChar).toUpperCase()); } } if (directivesOnly) { parser.parseTagFileDirectives(root); return new Node.Nodes(root); } // For the Top level page, add inlcude-prelude and include-coda PageInfo pageInfo = pc.getCompiler().getPageInfo(); if (parent == null) { parser.addInclude(root, pageInfo.getIncludePrelude()); } while (reader.hasMoreInput()) { parser.parseElements(root); } if (parent == null) { parser.addInclude(root, pageInfo.getIncludeCoda()); parser.pageInfo.setRootPath(path); } Node.Nodes page = new Node.Nodes(root); return page; }
java
{ "resource": "" }
q178024
Parser.parseAttributes
test
public static Attributes parseAttributes(ParserController pc, JspReader reader) throws JasperException { Parser tmpParser = new Parser(pc, reader, false, false, null, false); return tmpParser.parseAttributes(); }
java
{ "resource": "" }
q178025
Parser.parseQuoted
test
private String parseQuoted(String tx) { StringBuilder buf = new StringBuilder(); int size = tx.length(); int i = 0; while (i < size) { char ch = tx.charAt(i); if (ch == '&') { if (i+5 < size && tx.charAt(i+1) == 'a' && tx.charAt(i+2) == 'p' && tx.charAt(i+3) == 'o' && tx.charAt(i+4) == 's' && tx.charAt(i+5) == ';') { buf.append('\''); i += 6; } else if (i+5 < size && tx.charAt(i+1) == 'q' && tx.charAt(i+2) == 'u' && tx.charAt(i+3) == 'o' && tx.charAt(i+4) == 't' && tx.charAt(i+5) == ';') { buf.append('"'); i += 6; } else { buf.append(ch); ++i; } } else if (ch == '\\' && i+1 < size) { ch = tx.charAt(i+1); if (ch == '\\' || ch == '\"' || ch == '\'' || ch == '>') { buf.append(ch); i += 2; } else { buf.append('\\'); ++i; } } else { buf.append(ch); ++i; } } return buf.toString(); }
java
{ "resource": "" }
q178026
Parser.addInclude
test
private void addInclude(Node parent, List files) throws JasperException { if( files != null ) { Iterator iter = files.iterator(); while (iter.hasNext()) { String file = (String) iter.next(); AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "file", "file", "CDATA", file); // Create a dummy Include directive node Node includeNode = new Node.IncludeDirective(attrs, reader.mark(), parent); processIncludeDirective(file, includeNode); } } }
java
{ "resource": "" }
q178027
Parser.parseJspAttributeAndBody
test
private boolean parseJspAttributeAndBody( Node parent, String tag, String bodyType ) throws JasperException { boolean result = false; if( reader.matchesOptionalSpacesFollowedBy( "<jsp:attribute" ) ) { // May be an EmptyBody, depending on whether // There's a "<jsp:body" before the ETag // First, parse <jsp:attribute> elements: parseNamedAttributes( parent ); result = true; } if( reader.matchesOptionalSpacesFollowedBy( "<jsp:body" ) ) { // ActionBody parseJspBody( parent, bodyType ); reader.skipSpaces(); if( !reader.matchesETag( tag ) ) { err.jspError(reader.mark(), "jsp.error.unterminated", "&lt;" + tag ); } result = true; } else if( result && !reader.matchesETag( tag ) ) { // If we have <jsp:attribute> but something other than // <jsp:body> or the end tag, translation error. err.jspError(reader.mark(), "jsp.error.jspbody.required", "&lt;" + tag ); } return result; }
java
{ "resource": "" }
q178028
TreeNode.addAttribute
test
public void addAttribute(String name, String value) { if (attributes == null) attributes = new HashMap<String, String>(); attributes.put(name, value); }
java
{ "resource": "" }
q178029
TreeNode.addChild
test
public void addChild(TreeNode node) { if (children == null) children = new ArrayList<TreeNode>(); children.add(node); }
java
{ "resource": "" }
q178030
TreeNode.findAttributes
test
public Iterator<String> findAttributes() { Set<String> attrs; if (attributes == null) attrs = Collections.emptySet(); else attrs = attributes.keySet(); return attrs.iterator(); }
java
{ "resource": "" }
q178031
TreeNode.findChildren
test
public Iterator<TreeNode> findChildren() { List<TreeNode> nodes; if (children == null) nodes = Collections.emptyList(); else nodes = children; return nodes.iterator(); }
java
{ "resource": "" }
q178032
TreeNode.findChildren
test
public Iterator<TreeNode> findChildren(String name) { List<TreeNode> results; if (children == null) results = Collections.emptyList(); else { results = new ArrayList<TreeNode>(); for (TreeNode item: children) { if (name.equals(item.getName())) results.add(item); } } return results.iterator(); }
java
{ "resource": "" }
q178033
MavenCoordinates.toBase
test
public MavenCoordinates toBase () { if ( this.classifier == null && this.extension == null ) { return this; } return new MavenCoordinates ( this.groupId, this.artifactId, this.version ); }
java
{ "resource": "" }
q178034
JspContextWrapper.findAlias
test
private String findAlias(String varName) { if (aliases == null) return varName; String alias = aliases.get(varName); if (alias == null) { return varName; } return alias; }
java
{ "resource": "" }
q178035
SystemLogHandler.setThread
test
public static void setThread() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); data.set(baos); streams.set(new PrintStream(baos)); }
java
{ "resource": "" }
q178036
SystemLogHandler.unsetThread
test
public static String unsetThread() { ByteArrayOutputStream baos = (ByteArrayOutputStream) data.get(); if (baos == null) { return null; } streams.set(null); data.set(null); return baos.toString(); }
java
{ "resource": "" }
q178037
SystemLogHandler.findStream
test
protected PrintStream findStream() { PrintStream ps = (PrintStream) streams.get(); if (ps == null) { ps = wrapped; } return ps; }
java
{ "resource": "" }
q178038
RepoBuilder.writeOptional
test
protected static void writeOptional ( final StringWriter writer, final String fieldName, final String value ) { if ( value != null ) { write ( writer, fieldName, value ); } }
java
{ "resource": "" }
q178039
RepoBuilder.write
test
protected static void write ( final StringWriter writer, final String fieldName, final String value ) { writer.write ( fieldName + ": " + value + "\n" ); }
java
{ "resource": "" }
q178040
XmlHelper.addElement
test
public static Element addElement ( final Element parent, final String name ) { final Element ele = parent.getOwnerDocument ().createElement ( name ); parent.appendChild ( ele ); return ele; }
java
{ "resource": "" }
q178041
XmlHelper.addElementFirst
test
public static Element addElementFirst ( final Element parent, final String name ) { final Element ele = parent.getOwnerDocument ().createElement ( name ); parent.insertBefore ( ele, null ); return ele; }
java
{ "resource": "" }
q178042
BodyContentImpl.writeOut
test
public void writeOut(Writer out) throws IOException { if (writer == null) { out.write(cb, 0, nextChar); // Flush not called as the writer passed could be a BodyContent and // it doesn't allow to flush. } }
java
{ "resource": "" }
q178043
BodyContentImpl.setWriter
test
void setWriter(Writer writer) { this.writer = writer; if (writer != null) { // According to the spec, the JspWriter returned by // JspContext.pushBody(java.io.Writer writer) must behave as // though it were unbuffered. This means that its getBufferSize() // must always return 0. The implementation of // JspWriter.getBufferSize() returns the value of JspWriter's // 'bufferSize' field, which is inherited by this class. // Therefore, we simply save the current 'bufferSize' (so we can // later restore it should this BodyContentImpl ever be reused by // a call to PageContext.pushBody()) before setting it to 0. if (bufferSize != 0) { bufferSizeSave = bufferSize; bufferSize = 0; } } else { bufferSize = bufferSizeSave; clearBody(); } }
java
{ "resource": "" }
q178044
BodyContentImpl.reAllocBuff
test
private void reAllocBuff(int len) { if (bufferSize + len <= cb.length) { bufferSize = cb.length; return; } if (len < cb.length) { len = cb.length; } bufferSize = cb.length + len; char[] tmp = new char[bufferSize]; System.arraycopy(cb, 0, tmp, 0, cb.length); cb = tmp; tmp = null; }
java
{ "resource": "" }
q178045
ELFunctionMapper.map
test
public static void map(Compiler compiler, Node.Nodes page) throws JasperException { ELFunctionMapper map = new ELFunctionMapper(); map.ds = new StringBuilder(); map.ss = new StringBuilder(); page.visit(map.new ELFunctionVisitor()); // Append the declarations to the root node String ds = map.ds.toString(); if (ds.length() > 0) { Node root = page.getRoot(); new Node.Declaration(map.ss.toString(), null, root); new Node.Declaration("static {\n" + ds + "}\n", null, root); } }
java
{ "resource": "" }
q178046
StorageManager.getSameParent
test
private static State getSameParent ( final State parent, final MetaKey key ) { State current = parent; while ( current != null ) { if ( current.key.equals ( key ) ) { return current; } current = current.parent; } return null; }
java
{ "resource": "" }
q178047
StorageManager.registerModel
test
public StorageRegistration registerModel ( final long lockPriority, final MetaKey key, final StorageModelProvider<?, ?> storageProvider ) throws ModelInitializationException { this.modelLock.writeLock ().lock (); try { testClosed (); if ( this.modelKeyMap.containsKey ( key ) ) { throw new IllegalArgumentException ( String.format ( "A provider for '%s' is already registered", key ) ); } try { storageProvider.start ( this.context ); } catch ( final Exception e ) { throw new ModelInitializationException ( "Failed to start model provider: " + key, e ); } final long id = this.counter++; final Entry entry = new Entry ( id, lockPriority, key, storageProvider ); this.modelIdMap.put ( id, entry ); this.modelKeyMap.put ( key, entry ); return new StorageRegistration () { @Override public void unregister () { unregisterModel ( id ); } }; } finally { this.modelLock.writeLock ().unlock (); } }
java
{ "resource": "" }
q178048
CacheStore.stream
test
public boolean stream ( final MetaKey key, final IOConsumer<InputStream> consumer ) throws IOException { return streamFrom ( this.dataPath, key, consumer ); }
java
{ "resource": "" }
q178049
JobController.monitor
test
@RequestMapping ( "/{id}/monitor" ) public ModelAndView monitor ( @PathVariable ( "id" ) final String id) { final JobHandle job = this.manager.getJob ( id ); if ( job != null ) { logger.debug ( "Job: {} - {}", job.getId (), job.getState () ); } else { logger.debug ( "No job: {}", id ); } final Map<String, Object> model = new HashMap<> ( 1 ); model.put ( "job", job ); return new ModelAndView ( "monitor", model ); }
java
{ "resource": "" }
q178050
AbstractChannelServiceServlet.isAuthenticated
test
protected boolean isAuthenticated ( final By by, final HttpServletRequest request ) { final String[] authToks = parseAuthorization ( request ); if ( authToks == null ) { return false; } // we don't enforce the "deploy" user name anymore final String deployKey = authToks[1]; logger.debug ( "Deploy key: '{}'", deployKey ); final ChannelService service = getService ( request ); if ( service == null ) { logger.info ( "Called 'isAuthenticated' without service" ); return false; } return service.getChannelDeployKeyStrings ( by ).orElse ( Collections.emptySet () ).contains ( deployKey ); }
java
{ "resource": "" }
q178051
UrlSetWriter.finish
test
public void finish () throws IOException { if ( !this.finished ) { this.finished = true; writeEnd (); } try { this.out.close (); } catch ( final XMLStreamException e ) { throw new IOException ( e ); } }
java
{ "resource": "" }
q178052
ChannelData.makeGson
test
public static Gson makeGson ( final boolean pretty ) { final GsonBuilder gb = new GsonBuilder (); if ( pretty ) { gb.setPrettyPrinting (); } gb.registerTypeAdapter ( Node.class, new NodeAdapter () ); gb.registerTypeAdapter ( byte[].class, new ByteArrayAdapter () ); return gb.create (); }
java
{ "resource": "" }
q178053
LZMAEncoder.encodeForLZMA2
test
public boolean encodeForLZMA2() { // LZMA2 uses RangeEncoderToBuffer so IOExceptions aren't possible. try { if (!lz.isStarted() && !encodeInit()) return false; while (uncompressedSize <= LZMA2_UNCOMPRESSED_LIMIT && rc.getPendingSize() <= LZMA2_COMPRESSED_LIMIT) if (!encodeSymbol()) return false; } catch (IOException e) { throw new Error(); } return true; }
java
{ "resource": "" }
q178054
MetaKeys.union
test
public static Map<MetaKey, String> union ( final Map<MetaKey, String> providedMetaData, final Map<MetaKey, String> extractedMetaData ) { final int size1 = providedMetaData != null ? providedMetaData.size () : 0; final int size2 = extractedMetaData != null ? extractedMetaData.size () : 0; if ( size1 + size2 == 0 ) { return Collections.emptyMap (); } final Map<MetaKey, String> result = new HashMap<> ( size1 + size2 ); if ( extractedMetaData != null ) { result.putAll ( extractedMetaData ); } // provided will override if ( providedMetaData != null ) { result.putAll ( providedMetaData ); } return Collections.unmodifiableMap ( result ); }
java
{ "resource": "" }
q178055
JspRuntimeLibrary.getThrowable
test
public static Throwable getThrowable(ServletRequest request) { Throwable error = (Throwable) request.getAttribute(SERVLET_EXCEPTION); if (error == null) { error = (Throwable) request.getAttribute(JSP_EXCEPTION); if (error != null) { /* * The only place that sets JSP_EXCEPTION is * PageContextImpl.handlePageException(). It really should set * SERVLET_EXCEPTION, but that would interfere with the * ErrorReportValve. Therefore, if JSP_EXCEPTION is set, we * need to set SERVLET_EXCEPTION. */ request.setAttribute(SERVLET_EXCEPTION, error); } } return error; }
java
{ "resource": "" }
q178056
Uploader.isCheckSum
test
private String isCheckSum ( final Coordinates c ) { final String cext = c.getExtension (); if ( cext == null ) { return null; } for ( final String ext : this.options.getChecksumExtensions () ) { if ( cext.endsWith ( "." + ext ) ) { return ext; } } return null; }
java
{ "resource": "" }
q178057
LZMAOutputStream.finish
test
public void finish() throws IOException { if (!finished) { if (exception != null) throw exception; try { if (expectedUncompressedSize != -1 && expectedUncompressedSize != currentUncompressedSize) throw new XZIOException("Expected uncompressed size (" + expectedUncompressedSize + ") doesn't equal " + "the number of bytes written to the stream (" + currentUncompressedSize + ")"); lz.setFinishing(); lzma.encodeForLZMA1(); if (useEndMarker) lzma.encodeLZMA1EndMarker(); rc.finish(); } catch (IOException e) { exception = e; throw e; } finished = true; lzma.putArraysToCache(arrayCache); lzma = null; lz = null; } }
java
{ "resource": "" }
q178058
PageContextImpl.getException
test
public Exception getException() { Throwable t = JspRuntimeLibrary.getThrowable(request); // Only wrap if needed if((t != null) && (! (t instanceof Exception))) { t = new JspException(t); } return (Exception) t; }
java
{ "resource": "" }
q178059
PageContextImpl.evaluateExpression
test
public static Object evaluateExpression(final String expression, final Class expectedType, final PageContext pageContext, final ProtectedFunctionMapper functionMap) throws ELException { Object retValue; if (SecurityUtil.isPackageProtectionEnabled()){ try { retValue = AccessController.doPrivileged( new PrivilegedExceptionAction<Object>(){ public Object run() throws Exception{ ELContextImpl elContext = (ELContextImpl) pageContext.getELContext(); elContext.setFunctionMapper(functionMap); ExpressionFactory expFactory = getExpressionFactory(pageContext); ValueExpression expr = expFactory.createValueExpression( elContext, expression, expectedType); return expr.getValue(elContext); } }); } catch (PrivilegedActionException ex) { Exception realEx = ex.getException(); if (realEx instanceof ELException) { throw (ELException) realEx; } else { throw new ELException(realEx); } } } else { ELContextImpl elContext = (ELContextImpl)pageContext.getELContext(); elContext.setFunctionMapper(functionMap); ExpressionFactory expFactory = getExpressionFactory(pageContext); ValueExpression expr = expFactory.createValueExpression( elContext, expression, expectedType); retValue = expr.getValue(elContext); } return retValue; }
java
{ "resource": "" }
q178060
SystemServiceImpl.makePrefixFromOsgiProperties
test
protected String makePrefixFromOsgiProperties () { final String port = System.getProperty ( "org.osgi.service.http.port" ); if ( port == null ) { return null; } final StringBuilder sb = new StringBuilder (); sb.append ( "http://" ).append ( discoverHostname () ); if ( !"80".equals ( port ) ) { sb.append ( ':' ).append ( port ); } return sb.toString (); }
java
{ "resource": "" }
q178061
XmlFiles.isXml
test
public static boolean isXml ( final Path path ) throws IOException { final XmlToolsFactory xml = Activator.getXmlToolsFactory (); final XMLInputFactory xin = xml.newXMLInputFactory (); try ( InputStream stream = new BufferedInputStream ( Files.newInputStream ( path ) ) ) { try { final XMLStreamReader reader = xin.createXMLStreamReader ( stream ); reader.next (); return true; } catch ( final XMLStreamException e ) { return false; } } }
java
{ "resource": "" }
q178062
TagFileProcessor.parseTagFileDirectives
test
public static TagInfo parseTagFileDirectives(ParserController pc, String name, String path, TagLibraryInfo tagLibInfo) throws JasperException { ErrorDispatcher err = pc.getCompiler().getErrorDispatcher(); Node.Nodes page = null; try { page = pc.parseTagFileDirectives(path); } catch (FileNotFoundException e) { err.jspError("jsp.error.file.not.found", path); } catch (IOException e) { err.jspError("jsp.error.file.not.found", path); } TagFileDirectiveVisitor tagFileVisitor = new TagFileDirectiveVisitor(pc.getCompiler(), tagLibInfo, name, path); page.visit(tagFileVisitor); tagFileVisitor.postCheck(); return tagFileVisitor.getTagInfo(); }
java
{ "resource": "" }
q178063
TagFileProcessor.loadTagFile
test
private Class loadTagFile(Compiler compiler, String tagFilePath, TagInfo tagInfo, PageInfo parentPageInfo) throws JasperException { JspCompilationContext ctxt = compiler.getCompilationContext(); JspRuntimeContext rctxt = ctxt.getRuntimeContext(); synchronized(rctxt) { JspServletWrapper wrapper = (JspServletWrapper) rctxt.getWrapper(tagFilePath); if (wrapper == null) { wrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt.getOptions(), tagFilePath, tagInfo, ctxt.getRuntimeContext(), (URL) ctxt.getTagFileJarUrls().get(tagFilePath)); rctxt.addWrapper(tagFilePath,wrapper); // Use same classloader and classpath for compiling tag files wrapper.getJspEngineContext().setClassLoader( (URLClassLoader) ctxt.getClassLoader()); wrapper.getJspEngineContext().setClassPath(ctxt.getClassPath()); } else { // Make sure that JspCompilationContext gets the latest TagInfo // for the tag file. TagInfo instance was created the last // time the tag file was scanned for directives, and the tag // file may have been modified since then. wrapper.getJspEngineContext().setTagInfo(tagInfo); } Class tagClazz; int tripCount = wrapper.incTripCount(); try { if (tripCount > 0) { // When tripCount is greater than zero, a circular // dependency exists. The circularily dependant tag // file is compiled in prototype mode, to avoid infinite // recursion. JspServletWrapper tempWrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt.getOptions(), tagFilePath, tagInfo, ctxt.getRuntimeContext(), (URL) ctxt.getTagFileJarUrls().get(tagFilePath)); tagClazz = tempWrapper.loadTagFilePrototype(); tempVector.add( tempWrapper.getJspEngineContext().getCompiler()); } else { tagClazz = wrapper.loadTagFile(); } } finally { wrapper.decTripCount(); } // Add the dependants for this tag file to its parent's // dependant list. The only reliable dependency information // can only be obtained from the tag instance. try { Object tagIns = tagClazz.newInstance(); if (tagIns instanceof JspSourceDependent) { for (String dependant: ((JspSourceDependent)tagIns).getDependants()) { parentPageInfo.addDependant(dependant); } } } catch (Exception e) { // ignore errors } return tagClazz; } }
java
{ "resource": "" }
q178064
TagFileProcessor.removeProtoTypeFiles
test
public void removeProtoTypeFiles(String classFileName) { Iterator<Compiler> iter = tempVector.iterator(); while (iter.hasNext()) { Compiler c = iter.next(); if (classFileName == null) { c.removeGeneratedClassFiles(); } else if (classFileName.equals( c.getCompilationContext().getClassFileName())) { c.removeGeneratedClassFiles(); tempVector.remove(c); return; } } }
java
{ "resource": "" }
q178065
JspC.main
test
public static void main(String arg[]) { if (arg.length == 0) { System.out.println(Localizer.getMessage("jspc.usage")); } else { JspC jspc = new JspC(); try { jspc.setArgs(arg); if (jspc.helpNeeded) { System.out.println(Localizer.getMessage("jspc.usage")); } else { jspc.execute(); } } catch (JasperException je) { System.err.println(je); //System.err.println(je.getMessage()); if (jspc.getDieLevel() != NO_DIE_LEVEL) { System.exit(jspc.getDieLevel()); } } } }
java
{ "resource": "" }
q178066
JspC.setUriroot
test
public void setUriroot( String s ) { uriRoot = s; if (s != null) { try { uriRoot=new File( s ).getCanonicalPath(); } catch( Exception ex ) { uriRoot=s; } } }
java
{ "resource": "" }
q178067
JspC.scanFiles
test
public void scanFiles( File base ) throws JasperException { Stack<String> dirs = new Stack<String>(); dirs.push(base.toString()); if (extensions == null) { extensions = new ArrayList<String>(); extensions.add("jsp"); extensions.add("jspx"); } while (!dirs.isEmpty()) { String s = dirs.pop(); File f = new File(s); if (f.exists() && f.isDirectory()) { String[] files = f.list(); String ext; for (int i = 0; (files != null) && i < files.length; i++) { File f2 = new File(s, files[i]); if (f2.isDirectory()) { dirs.push(f2.getPath()); } else { String path = f2.getPath(); String uri = path.substring(uriRoot.length()); ext = files[i].substring(files[i].lastIndexOf('.') +1); if (extensions.contains(ext) || jspConfig.isJspPage(uri)) { pages.add(path); } } } } } }
java
{ "resource": "" }
q178068
JspC.locateUriRoot
test
private void locateUriRoot( File f ) { String tUriBase = uriBase; if (tUriBase == null) { tUriBase = "/"; } try { if (f.exists()) { f = new File(f.getCanonicalPath()); while (f != null) { File g = new File(f, "WEB-INF"); if (g.exists() && g.isDirectory()) { uriRoot = f.getCanonicalPath(); uriBase = tUriBase; if (log.isLoggable(Level.INFO)) { log.info( Localizer.getMessage("jspc.implicit.uriRoot", uriRoot)); } break; } if (f.exists() && f.isDirectory()) { tUriBase = "/" + f.getName() + "/" + tUriBase; } String fParent = f.getParent(); if (fParent == null) { break; } else { f = new File(fParent); } // If there is no acceptible candidate, uriRoot will // remain null to indicate to the CompilerContext to // use the current working/user dir. } if (uriRoot != null) { File froot = new File(uriRoot); uriRoot = froot.getCanonicalPath(); } } } catch (IOException ioe) { // since this is an optional default and a null value // for uriRoot has a non-error meaning, we can just // pass straight through } }
java
{ "resource": "" }
q178069
JspC.initSystemClassLoader
test
private ClassLoader initSystemClassLoader() throws IOException { String sysClassPath = getSystemClassPath(); if (sysClassPath == null) { return null; } ArrayList<URL> urls = new ArrayList<URL>(); StringTokenizer tokenizer = new StringTokenizer(sysClassPath, File.pathSeparator); while (tokenizer.hasMoreTokens()) { urls.add(new File(tokenizer.nextToken()).toURL()); } if (urls.size() == 0) { return null; } URL urlsArray[] = new URL[urls.size()]; urls.toArray(urlsArray); return new URLClassLoader(urlsArray, this.getClass().getClassLoader()); }
java
{ "resource": "" }
q178070
HC4.movePos
test
private int movePos() { int avail = movePos(4, 4); if (avail != 0) { if (++lzPos == Integer.MAX_VALUE) { int normalizationOffset = Integer.MAX_VALUE - cyclicSize; hash.normalize(normalizationOffset); normalize(chain, cyclicSize, normalizationOffset); lzPos -= normalizationOffset; } if (++cyclicPos == cyclicSize) cyclicPos = 0; } return avail; }
java
{ "resource": "" }
q178071
JspReader.matches
test
boolean matches(String string) throws JasperException { Mark mark = mark(); int ch = 0; int i = 0; do { ch = nextChar(); if (((char) ch) != string.charAt(i++)) { reset(mark); return false; } } while (i < string.length()); return true; }
java
{ "resource": "" }
q178072
JspReader.matchesOptionalSpacesFollowedBy
test
boolean matchesOptionalSpacesFollowedBy( String s ) throws JasperException { Mark mark = mark(); skipSpaces(); boolean result = matches( s ); if( !result ) { reset( mark ); } return result; }
java
{ "resource": "" }
q178073
JspReader.skipUntil
test
Mark skipUntil(String limit) throws JasperException { Mark ret = null; int limlen = limit.length(); int ch; skip: for (ret = mark(), ch = nextChar() ; ch != -1 ; ret = mark(), ch = nextChar()) { if (ch == limit.charAt(0)) { Mark restart = mark(); for (int i = 1 ; i < limlen ; i++) { if (peekChar() == limit.charAt(i)) nextChar(); else { reset(restart); continue skip; } } return ret; } } return null; }
java
{ "resource": "" }
q178074
JspReader.skipUntilIgnoreEsc
test
Mark skipUntilIgnoreEsc(String limit) throws JasperException { Mark ret = null; int limlen = limit.length(); int ch; int prev = 'x'; // Doesn't matter skip: for (ret = mark(), ch = nextChar() ; ch != -1 ; ret = mark(), prev = ch, ch = nextChar()) { if (ch == '\\' && prev == '\\') { ch = 0; // Double \ is not an escape char anymore } else if (ch == limit.charAt(0) && prev != '\\') { for (int i = 1 ; i < limlen ; i++) { if (peekChar() == limit.charAt(i)) nextChar(); else continue skip; } return ret; } } return null; }
java
{ "resource": "" }
q178075
JspReader.skipUntilETag
test
Mark skipUntilETag(String tag) throws JasperException { Mark ret = skipUntil("</" + tag); if (ret != null) { skipSpaces(); if (nextChar() != '>') ret = null; } return ret; }
java
{ "resource": "" }
q178076
JspReader.parseToken
test
String parseToken(boolean quoted) throws JasperException { StringBuilder stringBuffer = new StringBuilder(); skipSpaces(); stringBuffer.setLength(0); if (!hasMoreInput()) { return ""; } int ch = peekChar(); if (quoted) { if (ch == '"' || ch == '\'') { char endQuote = ch == '"' ? '"' : '\''; // Consume the open quote: ch = nextChar(); for (ch = nextChar(); ch != -1 && ch != endQuote; ch = nextChar()) { if (ch == '\\') ch = nextChar(); stringBuffer.append((char) ch); } // Check end of quote, skip closing quote: if (ch == -1) { err.jspError(mark(), "jsp.error.quotes.unterminated"); } } else { err.jspError(mark(), "jsp.error.attr.quoted"); } } else { if (!isDelimiter()) { // Read value until delimiter is found: do { ch = nextChar(); // Take care of the quoting here. if (ch == '\\') { if (peekChar() == '"' || peekChar() == '\'' || peekChar() == '>' || peekChar() == '%') ch = nextChar(); } stringBuffer.append((char) ch); } while (!isDelimiter()); } } return stringBuffer.toString(); }
java
{ "resource": "" }
q178077
JspReader.popFile
test
private boolean popFile() throws JasperException { // Is stack created ? (will happen if the Jsp file we're looking at is // missing. if (current == null || currFileId < 0) { return false; } // Restore parser state: String fName = getFile(currFileId); currFileId = unregisterSourceFile(fName); if (currFileId < -1) { err.jspError("jsp.error.file.not.registered", fName); } Mark previous = current.popStream(); if (previous != null) { master = current.baseDir; current = previous; return true; } // Note that although the current file is undefined here, "current" // is not set to null just for convience, for it maybe used to // set the current (undefined) position. return false; }
java
{ "resource": "" }
q178078
Coordinates.makeUnclassified
test
public Coordinates makeUnclassified () { if ( this.classifier == null ) { return this; } return new Coordinates ( this.groupId, this.artifactId, this.version, this.qualifiedVersion, null, this.extension ); }
java
{ "resource": "" }
q178079
AspectInformation.filterIds
test
public static List<AspectInformation> filterIds ( final List<AspectInformation> list, final Predicate<String> predicate ) { if ( list == null ) { return null; } return list.stream ().filter ( ( i ) -> predicate.test ( i.getFactoryId () ) ).collect ( Collectors.toList () ); }
java
{ "resource": "" }
q178080
AspectInformation.getMissingIds
test
public String[] getMissingIds ( final List<AspectInformation> assignedAspects ) { final Set<AspectInformation> required = new HashSet<> (); addRequired ( required, this, assignedAspects ); return required.stream ().map ( AspectInformation::getFactoryId ).toArray ( size -> new String[size] ); }
java
{ "resource": "" }
q178081
ParserUtils.setSchemaResourcePrefix
test
public static void setSchemaResourcePrefix(String prefix) { if (prefix != null && prefix.startsWith("file:")) { schemaResourcePrefix = uencode(prefix); isSchemaResourcePrefixFileUrl = true; } else { schemaResourcePrefix = prefix; isSchemaResourcePrefixFileUrl = false; } for (int i=0; i<CACHED_SCHEMA_RESOURCE_PATHS.length; i++) { String path = DEFAULT_SCHEMA_RESOURCE_PATHS[i]; int index = path.lastIndexOf('/'); if (index != -1) { CACHED_SCHEMA_RESOURCE_PATHS[i] = schemaResourcePrefix + path.substring(index+1); } } }
java
{ "resource": "" }
q178082
ParserUtils.setDtdResourcePrefix
test
public static void setDtdResourcePrefix(String prefix) { if (prefix != null && prefix.startsWith("file:")) { dtdResourcePrefix = uencode(prefix); isDtdResourcePrefixFileUrl = true; } else { dtdResourcePrefix = prefix; isDtdResourcePrefixFileUrl = false; } for (int i=0; i<CACHED_DTD_RESOURCE_PATHS.length; i++) { String path = DEFAULT_DTD_RESOURCE_PATHS[i]; int index = path.lastIndexOf('/'); if (index != -1) { CACHED_DTD_RESOURCE_PATHS[i] = dtdResourcePrefix + path.substring(index+1); } } }
java
{ "resource": "" }
q178083
ParserUtils.uencode
test
private static String uencode(String prefix) { if (prefix != null && prefix.startsWith("file:")) { StringTokenizer tokens = new StringTokenizer(prefix, "/\\:", true); StringBuilder stringBuilder = new StringBuilder(); while (tokens.hasMoreElements()) { String token = tokens.nextToken(); if ("/".equals(token) || "\\".equals(token) || ":".equals(token)) { stringBuilder.append(token); } else { try { stringBuilder.append(URLEncoder.encode(token, "UTF-8")); } catch(java.io.UnsupportedEncodingException ex) { } } } return stringBuilder.toString(); } else { return prefix; } }
java
{ "resource": "" }
q178084
ParserUtils.convert
test
protected TreeNode convert(TreeNode parent, Node node) { // Construct a new TreeNode for this node TreeNode treeNode = new TreeNode(node.getNodeName(), parent); // Convert all attributes of this node NamedNodeMap attributes = node.getAttributes(); if (attributes != null) { int n = attributes.getLength(); for (int i = 0; i < n; i++) { Node attribute = attributes.item(i); treeNode.addAttribute(attribute.getNodeName(), attribute.getNodeValue()); } } // Create and attach all children of this node NodeList children = node.getChildNodes(); if (children != null) { int n = children.getLength(); for (int i = 0; i < n; i++) { Node child = children.item(i); if (child instanceof Comment) continue; if (child instanceof Text) { String body = ((Text) child).getData(); if (body != null) { body = body.trim(); if (body.length() > 0) treeNode.setBody(body); } } else { TreeNode treeChild = convert(treeNode, child); } } } // Return the completed TreeNode graph return (treeNode); }
java
{ "resource": "" }
q178085
BindingManager.mergeErrors
test
private static void mergeErrors ( final BindingResult bindingResult, final BindingResult result ) { if ( bindingResult == null ) { return; } result.addErrors ( bindingResult.getLocalErrors () ); for ( final Map.Entry<String, BindingResult> child : bindingResult.getChildren ().entrySet () ) { mergeErrors ( child.getValue (), result.getChildOrAdd ( child.getKey () ) ); } }
java
{ "resource": "" }
q178086
BindingManager.initializeBinder
test
private void initializeBinder ( final Binder binder ) { for ( final Method m : binder.getClass ().getMethods () ) { if ( !m.isAnnotationPresent ( Binder.Initializer.class ) ) { continue; } final Call call = bind ( m, binder ); try { call.invoke (); } catch ( final Exception e ) { throw new RuntimeException ( String.format ( "Failed to initialze binder: %s # %s", binder, m ), e ); } } }
java
{ "resource": "" }
q178087
ChannelAspectProcessor.scanAspectInformations
test
public static Map<String, ChannelAspectInformation> scanAspectInformations ( final BundleContext context ) { Collection<ServiceReference<ChannelAspectFactory>> refs; try { refs = context.getServiceReferences ( ChannelAspectFactory.class, null ); } catch ( final InvalidSyntaxException e ) { // this should never happen since we don't specific a filter return Collections.emptyMap (); } if ( refs == null ) { return Collections.emptyMap (); } final Map<String, ChannelAspectInformation> result = new HashMap<> ( refs.size () ); for ( final ServiceReference<ChannelAspectFactory> ref : refs ) { final ChannelAspectInformation info = makeInformation ( ref ); result.put ( info.getFactoryId (), info ); } return result; }
java
{ "resource": "" }
q178088
SmapUtil.unqualify
test
private static String unqualify(String path) { path = path.replace('\\', '/'); return path.substring(path.lastIndexOf('/') + 1); }
java
{ "resource": "" }
q178089
TagPluginManager.invokePlugin
test
private void invokePlugin(Node.CustomTag n) { TagPlugin tagPlugin = tagPlugins.get(n.getTagHandlerClass().getName()); if (tagPlugin == null) { return; } TagPluginContext tagPluginContext = new TagPluginContextImpl(n, pageInfo); n.setTagPluginContext(tagPluginContext); tagPlugin.doTag(tagPluginContext); }
java
{ "resource": "" }
q178090
BasicArrayCache.getByteArray
test
public byte[] getByteArray(int size, boolean fillWithZeros) { byte[] array = getArray(byteArrayCache, size); if (array == null) array = new byte[size]; else if (fillWithZeros) Arrays.fill(array, (byte)0x00); return array; }
java
{ "resource": "" }
q178091
BasicArrayCache.getIntArray
test
public int[] getIntArray(int size, boolean fillWithZeros) { int[] array = getArray(intArrayCache, size); if (array == null) array = new int[size]; else if (fillWithZeros) Arrays.fill(array, 0); return array; }
java
{ "resource": "" }
q178092
AetherImporter.asResult
test
public static AetherResult asResult ( final Collection<ArtifactResult> results, final ImportConfiguration cfg, final Optional<DependencyResult> dependencyResult ) { final AetherResult result = new AetherResult (); // create set of requested coordinates final Set<String> requested = new HashSet<> ( cfg.getCoordinates ().size () ); for ( final MavenCoordinates mc : cfg.getCoordinates () ) { requested.add ( mc.toString () ); } // generate dependency map final Map<String, Boolean> optionalDeps = new HashMap<> (); fillOptionalDependenciesMap ( dependencyResult, optionalDeps ); // convert artifacts for ( final ArtifactResult ar : results ) { final AetherResult.Entry entry = new AetherResult.Entry (); final MavenCoordinates coordinates = MavenCoordinates.fromResult ( ar ); final String key = coordinates.toBase ().toString (); entry.setCoordinates ( coordinates ); entry.setResolved ( ar.isResolved () ); entry.setRequested ( requested.contains ( key ) ); entry.setOptional ( optionalDeps.getOrDefault ( key, Boolean.FALSE ) ); // convert error if ( ar.getExceptions () != null && !ar.getExceptions ().isEmpty () ) { final StringBuilder sb = new StringBuilder ( ar.getExceptions ().get ( 0 ).getMessage () ); if ( ar.getExceptions ().size () > 1 ) { sb.append ( " ..." ); } entry.setError ( sb.toString () ); } // add to list result.getArtifacts ().add ( entry ); } // sort by coordinates Collections.sort ( result.getArtifacts (), Comparator.comparing ( AetherResult.Entry::getCoordinates ) ); // set repo url result.setRepositoryUrl ( cfg.getRepositoryUrl () ); return result; }
java
{ "resource": "" }
q178093
TagLibraryInfoImpl.getResourceAsStream
test
private InputStream getResourceAsStream(String uri) throws JasperException { try { // see if file exists on the filesystem first String real = ctxt.getRealPath(uri); if (real == null) { return ctxt.getResourceAsStream(uri); } else { return new FileInputStream(real); } } catch (FileNotFoundException ex) { // if file not found on filesystem, get the resource through // the context return ctxt.getResourceAsStream(uri); } }
java
{ "resource": "" }
q178094
TagLibraryInfoImpl.validate
test
public ValidationMessage[] validate(PageData thePage) { TagLibraryValidator tlv = getTagLibraryValidator(); if (tlv == null) return null; String uri = getURI(); if (uri.startsWith("/")) { uri = URN_JSPTLD + uri; } ValidationMessage[] messages = tlv.validate(getPrefixString(), uri, thePage); tlv.release(); return messages; }
java
{ "resource": "" }
q178095
Mark.pushStream
test
public void pushStream(char[] inStream, int inFileid, String name, String inBaseDir, String inEncoding) { // store current state in stack includeStack.push(new IncludeState(cursor, line, col, fileid, fileName, baseDir, encoding, stream) ); // set new variables cursor = 0; line = 1; col = 1; fileid = inFileid; fileName = name; baseDir = inBaseDir; encoding = inEncoding; stream = inStream; }
java
{ "resource": "" }
q178096
XMLEncodingDetector.getEncoding
test
public static Object[] getEncoding(String fname, JarFile jarFile, JspCompilationContext ctxt, ErrorDispatcher err) throws IOException, JasperException { InputStream inStream = JspUtil.getInputStream(fname, jarFile, ctxt, err); XMLEncodingDetector detector = new XMLEncodingDetector(); Object[] ret = detector.getEncoding(inStream, err); inStream.close(); return ret; }
java
{ "resource": "" }
q178097
XMLEncodingDetector.scanXMLDecl
test
private void scanXMLDecl() throws IOException, JasperException { if (skipString("<?xml")) { fMarkupDepth++; // NOTE: special case where document starts with a PI // whose name starts with "xml" (e.g. "xmlfoo") if (XMLChar.isName(peekChar())) { fStringBuffer.clear(); fStringBuffer.append("xml"); while (XMLChar.isName(peekChar())) { fStringBuffer.append((char)scanChar()); } String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length); scanPIData(target, fString); } // standard XML declaration else { scanXMLDeclOrTextDecl(false); } } }
java
{ "resource": "" }
q178098
XMLEncodingDetector.reportFatalError
test
private void reportFatalError(String msgId, String arg) throws JasperException { err.jspError(msgId, arg); }
java
{ "resource": "" }
q178099
JspCServletContext.getRealPath
test
public String getRealPath(String path) { if (!myResourceBaseURL.getProtocol().equals("file")) return (null); if (!path.startsWith("/")) return (null); try { return (getResource(path).getFile().replace('/', File.separatorChar)); } catch (Throwable t) { return (null); } }
java
{ "resource": "" }