_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q25000
CharBuffer.clear
train
public void clear() { if (size() == 0) return; buffer = new char[buffer.length]; root.next = null; pos = 0; length = 0; curr = root; }
java
{ "resource": "" }
q25001
Ftp.actionExistsDir
train
private AFTPClient actionExistsDir() throws PageException, IOException { required("directory", directory); AFTPClient client = getClient(); boolean res = existsDir(client, directory); Struct cfftp = writeCfftp(client); cfftp.setEL(RETURN_VALUE, Caster.toBoolean(res)); cfftp.setEL(SUCCEEDED, Boolean.TRUE); sto...
java
{ "resource": "" }
q25002
Ftp.actionExistsFile
train
private AFTPClient actionExistsFile() throws PageException, IOException { required("remotefile", remotefile); AFTPClient client = getClient(); FTPFile file = existsFile(client, remotefile, true); Struct cfftp = writeCfftp(client); cfftp.setEL(RETURN_VALUE, Caster.toBoolean(file != null && file.isFile())); cfft...
java
{ "resource": "" }
q25003
Ftp.actionExists
train
private AFTPClient actionExists() throws PageException, IOException { required("item", item); AFTPClient client = getClient(); FTPFile file = existsFile(client, item, false); Struct cfftp = writeCfftp(client); cfftp.setEL(RETURN_VALUE, Caster.toBoolean(file != null)); cfftp.setEL(SUCCEEDED, Boolean.TRUE); ret...
java
{ "resource": "" }
q25004
Ftp.actionRemove
train
private AFTPClient actionRemove() throws IOException, PageException { required("item", item); AFTPClient client = getClient(); client.deleteFile(item); writeCfftp(client); return client; }
java
{ "resource": "" }
q25005
Ftp.actionRename
train
private AFTPClient actionRename() throws PageException, IOException { required("existing", existing); required("new", _new); AFTPClient client = getClient(); client.rename(existing, _new); writeCfftp(client); return client; }
java
{ "resource": "" }
q25006
Ftp.actionPutFile
train
private AFTPClient actionPutFile() throws IOException, PageException { required("remotefile", remotefile); required("localfile", localfile); AFTPClient client = getClient(); Resource local = ResourceUtil.toResourceExisting(pageContext, localfile);// new File(localfile); // if(failifexists && local.exists()) throw...
java
{ "resource": "" }
q25007
Ftp.actionGetFile
train
private AFTPClient actionGetFile() throws PageException, IOException { required("remotefile", remotefile); required("localfile", localfile); AFTPClient client = getClient(); Resource local = ResourceUtil.toResourceExistingParent(pageContext, localfile);// new File(localfile); pageContext.getConfig().getSecurityMa...
java
{ "resource": "" }
q25008
Ftp.actionGetCurrentURL
train
private AFTPClient actionGetCurrentURL() throws PageException, IOException { AFTPClient client = getClient(); String pwd = client.printWorkingDirectory(); Struct cfftp = writeCfftp(client); cfftp.setEL("returnValue", client.getPrefix() + "://" + client.getRemoteAddress().getHostName() + pwd); return client; }
java
{ "resource": "" }
q25009
Ftp.actionGetCurrentDir
train
private AFTPClient actionGetCurrentDir() throws PageException, IOException { AFTPClient client = getClient(); String pwd = client.printWorkingDirectory(); Struct cfftp = writeCfftp(client); cfftp.setEL("returnValue", pwd); return client; }
java
{ "resource": "" }
q25010
Ftp.actionChangeDir
train
private AFTPClient actionChangeDir() throws IOException, PageException { required("directory", directory); AFTPClient client = getClient(); client.changeWorkingDirectory(directory); writeCfftp(client); return client; }
java
{ "resource": "" }
q25011
Ftp.actionRemoveDir
train
private AFTPClient actionRemoveDir() throws IOException, PageException { required("directory", directory); AFTPClient client = getClient(); if (recursive) { removeRecursive(client, directory, FTPFile.DIRECTORY_TYPE); } else client.removeDirectory(directory); writeCfftp(client); return client; }
java
{ "resource": "" }
q25012
Ftp.actionCreateDir
train
private AFTPClient actionCreateDir() throws IOException, PageException { required("directory", directory); AFTPClient client = getClient(); client.makeDirectory(directory); writeCfftp(client); return client; }
java
{ "resource": "" }
q25013
Ftp.actionListDir
train
private AFTPClient actionListDir() throws PageException, IOException { required("name", name); required("directory", directory); AFTPClient client = getClient(); FTPFile[] files = client.listFiles(directory); if (files == null) files = new FTPFile[0]; pageContext.setVariable(name, toQuery(files, "ftp", director...
java
{ "resource": "" }
q25014
Ftp.actionOpen
train
private AFTPClient actionOpen() throws IOException, PageException { required("server", server); required("username", username); // required("password", password); AFTPClient client = getClient(); writeCfftp(client); return client; }
java
{ "resource": "" }
q25015
Ftp.actionClose
train
private AFTPClient actionClose() throws PageException { FTPConnection conn = _createConnection(); AFTPClient client = pool.remove(conn); Struct cfftp = writeCfftp(client); cfftp.setEL("succeeded", Caster.toBoolean(client != null)); return client; }
java
{ "resource": "" }
q25016
Ftp.writeCfftp
train
private Struct writeCfftp(AFTPClient client) throws PageException { Struct cfftp = new StructImpl(); if (result == null) pageContext.variablesScope().setEL(CFFTP, cfftp); else pageContext.setVariable(result, cfftp); if (client == null) { cfftp.setEL(SUCCEEDED, Boolean.FALSE); cfftp.setEL(ERROR_CODE, new D...
java
{ "resource": "" }
q25017
Ftp.checkCompletion
train
private boolean checkCompletion(AFTPClient client) throws ApplicationException { boolean isPositiveCompletion = client.isPositiveCompletion(); if (isPositiveCompletion) return false; if (count++ < retrycount) return true; if (stoponerror) { throw new lucee.runtime.exp.FTPException(action, client); } return ...
java
{ "resource": "" }
q25018
Ftp.getType
train
private int getType(Resource file) { if (transferMode == FTPConstant.TRANSFER_MODE_BINARY) return AFTPClient.FILE_TYPE_BINARY; else if (transferMode == FTPConstant.TRANSFER_MODE_ASCCI) return AFTPClient.FILE_TYPE_TEXT; else { String ext = ResourceUtil.getExtension(file, null); if (ext == null || ListUtil.l...
java
{ "resource": "" }
q25019
Condition.addElseIf
train
public Pair addElseIf(ExprBoolean condition, Statement body, Position start, Position end) { Pair pair; ifs.add(pair = new Pair(condition, body, start, end)); body.setParent(this); return pair; }
java
{ "resource": "" }
q25020
Condition.setElse
train
public Pair setElse(Statement body, Position start, Position end) { _else = new Pair(null, body, start, end); body.setParent(this); return _else; }
java
{ "resource": "" }
q25021
StructUtil.copy
train
public static void copy(Struct source, Struct target, boolean overwrite) { Iterator<Entry<Key, Object>> it = source.entryIterator(); Entry<Key, Object> e; while (it.hasNext()) { e = it.next(); if (overwrite || !target.containsKey(e.getKey())) target.setEL(e.getKey(), e.getValue()); } }
java
{ "resource": "" }
q25022
StructUtil.values
train
public static java.util.Collection<?> values(Struct sct) { ArrayList<Object> arr = new ArrayList<Object>(); // Key[] keys = sct.keys(); Iterator<Object> it = sct.valueIterator(); while (it.hasNext()) { arr.add(it.next()); } return arr; }
java
{ "resource": "" }
q25023
StructUtil.sizeOf
train
public static long sizeOf(Struct sct) { Iterator<Entry<Key, Object>> it = sct.entryIterator(); Entry<Key, Object> e; long size = 0; while (it.hasNext()) { e = it.next(); size += SizeOf.size(e.getKey()); size += SizeOf.size(e.getValue()); } return size; }
java
{ "resource": "" }
q25024
StructUtil.removeValue
train
public static void removeValue(Map map, Object value) { Iterator it = map.entrySet().iterator(); Map.Entry entry; while (it.hasNext()) { entry = (Entry) it.next(); if (entry.getValue() == value) it.remove(); } }
java
{ "resource": "" }
q25025
TagOutput.writeOutTypeNormal
train
private void writeOutTypeNormal(BytecodeContext bc) throws TransformerException { ParseBodyVisitor pbv = new ParseBodyVisitor(); pbv.visitBegin(bc); getBody().writeOut(bc); pbv.visitEnd(bc); }
java
{ "resource": "" }
q25026
Table.setQuery
train
public void setQuery(String query) throws PageException { this.query = Caster.toQuery(pageContext.getVariable(query)); }
java
{ "resource": "" }
q25027
Reflections.merge
train
public Reflections merge(final Reflections reflections) { if (reflections.store != null) { for (String indexName : reflections.store.keySet()) { Multimap<String, String> index = reflections.store.get(indexName); for (String key : index.keySet()) { ...
java
{ "resource": "" }
q25028
Reflections.getMethodsReturn
train
public Set<Method> getMethodsReturn(Class returnType) { return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), names(returnType)), loaders()); }
java
{ "resource": "" }
q25029
Reflections.getMethodsWithAnyParamAnnotated
train
public Set<Method> getMethodsWithAnyParamAnnotated(Class<? extends Annotation> annotation) { return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), annotation.getName()), loaders()); }
java
{ "resource": "" }
q25030
Reflections.getMethodsWithAnyParamAnnotated
train
public Set<Method> getMethodsWithAnyParamAnnotated(Annotation annotation) { return filter(getMethodsWithAnyParamAnnotated(annotation.annotationType()), withAnyParameterAnnotation(annotation)); }
java
{ "resource": "" }
q25031
Reflections.getConstructorsWithAnyParamAnnotated
train
public Set<Constructor> getConstructorsWithAnyParamAnnotated(Class<? extends Annotation> annotation) { return getConstructorsFromDescriptors(store.get(index(MethodParameterScanner.class), annotation.getName()), loaders()); }
java
{ "resource": "" }
q25032
Reflections.getConstructorsWithAnyParamAnnotated
train
public Set<Constructor> getConstructorsWithAnyParamAnnotated(Annotation annotation) { return filter(getConstructorsWithAnyParamAnnotated(annotation.annotationType()), withAnyParameterAnnotation(annotation)); }
java
{ "resource": "" }
q25033
ClasspathHelper.tryToGetValidUrl
train
static URL tryToGetValidUrl(String workingDir, String path, String filename) { try { if (new File(filename).exists()) return new File(filename).toURI().toURL(); if (new File(path + File.separator + filename).exists()) return new File(path + File.separator ...
java
{ "resource": "" }
q25034
FilterBuilder.includePackage
train
public FilterBuilder includePackage(final String... prefixes) { for (String prefix : prefixes) { add(new Include(prefix(prefix))); } return this; }
java
{ "resource": "" }
q25035
MetadataSet.getRefinedBy
train
public Optional<Metadata> getRefinedBy(Metadata meta) { return Optional.fromNullable(refines.get(meta)); }
java
{ "resource": "" }
q25036
Messages.getInstance
train
public static Messages getInstance(Locale locale, Class<?> cls) { Messages instance = null; locale = (locale == null) ? Locale.getDefault() : locale; String bundleKey = (cls==null)? BUNDLE_NAME : getBundleName(cls); String localeKey = locale.getLanguage(); if (messageTable.contains(bundleK...
java
{ "resource": "" }
q25037
AggregateVocab.of
train
public static Vocab of(Vocab... vocabs) { return new AggregateVocab(new ImmutableList.Builder<Vocab>().add(vocabs).build()); }
java
{ "resource": "" }
q25038
VocabUtil.parseProperty
train
public static Optional<Property> parseProperty(String value, Map<String, Vocab> vocabs, ValidationContext context, EPUBLocation location) { return Optional.fromNullable( Iterables.get(parseProperties(value, vocabs, false, context, location), 0, null)); }
java
{ "resource": "" }
q25039
VocabUtil.parsePropertyList
train
public static Set<Property> parsePropertyList(String value, Map<String, ? extends Vocab> vocabs, ValidationContext context, EPUBLocation location) { return parseProperties(value, vocabs, true, context, location); }
java
{ "resource": "" }
q25040
VocabUtil.parsePrefixDeclaration
train
public static Map<String, Vocab> parsePrefixDeclaration(String value, Map<String, ? extends Vocab> predefined, Map<String, ? extends Vocab> known, Set<String> forbidden, Report report, EPUBLocation location) { Map<String, Vocab> vocabs = Maps.newHashMap(predefined); Map<String, String> mappings = ...
java
{ "resource": "" }
q25041
LinkedResources.getById
train
public Optional<LinkedResource> getById(String id) { return Optional.fromNullable(resourcesById.get(id)); }
java
{ "resource": "" }
q25042
CssScanner._dashmatch
train
private void _dashmatch() throws IOException { if (debug) { checkState(reader.curChar == '|'); } builder.type = Type.DASHMATCH; builder.append("|="); reader.next(); if (debug) { checkState(reader.curChar == '='); } }
java
{ "resource": "" }
q25043
CssScanner._includes
train
private void _includes() throws IOException { if (debug) { checkState(reader.curChar == '~'); } builder.type = Type.INCLUDES; builder.append("~="); reader.next(); if (debug) { checkState(reader.curChar == '='); } }
java
{ "resource": "" }
q25044
CssScanner._prefixmatch
train
private void _prefixmatch() throws IOException { if (debug) { checkState(reader.curChar == '^'); } builder.type = Type.PREFIXMATCH; builder.append("^="); reader.next(); if (debug) { checkState(reader.curChar == '='); } }
java
{ "resource": "" }
q25045
CssScanner._comment
train
private void _comment() throws IOException, CssException { if (debug) { checkState(reader.curChar == '/' && reader.peek() == '*'); } /* * badcomment1 \/\*[^*]*\*+([^/*][^*]*\*+)* badcomment2 * \/\*[^*]*(\*+[^/*][^*]*)* comment \/\*[^*]*\*+([^/*][^*]*\*+)*\/ * ...
java
{ "resource": "" }
q25046
CssScanner._quantity
train
private void _quantity() throws IOException, CssException { if (debug) { int ch = reader.peek(); checkState(QNTSTART.matches((char) ch) || isNextEscape()); checkState(builder.getLength() > 0 && NUM.matches(builder.getLast())); } /* * Assume we have a {n...
java
{ "resource": "" }
q25047
CssScanner._urange
train
private void _urange() throws IOException, CssException { if (debug) { checkArgument((reader.curChar == 'U' || reader.curChar == 'u') && reader.peek() == '+'); } builder.type = Type.URANGE; reader.next(); // '+' List<Integer> cbuf = Lists.newArrayList(); int ...
java
{ "resource": "" }
q25048
CssScanner.append
train
private void append(CharMatcher matcher, TokenBuilder builder) throws IOException, CssException { while (true) { Mark mark = reader.mark(); int ch = reader.next(); if (ch > -1 && matcher.matches((char) ch)) { builder.append(ch); } else if (ch == '\...
java
{ "resource": "" }
q25049
CssScanner.forwardMatch
train
private boolean forwardMatch(String match, boolean ignoreCase, boolean resetOnTrue) throws IOException { Mark mark = reader.mark(); List<Integer> cbuf = Lists.newArrayList(); StringBuilder builder = new StringBuilder(); boolean result = true; boolean seenChar = false; while (true...
java
{ "resource": "" }
q25050
CssScanner.isNewLine
train
static int isNewLine(int[] chars) { checkArgument(chars.length > 1); // nl \n|\r\n|\r|\f if (chars[0] == '\r' && chars[1] == '\n') { return 2; } else if (chars[0] == '\n' || chars[0] == '\r' || chars[0] == '\f') { return 1; } return 0; }
java
{ "resource": "" }
q25051
OPFHandler.getItemById
train
public Optional<OPFItem> getItemById(String id) { return (items != null) ? items.getItemById(id) : Optional.<OPFItem> absent(); }
java
{ "resource": "" }
q25052
OPFHandler.getItemByPath
train
public Optional<OPFItem> getItemByPath(String path) { return (items != null) ? items.getItemByPath(path) : Optional.<OPFItem> absent(); }
java
{ "resource": "" }
q25053
OPFHandler.buildItems
train
private void buildItems() { Preconditions.checkState(items == null); items = OPFItems.build(itemBuilders.values(), spineIDs); for (OPFItem item : items.getItems()) { reportItem(item); } }
java
{ "resource": "" }
q25054
OPFHandler.reportItem
train
protected void reportItem(OPFItem item) { if (item.isInSpine()) { report.info(item.getPath(), FeatureEnum.IS_SPINEITEM, "true"); report.info(item.getPath(), FeatureEnum.IS_LINEAR, String.valueOf(item.isLinear())); } if (item.isNcx()) { report.info(item.getPath(), FeatureEnum.HAS_...
java
{ "resource": "" }
q25055
CssEscape.render
train
int render(TokenBuilder builder, CharMatcher asLiteral) { char ch = (char) character; if (asLiteral.matches(ch)) { builder.append(ch); } else { //TODO could normalize space end chars builder.append(sequence); } return sequence.length() - 1; }
java
{ "resource": "" }
q25056
CssParser.parseStyleAttribute
train
public void parseStyleAttribute(final Reader reader, String systemID, final CssErrorHandler err, final CssContentHandler doc) throws IOException, CssException { CssTokenIterator iter = scan(reader, systemID, err); doc.startDocument(); while (iter.hasNext()) { CssToken tk = iter.next(...
java
{ "resource": "" }
q25057
CssParser.handleRuleSet
train
private void handleRuleSet(CssToken start, final CssTokenIterator iter, final CssContentHandler doc, CssErrorHandler err) throws CssException { char errChar = '{'; try { List<CssSelector> selectors = handleSelectors(start, iter, err); errChar = '}'; if (selectors == null) ...
java
{ "resource": "" }
q25058
CssParser.handleDeclarationBlock
train
private void handleDeclarationBlock(CssToken start, CssTokenIterator iter, final CssContentHandler doc, CssErrorHandler err) throws CssException { while (true) { if (MATCH_CLOSEBRACE.apply(start)) { return; } CssDeclaration decl = handleDeclaration(start, iter, doc...
java
{ "resource": "" }
q25059
CssParser.handleDeclaration
train
private CssDeclaration handleDeclaration(CssToken name, CssTokenIterator iter, CssContentHandler doc, CssErrorHandler err, boolean isStyleAttribute) throws CssException { if (name.type != CssToken.Type.IDENT) { err.error(new CssGrammarException(GRAMMAR_EXPECTING_TOKEN, name.location, ...
java
{ "resource": "" }
q25060
CssParser.handlePropertyValue
train
private boolean handlePropertyValue(CssDeclaration declaration, CssToken start, CssTokenIterator iter, boolean isStyleAttribute) { // we dont worry about EOF here, throw to caller while (true) { if (start.type == CssToken.Type.IMPORTANT) { declaration.important = true; } ...
java
{ "resource": "" }
q25061
CssParser.handleAtRuleParam
train
private CssConstruct handleAtRuleParam(CssToken start, CssTokenIterator iter, CssContentHandler doc, CssErrorHandler err) { return CssConstructFactory.create(start, iter, MATCH_SEMI_OPENBRACE, ContextRestrictions.ATRULE_PARAM); }
java
{ "resource": "" }
q25062
DateParser.checkValueAndNext
train
private boolean checkValueAndNext(StringTokenizer st, String token) throws InvalidDateException { if (!st.hasMoreTokens()) { return false; } String t = st.nextToken(); if (!t.equals(token)) { throw new InvalidDateException("Unexpected: " + t); } if (!st.hasMoreTokens(...
java
{ "resource": "" }
q25063
OPSHandler.checkDependentCondition
train
protected void checkDependentCondition(MessageId id, boolean condition1, boolean condition2, EPUBLocation location) { if (condition1 && !condition2) { report.message(id, location); } }
java
{ "resource": "" }
q25064
EnumVocab.getName
train
public String getName(P property) { Preconditions.checkNotNull(property); return converter.convert(property); }
java
{ "resource": "" }
q25065
EnumVocab.getNames
train
public Collection<String> getNames(Collection<P> properties) { Preconditions.checkNotNull(properties); return Collections2.transform(properties, new Function<P, String>() { @Override public String apply(P property) { return converter.convert(property); } }); }
java
{ "resource": "" }
q25066
LocalizedMessages.getInstance
train
public static LocalizedMessages getInstance(Locale locale) { LocalizedMessages instance = null; if (locale == null) { locale = Locale.getDefault(); } String localeKey = locale.getLanguage(); if (localizedMessages.containsKey(localeKey)) { instance = localizedMessages.get(loca...
java
{ "resource": "" }
q25067
LocalizedMessages.getMessage
train
public Message getMessage(MessageId id) { // Performance note: this method uses a lazy initialization pattern. When // a MessageId is first requested, we fetch the data from the ResourceBundle // and create a new Message object, which is then cached. On the next // request, we'll use the cached versi...
java
{ "resource": "" }
q25068
LocalizedMessages.getSuggestion
train
public String getSuggestion(MessageId id, String key) { String messageKey = id.name() + "_SUG." + key; String messageDefaultKey = id.name() + "_SUG.default"; return bundle.containsKey(messageKey) ? getStringFromBundle(messageKey) : (bundle.containsKey(messageDefaultKey) ? getStringFromBundle(messa...
java
{ "resource": "" }
q25069
OPFItems.getItemById
train
public Optional<OPFItem> getItemById(String id) { return Optional.fromNullable(itemsById.get(id)); }
java
{ "resource": "" }
q25070
OPFItems.getItemByPath
train
public Optional<OPFItem> getItemByPath(String path) { return Optional.fromNullable(itemsByPath.get(path)); }
java
{ "resource": "" }
q25071
CssReader.next
train
int next() throws IOException { prevChar = curChar; checkState(prevChar > -1); if (pos < buf.length) { curChar = buf[pos++]; } else { curChar = in.read(); } offset++; /* * Handle line and col * lf=\n, cr=\r */ if (curChar == '\r' ||...
java
{ "resource": "" }
q25072
CssReader.peek
train
int peek() throws IOException { Mark m = mark(); int ch = next(); unread(ch, m); return ch; }
java
{ "resource": "" }
q25073
CssReader.peek
train
int[] peek(int n) throws IOException { int[] buf = new int[n]; Mark m = mark(); boolean seenEOF = false; for (int i = 0; i < buf.length; i++) { if (!seenEOF) { buf[i] = next(); } else { buf[i] = -1; } if (buf[i] == -1) { ...
java
{ "resource": "" }
q25074
CssReader.at
train
int at(int n) throws IOException { Mark mark = mark(); List<Integer> cbuf = Lists.newArrayList(); for (int i = 0; i < n; i++) { cbuf.add(next()); if (curChar == -1) { break; } } unread(cbuf, mark); return cbuf.get(cbuf.size() - 1); }
java
{ "resource": "" }
q25075
CssReader.forward
train
CssReader forward(CharMatcher matcher) throws IOException { while (true) { Mark mark = mark(); next(); //TODO escape awareness if (curChar == -1 || (matcher.matches((char) curChar) && prevChar != '\\')) { unread(curChar, mark); break; } } retur...
java
{ "resource": "" }
q25076
CssReader.forward
train
CssReader forward(int n) throws IOException { for (int i = 0; i < n; i++) { //TODO escape awareness Mark mark = mark(); next(); if (curChar == -1) { unread(curChar, mark); break; } } return this; }
java
{ "resource": "" }
q25077
DTBookHandler.checkURI
train
private URI checkURI(String uri) { try { return new URI(Preconditions.checkNotNull(uri).trim()); } catch (URISyntaxException e) { parser.getReport().message(MessageId.RSC_020, parser.getLocation(), uri); return null; } }
java
{ "resource": "" }
q25078
XmlReportAbstract.correctToUtf8
train
protected static String correctToUtf8(String inputString) { final StringBuilder result = new StringBuilder(inputString.length()); final StringCharacterIterator it = new StringCharacterIterator(inputString); char ch = it.current(); boolean modified = false; while (ch != CharacterI...
java
{ "resource": "" }
q25079
XmlReportAbstract.fromTime
train
protected static String fromTime(final long time) { Date date = new Date(time); // Waiting for Java 7: SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); String formatted = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(date); return formatted.substring(0, 22) + ":" + formatted.substring(22); }
java
{ "resource": "" }
q25080
ResourceCollections.getByRole
train
public List<ResourceCollection> getByRole(Roles role) { return role == null ? ImmutableList.<ResourceCollection> of() : getByRole(role.toString()); }
java
{ "resource": "" }
q25081
Property.newFrom
train
public static Property newFrom(String name, String base, String prefix) { return new Property(name, base, prefix, null); }
java
{ "resource": "" }
q25082
RaspividDevice.validateParameters
train
@Override protected void validateParameters() { super.validateParameters(); // override some arguments parameters.put(OPT_NOPREVIEW, ""); parameters.put(OPT_RAW, "-");// must be this, then image will be in console! parameters.put(OPT_RAW_FORMAT, "rgb");// only support rgb parameters.put(OPT_CAMSELECT, Inte...
java
{ "resource": "" }
q25083
Webcam.close
train
public boolean close() { if (open.compareAndSet(true, false)) { LOG.debug("Closing webcam {}", getName()); assert lock != null; // close webcam WebcamCloseTask task = new WebcamCloseTask(driver, device); try { task.close(); } catch (InterruptedException e) { open.set(true)...
java
{ "resource": "" }
q25084
Webcam.dispose
train
protected void dispose() { assert disposed != null; assert open != null; assert driver != null; assert device != null; assert listeners != null; if (!disposed.compareAndSet(false, true)) { return; } open.set(false); LOG.info("Disposing webcam {}", getName()); WebcamDisposeTas...
java
{ "resource": "" }
q25085
Webcam.transform
train
protected BufferedImage transform(BufferedImage image) { if (image != null) { WebcamImageTransformer tr = getImageTransformer(); if (tr != null) { return tr.transform(image); } } return image; }
java
{ "resource": "" }
q25086
Webcam.setCustomViewSizes
train
public void setCustomViewSizes(Dimension... sizes) { assert customSizes != null; if (sizes == null) { customSizes.clear(); return; } customSizes = Arrays.asList(sizes); }
java
{ "resource": "" }
q25087
Webcam.setViewSize
train
public void setViewSize(Dimension size) { if (size == null) { throw new IllegalArgumentException("Resolution cannot be null!"); } if (open.get()) { throw new IllegalStateException("Cannot change resolution when webcam is open, please close it first"); } // check if new resolution is the sam...
java
{ "resource": "" }
q25088
Webcam.setParameters
train
public void setParameters(Map<String, ?> parameters) { WebcamDevice device = getDevice(); if (device instanceof Configurable) { ((Configurable) device).setParameters(parameters); } else { LOG.debug("Webcam device {} is not configurable", device); } }
java
{ "resource": "" }
q25089
Webcam.isReady
train
private boolean isReady() { assert disposed != null; assert open != null; if (disposed.get()) { LOG.warn("Cannot get image, webcam has been already disposed"); return false; } if (!open.get()) { if (autoOpen) { open(); } else { return false; } } return true; ...
java
{ "resource": "" }
q25090
Webcam.getWebcams
train
public static List<Webcam> getWebcams() throws WebcamException { // timeout exception below will never be caught since user would have to // wait around three hundreds billion years for it to occur try { return getWebcams(Long.MAX_VALUE); } catch (TimeoutException e) { throw new RuntimeException...
java
{ "resource": "" }
q25091
Webcam.getWebcams
train
public static List<Webcam> getWebcams(long timeout) throws TimeoutException, WebcamException { if (timeout < 0) { throw new IllegalArgumentException(String.format("Timeout cannot be negative (%d)", timeout)); } return getWebcams(timeout, TimeUnit.MILLISECONDS); }
java
{ "resource": "" }
q25092
Webcam.getWebcams
train
public static synchronized List<Webcam> getWebcams(long timeout, TimeUnit tunit) throws TimeoutException, WebcamException { if (timeout < 0) { throw new IllegalArgumentException(String.format("Timeout cannot be negative (%d)", timeout)); } if (tunit == null) { throw new IllegalArgumentException("Time...
java
{ "resource": "" }
q25093
Webcam.addWebcamListener
train
public boolean addWebcamListener(WebcamListener l) { if (l == null) { throw new IllegalArgumentException("Webcam listener cannot be null!"); } assert listeners != null; return listeners.add(l); }
java
{ "resource": "" }
q25094
Webcam.registerDriver
train
public static void registerDriver(Class<? extends WebcamDriver> clazz) { if (clazz == null) { throw new IllegalArgumentException("Webcam driver class to register cannot be null!"); } DRIVERS_CLASS_LIST.add(clazz); registerDriver(clazz.getCanonicalName()); }
java
{ "resource": "" }
q25095
V4l4jDevice.getVideoDevice
train
private static VideoDevice getVideoDevice(File file) { LOG.debug("Creating V4L4J device from file {}", file); try { return new VideoDevice(file.getAbsolutePath()); } catch (V4L4JException e) { throw new WebcamException("Cannot instantiate V4L4J device from " + file, e); } }
java
{ "resource": "" }
q25096
VlcjDriver.initialize
train
protected static void initialize(boolean load) { if (load && initialized.compareAndSet(false, true)) { boolean nativeFound = getNativeDiscovery().discover(); if (!nativeFound) { throw new IllegalStateException("The libvlc native library has not been found"); } // Native.loadLibrary(RuntimeUtil.g...
java
{ "resource": "" }
q25097
IPCDevice.setParameters
train
@Override public void setParameters(Map<String, ?> map) { if (isOpen) { throw new UnsupportedOperationException(MSG_CANNOT_CHANGE_PROP); } for (Entry<String, ?> entry : map.entrySet()) { if (this.driver.getOptions().hasOption(entry.getKey())) { String longKey = this.driver.getOptions().getOption(entry...
java
{ "resource": "" }
q25098
WebcamUtils.getImageByteBuffer
train
public static final ByteBuffer getImageByteBuffer(Webcam webcam, String format) { return ByteBuffer.wrap(getImageBytes(webcam, format)); }
java
{ "resource": "" }
q25099
WebcamUtils.loadRB
train
public static final ResourceBundle loadRB(Class<?> clazz, Locale locale) { String pkg = WebcamUtils.class.getPackage().getName().replaceAll("\\.", "/"); return PropertyResourceBundle.getBundle(String.format("%s/i18n/%s", pkg, clazz.getSimpleName())); }
java
{ "resource": "" }