_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q177800
AbstractAuthResource.verifyAccountNameStrength
test
public void verifyAccountNameStrength(String accountName) throws AuthenticationException { Matcher matcher = PATTERN.matcher(accountName); if (!matcher.matches()) { throw new AuthenticationException(accountName + " is not a valid email"); } }
java
{ "resource": "" }
q177801
AbstractAuthResource.verifyPasswordStrength
test
public void verifyPasswordStrength(String oldPassword, String newPassword, T user) throws AuthenticationException { List<Rule> rules = getPasswordRules(); PasswordValidator validator = new PasswordValidator(rules); PasswordData passwordData = new PasswordData(new Password(newPassword)); ...
java
{ "resource": "" }
q177802
SearchFactory.provide
test
@Override public SearchModel provide() { SearchModel searchModel = new SearchModel(); searchModel.setResponse(response); String method = getMethod(); if ("GET".equals(method)) { MultivaluedMap<String, String> queryParameters = getUriInfo().getQueryParameters(); ...
java
{ "resource": "" }
q177803
Transaction.success
test
private void success() { org.hibernate.Transaction txn = session.getTransaction(); if (txn != null && txn.getStatus().equals(TransactionStatus.ACTIVE)) { txn.commit(); } }
java
{ "resource": "" }
q177804
Transaction.error
test
private void error() { org.hibernate.Transaction txn = session.getTransaction(); if (txn != null && txn.getStatus().equals(TransactionStatus.ACTIVE)) { txn.rollback(); } }
java
{ "resource": "" }
q177805
Transaction.start
test
private void start() { try { before(); transactionWrapper.wrap(); success(); } catch (Exception e) { error(); if (exceptionHandler != null) { exceptionHandler.onException(e); } else { throw e; ...
java
{ "resource": "" }
q177806
Query.configureFieldByName
test
public static <E> Holder<E> configureFieldByName(Criteria<E> criteria, String name){ if(Validations.isEmptyOrNull(name)) return null; // parse x.y name as [x, y] String[] names = name.split("\\."); // uses to keep current name by names index. String currentName; // init s...
java
{ "resource": "" }
q177807
TokenFactory.isAuthorized
test
private boolean isAuthorized(BasicToken token, List<UriTemplate> matchedTemplates, String method) { StringBuilder path = new StringBuilder(); // Merge all path templates and generate a path. for (UriTemplate template : matchedTemplates) { path.insert(0, template.getTemplate()); ...
java
{ "resource": "" }
q177808
ParseDate.parse
test
@Override public Date parse(Object o, Field field) { if (!isValid(o)) { return null; } JsonFormat formatAnn = field.getAnnotation(JsonFormat.class); if (formatAnn == null) { throw new RuntimeException("JsonFormat with pattern needed for: " + field.getName()); ...
java
{ "resource": "" }
q177809
RobeRuntimeException.getResponse
test
public Response getResponse() { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(builder.build()).build(); }
java
{ "resource": "" }
q177810
Restrictions.eq
test
public static Restriction eq(String name, Object value) { return new Restriction(Operator.EQUALS, name, value); }
java
{ "resource": "" }
q177811
Restrictions.ne
test
public static Restriction ne(String name, Object value){ return new Restriction(Operator.NOT_EQUALS, name, value); }
java
{ "resource": "" }
q177812
Restrictions.lt
test
public static Restriction lt(String name, Object Object){ return new Restriction(Operator.LESS_THAN, name, Object); }
java
{ "resource": "" }
q177813
Restrictions.le
test
public static Restriction le(String name, Object value){ return new Restriction(Operator.LESS_OR_EQUALS_THAN, name, value); }
java
{ "resource": "" }
q177814
Restrictions.gt
test
public static Restriction gt(String name, Object value){ return new Restriction(Operator.GREATER_THAN, name, value); }
java
{ "resource": "" }
q177815
Restrictions.ge
test
public static Restriction ge(String name, Object value){ return new Restriction(Operator.GREATER_OR_EQUALS_THAN, name, value); }
java
{ "resource": "" }
q177816
Restrictions.ilike
test
public static Restriction ilike(String name, Object value){ return new Restriction(Operator.CONTAINS, name, value); }
java
{ "resource": "" }
q177817
Restrictions.in
test
public static Restriction in(String name, Object value){ return new Restriction(Operator.IN, name, value); }
java
{ "resource": "" }
q177818
NamespaceManager.withNamespace
test
public NamespaceManager withNamespace(String namespace, String href) { if (namespaces.containsKey(namespace)) { throw new RepresentationException( format("Duplicate namespace '%s' found for representation factory", namespace)); } if (!href.contains("{rel}")) { throw new RepresentationE...
java
{ "resource": "" }
q177819
ResourceRepresentation.withContent
test
public ResourceRepresentation<V> withContent(ByteString content) { return new ResourceRepresentation<>( Option.of(content), links, rels, namespaceManager, value, resources); }
java
{ "resource": "" }
q177820
ResourceRepresentation.withRel
test
public ResourceRepresentation<V> withRel(Rel rel) { if (rels.containsKey(rel.rel())) { throw new IllegalStateException(String.format("Rel %s is already declared.", rel.rel())); } final TreeMap<String, Rel> updatedRels = rels.put(rel.rel(), rel); return new ResourceRepresentation<>( content...
java
{ "resource": "" }
q177821
ResourceRepresentation.withValue
test
public <R> ResourceRepresentation<R> withValue(R newValue) { return new ResourceRepresentation<>( Option.none(), links, rels, namespaceManager, newValue, resources); }
java
{ "resource": "" }
q177822
ResourceRepresentation.withNamespace
test
public ResourceRepresentation<V> withNamespace(String namespace, String href) { if (!rels.containsKey("curies")) { rels = rels.put("curies", Rels.collection("curies")); } final NamespaceManager updatedNamespaceManager = namespaceManager.withNamespace(namespace, href); return new ResourceR...
java
{ "resource": "" }
q177823
UTF8.canDecode
test
public static boolean canDecode(byte[] input, int off, int len) { try { decode(input, off, len); } catch (IllegalArgumentException ex) { return false; } return true; }
java
{ "resource": "" }
q177824
UTF8.encode
test
public static byte[] encode(String str, int off, int len) { return encode(str.substring(off, off + len)); }
java
{ "resource": "" }
q177825
CharStreams.equal
test
public static boolean equal(Reader in1, Reader in2) throws IOException { if (in1 == in2) { return true; } if (in1 == null || in2 == null) { return false; } in1 = buffer(in1); in2 = buffer(in2); int c1 = in1.read(); int c2 = in2.read(); while (c1 != -1 && c2 != -1 && c1 == c2) { c1 = in1.read...
java
{ "resource": "" }
q177826
XFiles.mv
test
public static void mv(File src, File dst) throws IOException { Parameters.checkNotNull(dst); if (!src.equals(dst)) { cp(src, dst); try { rm(src); } catch (IOException e) { rm(dst); throw new IOException("Can't move " + src, e); } } }
java
{ "resource": "" }
q177827
XFiles.touch
test
public static void touch(File... files) throws IOException { long now = System.currentTimeMillis(); for (File f : files) { if (!f.createNewFile() && !f.setLastModified(now)) { throw new IOException("Failed to touch " + f); } } }
java
{ "resource": "" }
q177828
XFiles.getBaseName
test
public static String getBaseName(File f) { String fileName = f.getName(); int index = fileName.lastIndexOf('.'); return index == -1 ? fileName : fileName.substring(0, index); }
java
{ "resource": "" }
q177829
MD4.addPadding
test
private void addPadding() { int len = BLOCK_LENGTH - bufferLen; if (len < 9) { len += BLOCK_LENGTH; } byte[] buf = new byte[len]; buf[0] = (byte) 0x80; for (int i = 1; i < len - 8; i++) { buf[i] = (byte) 0x00; } counter = (counter + (long) bufferLen) * 8L; LittleEndian.encode(counter, buf, len ...
java
{ "resource": "" }
q177830
Classes.getShortName
test
public static String getShortName(Class<?> c) { String qname = getQualifiedName(c); int start = qname.lastIndexOf('$'); if (start == -1) { start = qname.lastIndexOf('.'); } return qname.substring(start + 1); }
java
{ "resource": "" }
q177831
Classes.getSuperTypes
test
public static Set<Class<?>> getSuperTypes(Class<?> c) { Set<Class<?>> classes = new HashSet<Class<?>>(); for (Class<?> clazz : c.getInterfaces()) { classes.add(clazz); classes.addAll(getSuperTypes(clazz)); } Class<?> sup = c.getSuperclass(); if (sup != null) { classes.add(sup); classes.addAll(get...
java
{ "resource": "" }
q177832
Passwords.verify
test
public static boolean verify(String password, byte[] hash) { byte[] h = Arrays.copyOf(hash, HASH_LENGTH + SALT_LENGTH + 3); int n = 1 << (h[HASH_LENGTH + SALT_LENGTH] & 0xFF); int r = h[HASH_LENGTH + SALT_LENGTH + 1] & 0xFF; int p = h[HASH_LENGTH + SALT_LENGTH + 2] & 0xFF; if (n > N || n < N_MIN || r > R || ...
java
{ "resource": "" }
q177833
Scanf.readString
test
public static String readString(Charset charset) throws IOException { Reader in = new InputStreamReader(System.in, charset); BufferedReader reader = new BufferedReader(in); try { return reader.readLine(); } finally { reader.close(); } }
java
{ "resource": "" }
q177834
ByteBuffer.append
test
public ByteBuffer append(byte b) { int newCount = count + 1; ensureCapacity(newCount); buf[count] = b; count = newCount; return this; }
java
{ "resource": "" }
q177835
ByteBuffer.append
test
public ByteBuffer append(byte[] bytes, int off, int len) { int newCount = count + len; ensureCapacity(newCount); System.arraycopy(bytes, off, buf, count, len); count = newCount; return this; }
java
{ "resource": "" }
q177836
XArrays.copyOf
test
public static <T> T[] copyOf(T[] original) { return Arrays.copyOf(original, original.length); }
java
{ "resource": "" }
q177837
Fraction.plus
test
public Fraction plus(Fraction f) { return new Fraction(n.multiply(f.d).add(f.n.multiply(d)), d.multiply(f.d)).reduced(); }
java
{ "resource": "" }
q177838
Fraction.minus
test
public Fraction minus(Fraction f) { return new Fraction(n.multiply(f.d).subtract(f.n.multiply(d)), d.multiply(f.d)).reduced(); }
java
{ "resource": "" }
q177839
Fraction.multipliedBy
test
public Fraction multipliedBy(Fraction f) { return new Fraction(n.multiply(f.n), d.multiply(f.d)).reduced(); }
java
{ "resource": "" }
q177840
Fraction.dividedBy
test
public Fraction dividedBy(Fraction f) { if (ZERO.equals(f)) { throw new ArithmeticException("Division by zero"); } return new Fraction(n.multiply(f.d), d.multiply(f.n)).reduced(); }
java
{ "resource": "" }
q177841
Numbers.max
test
public static long max(long... values) { Parameters.checkCondition(values.length > 0); long max = values[0]; for (int i = 1; i < values.length; i++) { max = Math.max(max, values[i]); } return max; }
java
{ "resource": "" }
q177842
Numbers.min
test
public static long min(long... values) { Parameters.checkCondition(values.length > 0); long min = values[0]; for (int i = 1; i < values.length; i++) { min = Math.min(min, values[i]); } return min; }
java
{ "resource": "" }
q177843
Parameters.checkCondition
test
public static void checkCondition(boolean condition, String msg, Object... args) { if (!condition) { throw new IllegalArgumentException(format(msg, args)); } }
java
{ "resource": "" }
q177844
LocationforecastLTSService.fetchContent
test
public MeteoData<LocationForecast> fetchContent(double longitude, double latitude, int altitude) throws MeteoException { MeteoResponse response = getMeteoClient().fetchContent( createServiceUriBuilder() .addParameter(PARAM_LATITUDE, latitude) ...
java
{ "resource": "" }
q177845
SunriseService.fetchContent
test
public MeteoData<Sunrise> fetchContent(double longitude, double latitude, LocalDate date) throws MeteoException { MeteoResponse response = getMeteoClient().fetchContent( createServiceUriBuilder() .addParameter(PARAM_LATITUDE, latitude) .addParamete...
java
{ "resource": "" }
q177846
SunriseService.fetchContent
test
public MeteoData<Sunrise> fetchContent(double longitude, double latitude, LocalDate from, LocalDate to) throws MeteoException { MeteoResponse response = getMeteoClient().fetchContent( createServiceUriBuilder() .addParameter(PARAM_LATITUDE, latitude) ...
java
{ "resource": "" }
q177847
LocationForecastHelper.findHourlyPointForecastsFromNow
test
public List<MeteoExtrasForecast> findHourlyPointForecastsFromNow(int hoursAhead) { List<MeteoExtrasForecast> pointExtrasForecasts = new ArrayList<>(); ZonedDateTime now = getNow(); for (int i = 0; i < hoursAhead; i++) { ZonedDateTime ahead = now.plusHours(i); Optional<Poi...
java
{ "resource": "" }
q177848
LocationForecastHelper.findNearestForecast
test
public Optional<MeteoExtrasForecast> findNearestForecast(ZonedDateTime dateTime) { ZonedDateTime dt = toZeroMSN(dateTime.withZoneSameInstant(METZONE)); PointForecast chosenForecast = null; for (Forecast forecast : getLocationForecast().getForecasts()) { if (forecast instanceof PointF...
java
{ "resource": "" }
q177849
TextforecastService.fetchContent
test
public MeteoData<Weather> fetchContent(ForecastQuery query) throws MeteoException { MeteoResponse response = getMeteoClient().fetchContent( createServiceUriBuilder() .addParameter("forecast", query.getName()) .addParameter("language", query.getLang...
java
{ "resource": "" }
q177850
LongtermForecastHelper.createSimpleLongTermForecast
test
public MeteoExtrasLongTermForecast createSimpleLongTermForecast() throws MeteoException { List<MeteoExtrasForecastDay> forecastDays = new ArrayList<>(); ZonedDateTime dt = getNow(); for (int i = 0; i <= 6; i++) { ZonedDateTime dti = dt.plusDays(i); if (getIndexer().hasFor...
java
{ "resource": "" }
q177851
LongtermForecastHelper.createLongTermForecast
test
public MeteoExtrasLongTermForecast createLongTermForecast() { List<MeteoExtrasForecastDay> forecastDays = new ArrayList<>(); ZonedDateTime dt = toZeroHMSN(getLocationForecast().getCreated().plusDays(1)); for (int i = 0; i < series.getSeries().size(); i++) { createLongTermForecastDa...
java
{ "resource": "" }
q177852
Location.fromCoordinates
test
public static Location fromCoordinates(String coordinates) { if (coordinates == null) { throw new IllegalArgumentException("Cannot create Location from null input."); } Matcher m = P.matcher(coordinates); if (!m.matches()) { throw new IllegalArgumentException( ...
java
{ "resource": "" }
q177853
AvailableTextforecastsService.fetchContent
test
public MeteoData<Available> fetchContent() throws MeteoException { MeteoResponse response = getMeteoClient().fetchContent( createServiceUriBuilder().addParameter("available", null).skipQuestionMarkInUrl().build()); return new MeteoData<>(parser.parse(response.getData()), response); }
java
{ "resource": "" }
q177854
WindSymbolHelper.createWindSymbolName
test
public static Optional<String> createWindSymbolName(PointForecast pointForecast) { if (pointForecast == null || pointForecast.getWindDirection() == null || pointForecast.getWindSpeed() == null) { return Optional.empty(); } return Optional.of( pointForecast.getWindDire...
java
{ "resource": "" }
q177855
WindSymbolHelper.findBeaufortLevel
test
public static Optional<BeaufortLevel> findBeaufortLevel(PointForecast pointForecast) { if (pointForecast == null || pointForecast.getWindSpeed() == null) { return Optional.empty(); } return Optional.ofNullable(findUnitById(pointForecast.getWindSpeed().getBeaufort())); }
java
{ "resource": "" }
q177856
MeteoNetUtils.createUri
test
public static URI createUri(String uri) throws MeteoException { if (uri == null) { throw new MeteoException("URI is null"); } try { return new URI(uri); } catch (URISyntaxException e) { throw new MeteoException(e); } }
java
{ "resource": "" }
q177857
SunriseDate.isSun
test
public boolean isSun(ZonedDateTime currentDate) { if (getSun().getNeverRise()) { return false; } else if (getSun().getNeverSet()) { return true; } return timeWithinPeriod(currentDate); }
java
{ "resource": "" }
q177858
MeteoForecastIndexer.getPointForecast
test
Optional<PointForecast> getPointForecast(ZonedDateTime dateTime) { for (Forecast forecast : forecasts) { if (forecast instanceof PointForecast) { PointForecast pointForecast = (PointForecast) forecast; if (createHourIndexKey(dateTime) .equals(c...
java
{ "resource": "" }
q177859
MeteoForecastIndexer.getBestFitPeriodForecast
test
Optional<PeriodForecast> getBestFitPeriodForecast(ZonedDateTime from, ZonedDateTime to) { if (from == null || to == null) { return Optional.empty(); } // Making sure that we remove minutes, seconds and milliseconds from the request timestamps ZonedDateTime requestFrom = toZe...
java
{ "resource": "" }
q177860
TextLocationService.fetchContent
test
public MeteoData<TextLocationWeather> fetchContent(double longitude, double latitude) throws MeteoException { return fetchContent(longitude, latitude, TextLocationLanguage.NB); }
java
{ "resource": "" }
q177861
TextLocationService.fetchContent
test
public MeteoData<TextLocationWeather> fetchContent(double longitude, double latitude, TextLocationLanguage language) throws MeteoException { MeteoResponse response = getMeteoClient().fetchContent( createServiceUriBuilder() .addParameter("latitude", latitude) ...
java
{ "resource": "" }
q177862
Application.updateDB
test
private void updateDB() throws SQLException, LiquibaseException { System.out.println("About to perform DB update."); try (BasicDataSource dataSource = new BasicDataSource()) { dataSource.setUrl(fullConnectionString); dataSource.setUsername(username); dataSource.se...
java
{ "resource": "" }
q177863
JavascriptDecoder.invokeStringMethod
test
private static String invokeStringMethod(final ScriptEngine jsEngine, final Object thiz, final String name, final Object... args) throws NoSuchMethodException, ScriptException { return (String) ((Invocable) jsEngine).invokeMethod(thiz, name, args); }
java
{ "resource": "" }
q177864
ReferencedObject.acquire
test
public synchronized T acquire(final DataSource source) throws DataSourceException { if (object == null) { if (getReference() == null) { throw new IllegalStateException("No reference or object present"); } else { object = source.getObject(getRef...
java
{ "resource": "" }
q177865
ReferencedObject.getReferencedObject
test
public static <T> ReferencedObject<T> getReferencedObject(final Class<T> clazz, final String ref) { return new ReferencedObject<>(clazz, ref, null); }
java
{ "resource": "" }
q177866
ReferencedObject.getWrappedObject
test
public static <T> ReferencedObject<T> getWrappedObject(final Class<T> clazz, final T obj) { return new ReferencedObject<>(clazz, null, obj); }
java
{ "resource": "" }
q177867
CafConfigurationSource.getConfig
test
private <T> T getConfig(final Class<T> configClass) throws ConfigurationException { Iterator<Name> it = getServicePath().descendingPathIterator(); while (it.hasNext()) { try (InputStream in = getConfigurationStream(configClass, it.next())) { return decoder.deseria...
java
{ "resource": "" }
q177868
CafConfigurationSource.getIsSubstitutorEnabled
test
private static boolean getIsSubstitutorEnabled(final BootstrapConfiguration bootstrapConfig) { final String ENABLE_SUBSTITUTOR_CONFIG_KEY = "CAF_CONFIG_ENABLE_SUBSTITUTOR"; final boolean ENABLE_SUBSTITUTOR_CONFIG_DEFAULT = true; // Return the default if the setting is not configured ...
java
{ "resource": "" }
q177869
Jersey2ServiceIteratorProvider.createClassIterator
test
@Override public <T> Iterator<Class<T>> createClassIterator( final Class<T> service, final String serviceName, final ClassLoader loader, final boolean ignoreOnClassNotFound ) { final Iterator<Class<T>> delegateClassIterator = delegate.createClassIterator( ...
java
{ "resource": "" }
q177870
CafConfigurationDecoderProvider.getDecoder
test
@Override public Decoder getDecoder(final BootstrapConfiguration bootstrap, final Decoder defaultDecoder) { final String DECODER_CONFIG_KEY = "CAF_CONFIG_DECODER"; final String decoder; try { // Return the specified default Decoder if none has been configured if ...
java
{ "resource": "" }
q177871
ModuleLoader.getServices
test
public static <T> List<T> getServices(final Class<T> intf) { Objects.requireNonNull(intf); List<T> ret = new LinkedList<>(); for (final T t : ServiceLoader.load(intf)) { ret.add(t); } return ret; }
java
{ "resource": "" }
q177872
ModuleProvider.getModule
test
public <T> T getModule(final Class<T> interfaceImplemented, final String moduleType) throws NullPointerException { //check for this type in the map Map<String, Object> computedValue = loadedModules.computeIfAbsent(interfaceImplemented, ModuleProvider::loadModules); Object moduleInstance = co...
java
{ "resource": "" }
q177873
ReferencedData.acquire
test
public synchronized InputStream acquire(final DataSource source) throws DataSourceException { InputStream ret; if (data == null) { if (getReference() == null) { throw new IllegalStateException("No data or reference present"); } else { r...
java
{ "resource": "" }
q177874
ReferencedData.size
test
public synchronized long size(final DataSource source) throws DataSourceException { if (data == null) { if (getReference() == null) { throw new IllegalStateException("No data or reference present"); } else { return source.getDataSize(getReferen...
java
{ "resource": "" }
q177875
ReferencedData.getWrappedData
test
public static ReferencedData getWrappedData(final String ref, final byte[] data) { return new ReferencedData(Objects.requireNonNull(ref), data); }
java
{ "resource": "" }
q177876
Name.getIndex
test
public String getIndex(final int index) { if (index < 0 || index >= components.size()) { throw new IllegalArgumentException("Index out of bounds"); } return components.get(index); }
java
{ "resource": "" }
q177877
Name.getPrefix
test
public Name getPrefix(final int upperIndex) { if (upperIndex < 0 || upperIndex > components.size()) { throw new IllegalArgumentException("Index out of bounds"); } return new Name(components.subList(0, upperIndex)); }
java
{ "resource": "" }
q177878
Arc.colored
test
boolean colored() { return type == Compiler.PLAIN || type == Compiler.AHEAD || type == Compiler.BEHIND; }
java
{ "resource": "" }
q177879
Runtime.exec
test
boolean exec(HsrePattern re, CharSequence data, EnumSet<ExecFlags> execFlags) throws RegexException { /* sanity checks */ /* setup */ if (0 != (re.guts.info & Flags.REG_UIMPOSSIBLE)) { throw new RegexException("Regex marked impossible"); } eflags = 0; for (ExecFlag...
java
{ "resource": "" }
q177880
Runtime.cfindloop
test
private boolean cfindloop(Dfa d, Dfa s, int[] coldp) { int begin; int end; int cold; int open; /* open and close of range of possible starts */ int close; int estart; int estop; boolean shorter = 0 != (g.tree.flags & Subre.SHORTER); boolean h...
java
{ "resource": "" }
q177881
Runtime.subset
test
private void subset(RuntimeSubexpression sub, int begin, int end) { int n = sub.number; assert n > 0; while (match.size() < (n + 1)) { match.add(null); } match.set(n, new RegMatch(begin, end)); }
java
{ "resource": "" }
q177882
Runtime.crevdissect
test
private boolean crevdissect(RuntimeSubexpression t, int begin, int end) { Dfa d; Dfa d2; int mid; assert t.op == '.'; assert t.left != null && t.left.machine.states.length > 0; assert t.right != null && t.right.machine.states.length > 0; assert 0 != (t.left.flags...
java
{ "resource": "" }
q177883
Runtime.cbrdissect
test
private boolean cbrdissect(RuntimeSubexpression t, int begin, int end) { int i; int n = t.number; int len; int paren; int p; int stop; int min = t.min; int max = t.max; assert t.op == 'b'; assert n >= 0; //TODO: could this get be ...
java
{ "resource": "" }
q177884
Compiler.cloneouts
test
private void cloneouts(Nfa nfa, State old, State from, State to, int type) { Arc a; assert old != from; for (a = old.outs; a != null; a = a.outchain) { nfa.newarc(type, a.co, from, to); } }
java
{ "resource": "" }
q177885
Compiler.optst
test
private void optst(Subre t) { if (t == null) { return; } /* recurse through children */ if (t.left != null) { optst(t.left); } if (t.right != null) { optst(t.right); } }
java
{ "resource": "" }
q177886
Compiler.markst
test
private void markst(Subre t) { assert t != null; t.flags |= Subre.INUSE; if (t.left != null) { markst(t.left); } if (t.right != null) { markst(t.right); } }
java
{ "resource": "" }
q177887
Compiler.nfanode
test
private long nfanode(Subre t) throws RegexException { long ret; assert t.begin != null; if (LOG.isDebugEnabled() && IS_DEBUG) { LOG.debug(String.format("========= TREE NODE %s ==========", t.shortId())); } Nfa newNfa = new Nfa(nfa); newNfa.dupnfa(t.begin, t...
java
{ "resource": "" }
q177888
Compiler.parse
test
private Subre parse(int stopper, int type, State initState, State finalState) throws RegexException { State left; /* scaffolding for branch */ State right; Subre branches; /* top level */ Subre branch; /* current branch */ Subre t; /* temporary */ int firstbranch; ...
java
{ "resource": "" }
q177889
Compiler.deltraverse
test
private void deltraverse(Nfa nfa, State leftend, State s) { Arc a; State to; if (s.nouts == 0) { return; /* nothing to do */ } if (s.tmp != null) { return; /* already in progress */ } s.tmp = s; /* mark as in prog...
java
{ "resource": "" }
q177890
Compiler.nonword
test
private void nonword(int dir, State lp, State rp) { int anchor = (dir == AHEAD) ? '$' : '^'; assert dir == AHEAD || dir == BEHIND; nfa.newarc(anchor, (short)1, lp, rp); nfa.newarc(anchor, (short)0, lp, rp); cm.colorcomplement(nfa, dir, wordchrs, lp, rp); /* (no need for spec...
java
{ "resource": "" }
q177891
Compiler.word
test
private void word(int dir, State lp, State rp) { assert dir == AHEAD || dir == BEHIND; cloneouts(nfa, wordchrs, lp, rp, dir); /* (no need for special attention to \n) */ }
java
{ "resource": "" }
q177892
Compiler.scannum
test
private int scannum() throws RegexException { int n = 0; while (see(DIGIT) && n < DUPMAX) { n = n * 10 + nextvalue; lex.next(); } if (see(DIGIT) || n > DUPMAX) { throw new RegexException("Unvalid reference number."); } return n; }
java
{ "resource": "" }
q177893
Compiler.bracket
test
private void bracket(State lp, State rp) throws RegexException { assert see('['); lex.next(); while (!see(']') && !see(EOS)) { brackpart(lp, rp); } assert see(']'); cm.okcolors(nfa); }
java
{ "resource": "" }
q177894
Compiler.scanplain
test
private String scanplain() throws RegexException { int startp = now; int endp; assert see(COLLEL) || see(ECLASS) || see(CCLASS); lex.next(); endp = now; while (see(PLAIN)) { endp = now; lex.next(); } String ret = new String(patte...
java
{ "resource": "" }
q177895
Compiler.newlacon
test
private int newlacon(State begin, State end, int pos) { if (lacons.size() == 0) { // skip 0 lacons.add(null); } Subre sub = new Subre((char)0, 0, begin, end); sub.subno = pos; lacons.add(sub); return lacons.size() - 1; // it's the index into the ar...
java
{ "resource": "" }
q177896
Compiler.onechr
test
private void onechr(int c, State lp, State rp) throws RegexException { if (0 == (cflags & Flags.REG_ICASE)) { nfa.newarc(PLAIN, cm.subcolor(c), lp, rp); return; } /* rats, need general case anyway... */ dovec(Locale.allcases(c), lp, rp); }
java
{ "resource": "" }
q177897
Compiler.dovec
test
private void dovec(UnicodeSet set, State lp, State rp) throws RegexException { int rangeCount = set.getRangeCount(); for (int rx = 0; rx < rangeCount; rx++) { int rangeStart = set.getRangeStart(rx); int rangeEnd = set.getRangeEnd(rx); /* * Note: ICU oper...
java
{ "resource": "" }
q177898
ColorMap.getcolor
test
private short getcolor(int c) { try { return map.get(c); } catch (NullPointerException npe) { throw new RegexRuntimeException(String.format("Failed to map codepoint U+%08X.", c)); } }
java
{ "resource": "" }
q177899
ColorMap.pseudocolor
test
short pseudocolor() { short co = newcolor(); ColorDesc cd = colorDescs.get(co); cd.setNChars(1); cd.markPseudo(); return co; }
java
{ "resource": "" }