_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q169200 | OpenTsdbMetric.formatTags | validation | public static String formatTags(final Map<String, String> tagMap) {
StringBuilder stringBuilder = new StringBuilder();
String delimeter = "";
for (Map.Entry<String, String> tag : tagMap.entrySet()) {
stringBuilder.append(delimeter)
.append(sanitize(tag.getKey()))
.append("=")
.append(sanitize(tag.getValue()));
delimeter = " ";
}
return stringBuilder.toString();
} | java | {
"resource": ""
} |
q169201 | OpenTsdbMetric.fixEncodedTagsInNameAfterPrefix | validation | public static String fixEncodedTagsInNameAfterPrefix(final String name) {
if (name == null)
return name;
int tagStart = name.indexOf("TAG(");
if (tagStart == -1)
return name; // no tags in this name
if (tagStart == 0)
return name; // tag string is already correct
// extract the "TAG(...)" string from the middle of the name and put it at the front.
int tagEnd = name.lastIndexOf(')');
if (tagEnd == -1) {
throw new IllegalArgumentException("Tag definition missing closing parenthesis for metric '" + name + "'");
}
String tagString = name.substring(tagStart, tagEnd+1);
return tagString + name.substring(0, tagStart) + name.substring(tagEnd+1);
} | java | {
"resource": ""
} |
q169202 | OpenTsdbMetric.named | validation | public static Builder named(String name) {
/*
A name can contain either a pure metric name, or a string returned by encodeTagsInName().
If it's the latter, it looks like "TAG(tag1=value1 tag2=value2)metricname".
*/
if (!hasEncodedTagInName(name)) {
return new Builder(name);
}
// parse out the tags
int tagEnd = name.lastIndexOf(')');
if (tagEnd == -1) {
throw new IllegalArgumentException("Tag definition missing closing parenthesis for metric '" + name + "'");
}
String tagString = name.substring(4, tagEnd);
name = name.substring(tagEnd+1);
return new Builder(name).withTags(parseTags(tagString));
} | java | {
"resource": ""
} |
q169203 | OpenTsdbMetric.toTelnetPutString | validation | public String toTelnetPutString() {
String tagString = formatTags(tags);
return String.format("put %s %d %s %s%n", metric, timestamp, value, tagString);
} | java | {
"resource": ""
} |
q169204 | Domain.toHumanString | validation | @Override
public String toHumanString() {
if (unicode) {
return domain;
}
final IDNA.Info idnaInfo = new IDNA.Info();
final StringBuilder idnaOutput = new StringBuilder();
IDNA.getUTS46Instance(IDNA.DEFAULT).nameToUnicode(domain, idnaOutput, idnaInfo);
return idnaOutput.toString();
} | java | {
"resource": ""
} |
q169205 | URLUtils.percentDecode | validation | public static String percentDecode(final String input) {
if (input.isEmpty()) {
return input;
}
try {
final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
int idx = 0;
while (idx < input.length()) {
boolean isEOF = idx >= input.length();
int c = (isEOF)? 0x00 : input.codePointAt(idx);
while (!isEOF && c != '%') {
if (c <= 0x7F) { // String.getBytes is slow, so do not perform encoding
// if not needed
bytes.write((byte) c);
idx++;
} else {
bytes.write(new String(Character.toChars(c)).getBytes(UTF_8));
idx += Character.charCount(c);
}
isEOF = idx >= input.length();
c = (isEOF)? 0x00 : input.codePointAt(idx);
}
if (c == '%' && (input.length() <= idx + 2 ||
!isASCIIHexDigit(input.charAt(idx + 1)) ||
!isASCIIHexDigit(input.charAt(idx + 2)))) {
if (c <= 0x7F) { // String.getBytes is slow, so do not perform encoding
// if not needed
bytes.write((byte) c);
idx++;
} else {
bytes.write(new String(Character.toChars(c)).getBytes(UTF_8));
idx += Character.charCount(c);
}
} else {
while (c == '%' && input.length() > idx + 2 &&
isASCIIHexDigit(input.charAt(idx + 1)) &&
isASCIIHexDigit(input.charAt(idx + 2))) {
bytes.write(hexToInt(input.charAt(idx + 1), input.charAt(idx + 2)));
idx += 3;
c = (input.length() <= idx)? 0x00 : input.codePointAt(idx);
}
}
}
return new String(bytes.toByteArray(), UTF_8);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
} | java | {
"resource": ""
} |
q169206 | URL.queryParameter | validation | public String queryParameter(final String name) {
if (name == null) {
throw new NullPointerException("name is null");
}
if (query == null || query.isEmpty()) {
return null;
}
int start = 0;
do {
final int nextAmpersand = query.indexOf('&', start);
final int end = (nextAmpersand == -1)? query.length() : nextAmpersand;
int nextEquals = query.indexOf('=', start);
if (nextEquals == -1 || nextEquals > end) {
nextEquals = end;
}
final int thisNameLength = nextEquals - start;
final int thisValueLength = end - nextEquals;
if (thisNameLength == name.length() && query.regionMatches(start, name, 0, name.length())) {
if (thisValueLength == 0) {
return "";
}
return query.substring(nextEquals + 1, end);
}
if (nextAmpersand == -1) {
break;
}
start = nextAmpersand + 1;
} while (true);
return null;
} | java | {
"resource": ""
} |
q169207 | URL.queryParameters | validation | public List<String> queryParameters(final String name) {
if (name == null) {
throw new NullPointerException("name is null");
}
if (query == null || query.isEmpty()) {
return null;
}
int start = 0;
final List<String> result = new ArrayList<String>();
do {
final int nextAmpersand = query.indexOf('&', start);
final int end = (nextAmpersand == -1) ? query.length() : nextAmpersand;
int nextEquals = query.indexOf('=', start);
if (nextEquals == -1 || nextEquals > end) {
nextEquals = end;
}
final int thisNameLength = nextEquals - start;
final int thisValueLength = end - nextEquals;
if (thisNameLength == name.length() && query.regionMatches(start, name, 0, name.length())) {
if (thisValueLength == 0) {
result.add("");
} else {
result.add(query.substring(nextEquals + 1, end));
}
}
if (nextAmpersand == -1) {
break;
}
start = nextAmpersand + 1;
} while (true);
return result;
} | java | {
"resource": ""
} |
q169208 | URL.relativize | validation | public String relativize(final URL url) {
if (this.isOpaque() || url.isOpaque()) {
return url.toString();
}
if (!this.scheme().equals(url.scheme())) {
return url.toString();
}
if (this.authority() == null ^ url.authority() == null) {
return url.toString();
}
if (this.authority() != null && !this.authority().equals(url.authority())) {
return url.toString();
}
String prefixPath = (this.path().endsWith("/"))? this.path : this.path() + "/";
if (!url.path().startsWith(prefixPath) && !this.path().equals(url.path())) {
return url.toString();
}
StringBuilder output = new StringBuilder();
if (!this.path().equals(url.path())) {
output.append(url.path().replaceFirst(prefixPath, ""));
}
if (url.query() != null) {
output.append('?').append(url.query());
}
if (url.fragment() != null) {
output.append('#').append(url.fragment());
}
return output.toString();
} | java | {
"resource": ""
} |
q169209 | URL.buildHierarchical | validation | public static URL buildHierarchical(final String scheme, final String host) throws GalimatiasParseException {
if (!URLUtils.isRelativeScheme(scheme)) {
throw new GalimatiasParseException("Scheme is not relative: " + scheme);
}
return new URLParser(scheme + "://" + host).parse();
} | java | {
"resource": ""
} |
q169210 | URL.buildOpaque | validation | public static URL buildOpaque(final String scheme) throws GalimatiasParseException {
if (URLUtils.isRelativeScheme(scheme)) {
throw new GalimatiasParseException("Scheme is relative: " + scheme);
}
return new URLParser(scheme + ":").parse();
} | java | {
"resource": ""
} |
q169211 | URL.toHumanString | validation | public String toHumanString() {
final StringBuilder output = new StringBuilder();
output.append(scheme).append(':');
if (isHierarchical) {
output.append("//");
final String userInfo = userInfo();
if (!userInfo.isEmpty()) {
output.append(URLUtils.percentDecode(userInfo)).append('@');
}
if (host != null) {
if (host instanceof IPv6Address) {
output.append(host.toHostString());
} else {
output.append(host.toHumanString());
}
}
if (port != -1) {
output.append(':').append(port);
}
if (path != null) {
output.append(URLUtils.percentDecode(path));
}
} else {
output.append(URLUtils.percentDecode(schemeData));
}
if (query != null) {
output.append('?').append(URLUtils.percentDecode(query));
}
if (fragment != null) {
output.append('#').append(URLUtils.percentDecode(fragment));
}
return output.toString();
} | java | {
"resource": ""
} |
q169212 | SqlTemplate.queryStreamWithOrdinalParams | validation | private <T, U> U queryStreamWithOrdinalParams(
String sql,
PreparedStatementSetter pss,
RowMapper<T> mapper,
Function<? super Stream<T>, U> handleStream) {
SQLExceptionTranslator excTranslator = jdbcTemplate.getExceptionTranslator();
ResultSetExtractor<U> extractor
= new StreamResultSetExtractor(sql, mapper, handleStream, excTranslator);
return jdbcTemplate.query(sql, pss, extractor);
} | java | {
"resource": ""
} |
q169213 | SqlTemplate.queryStreamWithNamedParams | validation | private <T, U> U queryStreamWithNamedParams(
String sql,
SqlParameterSource sps,
RowMapper<T> mapper,
Function<? super Stream<T>, U> handleStream) {
SQLExceptionTranslator excTranslator = jdbcTemplate.getExceptionTranslator();
ResultSetExtractor<U> extractor
= new StreamResultSetExtractor(sql, mapper, handleStream, excTranslator);
return namedJdbcTemplate.query(sql, sps, extractor);
} | java | {
"resource": ""
} |
q169214 | BeanFields.get | validation | public static Field[] get(Class<?> clazz) {
Field[] fields = CACHED_FIELDS.get(clazz);
if (fields == null) {
fields = clazz.getFields();
CACHED_FIELDS.putIfAbsent(clazz, fields);
}
return fields;
} | java | {
"resource": ""
} |
q169215 | ResultSetIterator.fetchRow | validation | private Optional<T> fetchRow() {
if (this.row != null) {
// already fetched
return Optional.of(this.row);
}
this.hasReachedEos = hasReachedEos || ! wrapSqlException(() -> rs.next());
if (this.hasReachedEos) {
return Optional.empty();
}
this.row = wrapSqlException(() -> mapper.mapRow(rs, 1));
return Optional.ofNullable(this.row);
} | java | {
"resource": ""
} |
q169216 | Jsr310JdbcUtils.getAsLocalDateTime | validation | protected static LocalDateTime getAsLocalDateTime(ResultSet rs, int index) throws SQLException {
Timestamp timestamp = rs.getTimestamp(index);
if (timestamp != null) {
return timestamp.toLocalDateTime();
}
return null;
} | java | {
"resource": ""
} |
q169217 | Jsr310JdbcUtils.getAsLocalDate | validation | protected static LocalDate getAsLocalDate(ResultSet rs, int index) throws SQLException {
Date date = rs.getDate(index);
if (date != null) {
return date.toLocalDate();
}
return null;
} | java | {
"resource": ""
} |
q169218 | Jsr310JdbcUtils.getAsLocalTime | validation | protected static LocalTime getAsLocalTime(ResultSet rs, int index) throws SQLException {
Time time = rs.getTime(index);
if (time != null) {
return time.toLocalTime();
}
return null;
} | java | {
"resource": ""
} |
q169219 | Jsr310JdbcUtils.getAsZonedDateTime | validation | protected static ZonedDateTime getAsZonedDateTime(ResultSet rs, int index, ZoneId zoneId) throws SQLException {
Timestamp timestamp = rs.getTimestamp(index);
if (timestamp != null) {
return timestamp.toLocalDateTime().atZone(zoneId);
}
return null;
} | java | {
"resource": ""
} |
q169220 | Jsr310JdbcUtils.getAsOffsetDateTime | validation | protected static OffsetDateTime getAsOffsetDateTime(ResultSet rs, int index, ZoneId zoneId) throws SQLException {
Timestamp timestamp = rs.getTimestamp(index);
if (timestamp != null) {
return timestamp.toLocalDateTime().atZone(zoneId).toOffsetDateTime();
}
return null;
} | java | {
"resource": ""
} |
q169221 | Jsr310JdbcUtils.getAsOffsetTime | validation | protected static OffsetTime getAsOffsetTime(ResultSet rs, int index, ZoneId zoneId) throws SQLException {
Time time = rs.getTime(index);
if (time != null) {
return time.toLocalTime().atOffset(zoneId.getRules().getOffset(Instant.now()));
}
return null;
} | java | {
"resource": ""
} |
q169222 | BeanMapper.getColumnValue | validation | protected Object getColumnValue(ResultSet rs, int index, Class<?> requiredType) throws SQLException {
return Jsr310JdbcUtils.getResultSetValue(rs, index, requiredType, zoneId);
} | java | {
"resource": ""
} |
q169223 | CdnPathBuilder.crop | validation | public CdnPathBuilder crop(int width, int height) {
dimensionsGuard(width, height);
sb.append("/-/crop/")
.append(width)
.append("x")
.append(height);
return this;
} | java | {
"resource": ""
} |
q169224 | CdnPathBuilder.cropCenter | validation | public CdnPathBuilder cropCenter(int width, int height) {
dimensionsGuard(width, height);
sb.append("/-/crop/")
.append(width)
.append("x")
.append(height)
.append("/center");
return this;
} | java | {
"resource": ""
} |
q169225 | CdnPathBuilder.cropColor | validation | public CdnPathBuilder cropColor(int width, int height, Color color) {
dimensionsGuard(width, height);
sb.append("/-/crop/")
.append(width)
.append("x")
.append(height)
.append("/")
.append(colorToHex(color));
return this;
} | java | {
"resource": ""
} |
q169226 | CdnPathBuilder.resizeWidth | validation | public CdnPathBuilder resizeWidth(int width) {
dimensionGuard(width);
sb.append("/-/resize/")
.append(width)
.append("x");
return this;
} | java | {
"resource": ""
} |
q169227 | CdnPathBuilder.resize | validation | public CdnPathBuilder resize(int width, int height) {
dimensionsGuard(width, height);
sb.append("/-/resize/")
.append(width)
.append("x")
.append(height);
return this;
} | java | {
"resource": ""
} |
q169228 | CdnPathBuilder.scaleCrop | validation | public CdnPathBuilder scaleCrop(int width, int height) {
dimensionsGuard(width, height);
sb.append("/-/scale_crop/")
.append(width)
.append("x")
.append(height);
return this;
} | java | {
"resource": ""
} |
q169229 | CdnPathBuilder.scaleCropCenter | validation | public CdnPathBuilder scaleCropCenter(int width, int height) {
dimensionsGuard(width, height);
sb.append("/-/scale_crop/")
.append(width)
.append("x")
.append(height)
.append("/center");
return this;
} | java | {
"resource": ""
} |
q169230 | CdnPathBuilder.blur | validation | public CdnPathBuilder blur(int strength) {
if (strength < 0 || strength > 5000) {
strength = 10;
}
sb.append("/-/blur/")
.append(strength);
return this;
} | java | {
"resource": ""
} |
q169231 | CdnPathBuilder.sharp | validation | public CdnPathBuilder sharp(int strength) {
if (strength < 0 || strength > 20) {
strength = 5;
}
sb.append("/-/sharp/")
.append(strength);
return this;
} | java | {
"resource": ""
} |
q169232 | CdnPathBuilder.preview | validation | public CdnPathBuilder preview(int width, int height) {
dimensionsGuard(width, height);
sb.append("/-/preview/")
.append(width)
.append("x")
.append(height);
return this;
} | java | {
"resource": ""
} |
q169233 | Client.getProject | validation | public Project getProject() {
URI url = Urls.apiProject();
RequestHelper requestHelper = getRequestHelper();
ProjectData projectData = requestHelper.executeQuery(new HttpGet(url), true, ProjectData.class);
return new Project(this, projectData);
} | java | {
"resource": ""
} |
q169234 | Client.getFile | validation | public File getFile(String fileId) {
URI url = Urls.apiFile(fileId);
RequestHelper requestHelper = getRequestHelper();
FileData fileData = requestHelper.executeQuery(new HttpGet(url), true, FileData.class);
return new File(this, fileData);
} | java | {
"resource": ""
} |
q169235 | Client.deleteFile | validation | public void deleteFile(String fileId) {
URI url = Urls.apiFile(fileId);
RequestHelper requestHelper = getRequestHelper();
requestHelper.executeCommand(new HttpDelete(url), true);
} | java | {
"resource": ""
} |
q169236 | Client.saveFile | validation | public void saveFile(String fileId) {
URI url = Urls.apiFileStorage(fileId);
RequestHelper requestHelper = getRequestHelper();
requestHelper.executeCommand(new HttpPost(url), true);
} | java | {
"resource": ""
} |
q169237 | RequestHelper.executeCommand | validation | public HttpResponse executeCommand(HttpUriRequest request, boolean apiHeaders) {
if (apiHeaders) {
setApiHeaders(request);
}
try {
CloseableHttpResponse response = client.getHttpClient().execute(request);
try {
checkResponseStatus(response);
return response;
} finally {
response.close();
}
} catch (IOException e) {
throw new UploadcareNetworkException(e);
}
} | java | {
"resource": ""
} |
q169238 | RequestHelper.checkResponseStatus | validation | private void checkResponseStatus(HttpResponse response) throws IOException {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= 200 && statusCode < 300) {
return;
} else if (statusCode == 401 || statusCode == 403) {
throw new UploadcareAuthenticationException(
streamToString(response.getEntity().getContent()));
} else if (statusCode == 400 || statusCode == 404) {
throw new UploadcareInvalidRequestException(
streamToString(response.getEntity().getContent()));
} else {
throw new UploadcareApiException(
"Unknown exception during an API call, response:" + streamToString(
response.getEntity().getContent()));
}
} | java | {
"resource": ""
} |
q169239 | Urls.uploadFromUrl | validation | public static URI uploadFromUrl(String sourceUrl, String pubKey, String store) {
URIBuilder builder = new URIBuilder(URI.create(UPLOAD_BASE));
builder.setPath("/from_url/")
.setParameter("source_url", sourceUrl)
.setParameter("pub_key", pubKey)
.setParameter("store", store);
return trustedBuild(builder);
} | java | {
"resource": ""
} |
q169240 | InjectingActionBarActivity.inject | validation | @Override
public void inject(Object target) {
checkState(mObjectGraph != null, "object graph must be assigned prior to calling inject");
mObjectGraph.inject(target);
} | java | {
"resource": ""
} |
q169241 | AlertDialog.newBuilder | validation | public static Builder newBuilder(Context context, int themeResId) {
if (Build.VERSION.SDK_INT >= 21) {
return new APi21Builder(context, themeResId);
}
return new Api20Builder(context, themeResId);
} | java | {
"resource": ""
} |
q169242 | ReflectiveClassLoader.findClass | validation | @Nullable
public Class<?> findClass(final String className)
{
Objects.requireNonNull(className);
try {
return (Class<?>) findClass.invoke(loader, className);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new ParserTransformException("unable to find class by name ("
+ className + ')', e);
}
} | java | {
"resource": ""
} |
q169243 | ReflectiveClassLoader.loadClass | validation | public Class<?> loadClass(final String className, final byte[] bytecode)
{
Objects.requireNonNull(className);
Objects.requireNonNull(bytecode);
try {
return (Class<?>) loadClass.invoke(loader, className, bytecode, 0,
bytecode.length);
} catch (InvocationTargetException | IllegalAccessException e) {
throw new ParserTransformException("unable to load class by name",
e);
}
} | java | {
"resource": ""
} |
q169244 | TrieNode.doSearch | validation | private int doSearch(final CharBuffer buffer, final int matchedLength,
final int currentLength, final boolean ignoreCase)
{
/*
* Try and see if there is a possible match here; there is if "fullword"
* is true, in this case the next "matchedLength" argument to a possible
* child call will be the current length.
*/
final int nextLength = fullWord ? currentLength : matchedLength;
/*
* If there is nothing left in the buffer, we have a match.
*/
if (!buffer.hasRemaining())
return nextLength;
/*
* OK, there is at least one character remaining, so pick it up and see
* whether it is in the list of our children...
*/
char c = buffer.get();
int index = Arrays.binarySearch(nextChars, c);
if (index < 0 && ignoreCase) {
final boolean isUpper = Character.isUpperCase(c);
final boolean isLower = Character.isLowerCase(c);
if (isUpper != isLower) {
c = isUpper ? Character.toLowerCase(c)
: Character.toUpperCase(c);
index = Arrays.binarySearch(nextChars, c);
}
}
/*
* If not, we return the last good match; if yes, we call this same
* method on the matching child node with the (possibly new) matched
* length as an argument and a depth increased by 1.
*/
if (index < 0)
return nextLength;
return nextNodes[index].doSearch(buffer, nextLength, currentLength + 1,
ignoreCase);
} | java | {
"resource": ""
} |
q169245 | TrieBuilder.addWord | validation | public TrieBuilder addWord(@Nonnull final String word)
{
Objects.requireNonNull(word);
final int length = word.length();
if (length == 0)
throw new IllegalArgumentException("a trie cannot have empty "
+ "strings (use EMPTY instead)");
nrWords++;
maxLength = Math.max(maxLength, length);
nodeBuilder.addWord(word);
return this;
} | java | {
"resource": ""
} |
q169246 | StringBuilderVar.append | validation | public boolean append(final char c)
{
if (get() == null)
return set(new StringBuilder().append(c));
get().append(c);
return true;
} | java | {
"resource": ""
} |
q169247 | Reference.getAndSet | validation | public final T getAndSet(final T value)
{
final T ret = this.value;
this.value = value;
return ret;
} | java | {
"resource": ""
} |
q169248 | AsmUtils.isAssignableTo | validation | public static boolean isAssignableTo(final String classInternalName,
final Class<?> type)
{
Objects.requireNonNull(classInternalName, "classInternalName");
Objects.requireNonNull(type, "type");
final Class<?> c = CACHE.loadClass(classInternalName);
//final Class<?> c = getClassForInternalName(classInternalName);
return type.isAssignableFrom(c);
} | java | {
"resource": ""
} |
q169249 | TracingListener.copyParseInfo | validation | private void copyParseInfo(final FileSystem zipfs)
throws IOException
{
final Path path = zipfs.getPath(INFO_PATH);
try (
final BufferedWriter writer = Files.newBufferedWriter(path, UTF_8);
) {
sb.setLength(0);
sb.append(startTime).append(';')
.append(prematchIndices.size()).append(';')
.append(nextMatcherId).append(';')
.append(nrLines).append(';')
.append(nrChars).append(';')
.append(nrCodePoints).append(';')
.append(nextNodeId).append('\n');
writer.append(sb);
writer.flush();
}
} | java | {
"resource": ""
} |
q169250 | InstructionGroupHasher.hash | validation | public static void hash(@Nonnull final InstructionGroup group,
@Nonnull final String className)
{
final InstructionGroupHasher groupHasher
= new InstructionGroupHasher(group, className);
final String name = groupHasher.hashAndGetName();
group.setName(name);
} | java | {
"resource": ""
} |
q169251 | BaseParser.ignoreCase | validation | @Cached
@DontLabel
public Rule ignoreCase(final char c)
{
return Character.isLowerCase(c) == Character.isUpperCase(c)
? ch(c) : new CharIgnoreCaseMatcher(c);
} | java | {
"resource": ""
} |
q169252 | BaseParser.unicodeChar | validation | @Cached
@DontLabel
public Rule unicodeChar(final int codePoint)
{
if (!Character.isValidCodePoint(codePoint))
throw new InvalidGrammarException("invalid code point "
+ codePoint);
return new CodePointMatcher(codePoint);
} | java | {
"resource": ""
} |
q169253 | BaseParser.unicodeRange | validation | @Cached
@DontLabel
public Rule unicodeRange(final int low, final int high)
{
if (!Character.isValidCodePoint(low))
throw new InvalidGrammarException("invalid code point " + low);
if (!Character.isValidCodePoint(high))
throw new InvalidGrammarException("invalid code point " + high);
if (low > high)
throw new InvalidGrammarException("invalid code point range: "
+ low + " > " + high);
return low == high ? new CodePointMatcher(low)
: new CodePointRangeMatcher(low, high);
} | java | {
"resource": ""
} |
q169254 | BaseParser.anyOf | validation | @DontLabel
public Rule anyOf(final String characters)
{
Objects.requireNonNull(characters);
// TODO: see in this Characters class whether it is possible to wrap
return anyOf(characters.toCharArray());
} | java | {
"resource": ""
} |
q169255 | BaseParser.anyOf | validation | @Cached
@DontLabel
public Rule anyOf(final Characters characters)
{
Objects.requireNonNull(characters);
if (!characters.isSubtractive() && characters.getChars().length == 1)
return ch(characters.getChars()[0]);
if (characters.equals(Characters.NONE))
return NOTHING;
return new AnyOfMatcher(characters);
} | java | {
"resource": ""
} |
q169256 | BaseParser.string | validation | @DontLabel
public Rule string(final String string)
{
Objects.requireNonNull(string);
return string(string.toCharArray());
} | java | {
"resource": ""
} |
q169257 | BaseParser.string | validation | @Cached
@DontLabel
public Rule string(final char... characters)
{
if (characters.length == 1)
return ch(characters[0]); // optimize one-char strings
return new StringMatcher(new String(characters));
} | java | {
"resource": ""
} |
q169258 | BaseParser.ignoreCase | validation | @DontLabel
public Rule ignoreCase(final String string)
{
Objects.requireNonNull(string);
return ignoreCase(string.toCharArray());
} | java | {
"resource": ""
} |
q169259 | BaseParser.optional | validation | @Cached
@DontLabel
public Rule optional(final Object rule)
{
Objects.requireNonNull(rule);
return new OptionalMatcher(toRule(rule));
} | java | {
"resource": ""
} |
q169260 | BaseParser.optional | validation | @DontLabel
public Rule optional(final Object rule, final Object rule2,
final Object... moreRules)
{
Objects.requireNonNull(moreRules);
return optional(sequence(rule, rule2, moreRules));
} | java | {
"resource": ""
} |
q169261 | BaseParser.repeat | validation | @DontLabel
public final RepeatMatcherBuilder<V> repeat(final Object rule,
final Object rule2, final Object... moreRules)
{
Objects.requireNonNull(moreRules);
return repeat(sequence(rule, rule2, moreRules));
} | java | {
"resource": ""
} |
q169262 | BaseParser.zeroOrMore | validation | @DontLabel
public Rule zeroOrMore(final Object rule, final Object rule2,
final Object... moreRules)
{
return repeat(rule, rule2, moreRules).min(0);
} | java | {
"resource": ""
} |
q169263 | BaseParser.fromStringLiteral | validation | @DontExtend
protected Rule fromStringLiteral(final String string)
{
Objects.requireNonNull(string);
return fromCharArray(string.toCharArray());
} | java | {
"resource": ""
} |
q169264 | BaseParser.toRules | validation | @DontExtend
public Rule[] toRules(final Object... objects)
{
return Arrays.stream(objects).map(this::toRule).toArray(Rule[]::new);
} | java | {
"resource": ""
} |
q169265 | BaseParser.toRule | validation | @DontExtend
public Rule toRule(final Object obj)
{
Objects.requireNonNull(obj);
if (obj instanceof Rule)
return (Rule) obj;
if (obj instanceof Character)
return fromCharLiteral((Character) obj);
if (obj instanceof String)
return fromStringLiteral((String) obj);
if (obj instanceof char[])
return fromCharArray((char[]) obj);
if (obj instanceof Action) {
final Action<?> action = (Action<?>) obj;
return new ActionMatcher(action);
}
final String errmsg = obj instanceof Boolean
? "unwrapped Boolean value in rule (wrap it with ACTION())"
: "'" + obj + "' cannot be automatically converted to a rule";
throw new InvalidGrammarException(errmsg);
} | java | {
"resource": ""
} |
q169266 | BaseActions.push | validation | public boolean push(final int down, final V value)
{
check();
context.getValueStack().push(down, value);
return true;
} | java | {
"resource": ""
} |
q169267 | BaseActions.popAs | validation | public <E extends V> E popAs(@Nonnull final Class<E> c)
{
return c.cast(pop());
} | java | {
"resource": ""
} |
q169268 | BaseActions.popAs | validation | public <E extends V> E popAs(final Class<E> c, final int down)
{
return c.cast(pop(down));
} | java | {
"resource": ""
} |
q169269 | BaseActions.peekAs | validation | public <E extends V> E peekAs(final Class<E> c)
{
return c.cast(peek());
} | java | {
"resource": ""
} |
q169270 | BaseActions.poke | validation | public boolean poke(final int down, final V value)
{
check();
context.getValueStack().poke(down, value);
return true;
} | java | {
"resource": ""
} |
q169271 | ParseRunner.match | validation | @Override
public <T> boolean match(final MatcherContext<T> context)
{
final Matcher matcher = context.getMatcher();
final PreMatchEvent<T> preMatchEvent = new PreMatchEvent<>(context);
bus.post(preMatchEvent);
if (throwable != null)
throw new GrappaException("parsing listener error (before match)",
throwable);
// FIXME: is there any case at all where context.getMatcher() is null?
@SuppressWarnings("ConstantConditions")
final boolean match = matcher.match(context);
final MatchContextEvent<T> postMatchEvent = match
? new MatchSuccessEvent<>(context)
: new MatchFailureEvent<>(context);
bus.post(postMatchEvent);
if (throwable != null)
throw new GrappaException("parsing listener error (after match)",
throwable);
return match;
} | java | {
"resource": ""
} |
q169272 | IndexRange.overlapsWith | validation | public boolean overlapsWith(final IndexRange other)
{
Objects.requireNonNull(other, "other");
return end > other.start && other.end > start;
} | java | {
"resource": ""
} |
q169273 | IndexRange.touches | validation | public boolean touches(final IndexRange other)
{
Objects.requireNonNull(other, "other");
return other.end == start || end == other.start;
} | java | {
"resource": ""
} |
q169274 | IndexRange.mergedWith | validation | public IndexRange mergedWith(final IndexRange other)
{
Objects.requireNonNull(other, "other");
return new IndexRange(Math.min(start, other.start),
Math.max(end, other.end));
} | java | {
"resource": ""
} |
q169275 | Grappa.getByteCode | validation | public static <P extends BaseParser<V>, V> byte[] getByteCode(
final Class<P> parserClass)
{
try {
return ParserTransformer.getByteCode(parserClass);
} catch (Exception e) {
throw new RuntimeException("failed to generate byte code", e);
}
} | java | {
"resource": ""
} |
q169276 | TrieNodeBuilder.doAddWord | validation | private void doAddWord(final CharBuffer buffer)
{
if (!buffer.hasRemaining()) {
fullWord = true;
return;
}
final char c = buffer.get();
TrieNodeBuilder builder = subnodes.get(c);
if (builder == null) {
builder = new TrieNodeBuilder();
subnodes.put(c, builder);
}
builder.doAddWord(buffer);
} | java | {
"resource": ""
} |
q169277 | ProxyMatcher.unwrap | validation | public static Matcher unwrap(final Matcher matcher)
{
if (matcher instanceof ProxyMatcher) {
final ProxyMatcher proxyMatcher = (ProxyMatcher) matcher;
if (proxyMatcher.dirty)
proxyMatcher.apply();
return proxyMatcher.target == null ? proxyMatcher
: proxyMatcher.target;
}
return matcher;
} | java | {
"resource": ""
} |
q169278 | EventBusParser.register | validation | public final boolean register(@Nonnull final Object listener)
{
bus.register(Objects.requireNonNull(listener));
return true;
} | java | {
"resource": ""
} |
q169279 | EventBusParser.post | validation | public final boolean post(@Nonnull final Object object)
{
Objects.requireNonNull(object);
bus.post(object);
return true;
} | java | {
"resource": ""
} |
q169280 | AbstractMatcher.getSubContext | validation | @Override
public <V> MatcherContext<V> getSubContext(final MatcherContext<V> context)
{
return context.getSubContext(this);
} | java | {
"resource": ""
} |
q169281 | RangeMatcherBuilder.min | validation | public Rule min(final int nrCycles)
{
Preconditions.checkArgument(nrCycles >= 0,
"illegal repetition number specified (" + nrCycles
+ "), must be 0 or greater");
return range(Range.atLeast(nrCycles));
} | java | {
"resource": ""
} |
q169282 | RangeMatcherBuilder.max | validation | public Rule max(final int nrCycles)
{
Preconditions.checkArgument(nrCycles >= 0,
"illegal repetition number specified (" + nrCycles
+ "), must be 0 or greater");
return range(Range.atMost(nrCycles));
} | java | {
"resource": ""
} |
q169283 | RangeMatcherBuilder.times | validation | public Rule times(final int nrCycles)
{
Preconditions.checkArgument(nrCycles >= 0,
"illegal repetition number specified (" + nrCycles
+ "), must be 0 or greater");
return range(Range.singleton(nrCycles));
} | java | {
"resource": ""
} |
q169284 | RangeMatcherBuilder.times | validation | public Rule times(final int minCycles, final int maxCycles)
{
Preconditions.checkArgument(minCycles >= 0,
"illegal repetition number specified (" + minCycles
+ "), must be 0 or greater");
Preconditions.checkArgument(maxCycles >= minCycles,
"illegal range specified (" + minCycles + ", " + maxCycles
+ "): maximum must be greater than minimum");
return range(Range.closed(minCycles, maxCycles));
} | java | {
"resource": ""
} |
q169285 | RangeMatcherBuilder.range | validation | @Cached
@DontLabel
public Rule range(final Range<Integer> range)
{
Objects.requireNonNull(range, "range must not be null");
final Range<Integer> realRange = normalizeRange(range);
/*
* We always have a lower bound
*/
final int lowerBound = realRange.lowerEndpoint();
/*
* Handle the case where there is no upper bound
*/
if (!realRange.hasUpperBound())
return boundedDown(lowerBound);
/*
* There is an upper bound. Handle the case where it is 0 or 1. Since
* the range is legal, we know that if it is 0, so is the lowerbound;
* and if it is one, the lower bound is either 0 or 1.
*/
final int upperBound = realRange.upperEndpoint();
if (upperBound == 0)
return parser.empty();
if (upperBound == 1)
return lowerBound == 0 ? parser.optional(rule) : rule;
/*
* So, upper bound is 2 or greater; return the appropriate matcher
* according to what the lower bound is.
*
* Also, if the lower and upper bounds are equal, return a matcher doing
* a fixed number of matches.
*/
if (lowerBound == 0)
return boundedUp(upperBound);
return lowerBound == upperBound
? exactly(lowerBound)
: boundedBoth(lowerBound, upperBound);
} | java | {
"resource": ""
} |
q169286 | Characters.allBut | validation | public static Characters allBut(final char... chars)
{
final int length = chars.length;
if (length == 0)
return ALL;
final char[] array = Arrays.copyOf(chars, length);
Arrays.sort(array);
return new Characters(true, array);
} | java | {
"resource": ""
} |
q169287 | Plugins.getDeploymentDescriptor | validation | public List<JAXBElement<? extends DeploymentDescriptorType>> getDeploymentDescriptor() {
if (deploymentDescriptor == null) {
deploymentDescriptor = new ArrayList<JAXBElement<? extends DeploymentDescriptorType>>();
}
return this.deploymentDescriptor;
} | java | {
"resource": ""
} |
q169288 | Authentications.getAuthenticationConfiguration | validation | public List<JAXBElement<? extends AuthenticationConfigurationType>> getAuthenticationConfiguration() {
if (authenticationConfiguration == null) {
authenticationConfiguration = new ArrayList<JAXBElement<? extends AuthenticationConfigurationType>>();
}
return this.authenticationConfiguration;
} | java | {
"resource": ""
} |
q169289 | ApplicationManagement.getBWServices | validation | private List<Bw> getBWServices() {
List<Bw> result = new ArrayList<Bw>();
for (JAXBElement<? extends ServiceType> jaxbElement : application.getServices().getBaseService()) {
if (jaxbElement.getName().getLocalPart().equals("bw")) {
result.add((Bw) jaxbElement.getValue());
}
}
return result;
} | java | {
"resource": ""
} |
q169290 | ApplicationManagement.addMonitoringEventsToAllServices | validation | public void addMonitoringEventsToAllServices(Events events) {
List<JAXBElement<? extends EventType>> events_ = events.getEvent();
if (events_ != null && !events_.isEmpty()) {
for (Bw service : this.getBWServices()) {
Monitor monitor = service.getMonitor();
if (monitor != null) {
monitor.setEvents(events);
}
}
}
} | java | {
"resource": ""
} |
q169291 | GlobalVariables.getGlobalVariable | validation | public List<GlobalVariables.GlobalVariable> getGlobalVariable() {
if (globalVariable == null) {
globalVariable = new ArrayList<GlobalVariables.GlobalVariable>();
}
return this.globalVariable;
} | java | {
"resource": ""
} |
q169292 | Services.getBaseService | validation | public List<JAXBElement<? extends ServiceType>> getBaseService() {
if (baseService == null) {
baseService = new ArrayList<JAXBElement<? extends ServiceType>>();
}
return this.baseService;
} | java | {
"resource": ""
} |
q169293 | Events.getEvent | validation | public List<JAXBElement<? extends EventType>> getEvent() {
if (event == null) {
event = new ArrayList<JAXBElement<? extends EventType>>();
}
return this.event;
} | java | {
"resource": ""
} |
q169294 | AbstractBWMojo.checkBWProject | validation | private void checkBWProject() throws MojoExecutionException {
if (projectDirectory == null) {
projectNotFound();
} else if (!projectDirectory.exists() || !projectDirectory.isDirectory()) {
projectNotFound();
}
} | java | {
"resource": ""
} |
q169295 | AbstractBWMojo.readDependenciesFromFile | validation | protected List<Dependency> readDependenciesFromFile(String resolvedFileName, String dependencyType) throws IOException {
List<Dependency> dependencies = new ArrayList<Dependency>();
File resolvedFile = new File(resolvedFileName);
if (!resolvedFile.exists()) {
return dependencies;
}
FileInputStream fstream = new FileInputStream(resolvedFile);
DataInputStream ds = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(ds));
Pattern p = Pattern.compile(" (.*):(.*):" + dependencyType + ":(.*):(.*)"); // keep only selected type (projlib or jar or bw-ear) dependencies
String strLine;
while ((strLine = br.readLine()) != null) {
Matcher m = p.matcher(strLine);
if (m.matches()) {
getLog().debug(m.group(0));
String groupId = m.group(1);
String artifactId = m.group(2);
String version = m.group(3);
String scope = m.group(4);
// create the dependency
Dependency dependency = new Dependency();
dependency.setGroupId(groupId);
dependency.setArtifactId(artifactId);
dependency.setVersion(version);
dependency.setType(dependencyType);
dependency.setScope(scope);
dependencies.add(dependency);
}
}
br.close();
return dependencies;
} | java | {
"resource": ""
} |
q169296 | AbstractBWMojo.launchTIBCOBinary | validation | protected void launchTIBCOBinary(File binary, List<File> tras, ArrayList<String> arguments, File workingDir, String errorMsg) throws IOException, MojoExecutionException {
launchTIBCOBinary(binary, tras, arguments, workingDir, errorMsg, false, true);
} | java | {
"resource": ""
} |
q169297 | Actions.getAction | validation | public List<JAXBElement<? extends ActionType>> getAction() {
if (action == null) {
action = new ArrayList<JAXBElement<? extends ActionType>>();
}
return this.action;
} | java | {
"resource": ""
} |
q169298 | CompileEARMojo.cleanDirectory | validation | protected boolean cleanDirectory(File directory) {
if (directory.isDirectory() && directory.listFiles().length != 0) {
for (File file : directory.listFiles()) {
if (file.isFile()) {
file.delete();
}
}
}
return directory.delete();
} | java | {
"resource": ""
} |
q169299 | SimpleType.getFinal | validation | public java.util.List<String> getFinal() {
if (_final == null) {
_final = new ArrayList<String>();
}
return this._final;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.