code
stringlengths
73
34.1k
label
stringclasses
1 value
private Name makeOperatorName(String name) { Name opName = names.fromString(name); operatorNames.add(opName); return opName; }
java
public Widget put(IWidgetFactory factory, String name) { Widget widget = factory.getWidget(); put(widget, name); return widget; }
java
public static String getEventTypeDescription(final XMLStreamReader reader) { final int eventType = reader.getEventType(); if (eventType == XMLStreamConstants.START_ELEMENT) { final String namespace = reader.getNamespaceURI(); return "<" + reader.getLocalName() ...
java
public static boolean isStartElement( final XMLStreamReader reader, final String namespace, final String localName) { return reader.getEventType() == XMLStreamConstants.START_ELEMENT && nameEquals(reader, namespace, localName); }
java
public static boolean nameEquals( final XMLStreamReader reader, final String namespace, final String localName) { if (!reader.getLocalName().equals(localName)) { return false; } if (namespace == null) { return true; } fi...
java
public static Class optionalClassAttribute( final XMLStreamReader reader, final String localName, final Class defaultValue) throws XMLStreamException { return optionalClassAttribute(reader, null, localName, defaultValue); }
java
public static void skipElement(final XMLStreamReader reader) throws XMLStreamException, IOException { if (reader.getEventType() != XMLStreamConstants.START_ELEMENT) { return; } final String namespace = reader.getNamespaceURI(); final String name = reader.getLocalName(); ...
java
public UriBuilder path(String path) throws URISyntaxException { path = path.trim(); if (getPath().endsWith("/")) { return new UriBuilder(setPath(String.format("%s%s", getPath(), path))); } else { return new UriBuilder(setPath(String.format("%s/%s", getPath(), path))); ...
java
public <T> ApruveResponse<List<T>> index(String path, GenericType<List<T>> resultType) { Response response = restRequest(path).get(); List<T> responseObject = null; ApruveResponse<List<T>> result; if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) { responseObject = response.readEntity(resultT...
java
public <T> ApruveResponse<T> get(String path, Class<T> resultType) { Response response = restRequest(path).get(); return processResponse(response, resultType); }
java
public boolean sync(NewRelicCache cache) { if(cache == null) throw new IllegalArgumentException("null cache"); checkInitialize(cache); boolean ret = isInitialized(); if(!ret) throw new IllegalStateException("cache not initialized"); clear(cache); ...
java
public boolean syncAlerts(NewRelicCache cache) { boolean ret = true; if(apiClient == null) throw new IllegalArgumentException("null API client"); // Get the alert configuration using the REST API if(cache.isAlertsEnabled()) { ret = false; ...
java
public boolean syncApplications(NewRelicCache cache) { boolean ret = true; if(apiClient == null) throw new IllegalArgumentException("null API client"); // Get the application configuration using the REST API if(cache.isApmEnabled() || cache.isBrowserEnabled() || cache.i...
java
public boolean syncPlugins(NewRelicCache cache) { boolean ret = true; if(apiClient == null) throw new IllegalArgumentException("null API client"); // Get the Plugins configuration using the REST API if(cache.isPluginsEnabled()) { ret = false; ...
java
public boolean syncMonitors(NewRelicCache cache) { boolean ret = true; if(apiClient == null) throw new IllegalArgumentException("null API client"); // Get the Synthetics configuration using the REST API if(cache.isSyntheticsEnabled()) { ret = false; ...
java
public boolean syncServers(NewRelicCache cache) { boolean ret = true; if(apiClient == null) throw new IllegalArgumentException("null API client"); // Get the server configuration using the REST API if(cache.isServersEnabled()) { ret = false; ...
java
public boolean syncLabels(NewRelicCache cache) { boolean ret = true; if(apiClient == null) throw new IllegalArgumentException("null API client"); // Get the label configuration using the REST API if(cache.isApmEnabled() || cache.isSyntheticsEnabled()) { ...
java
public boolean syncDashboards(NewRelicCache cache) { boolean ret = true; if(apiClient == null) throw new IllegalArgumentException("null API client"); // Get the dashboard configuration using the REST API if(cache.isInsightsEnabled()) { ret = false; ...
java
public static String stringFor(int m) { switch (m) { case CUFFT_SUCCESS : return "CUFFT_SUCCESS"; case CUFFT_INVALID_PLAN : return "CUFFT_INVALID_PLAN"; case CUFFT_ALLOC_FAILED : return "CUFFT_ALLOC_FAILED"; case CUFFT_INVALID_TYPE : return "CUF...
java
protected SocialProfile parseProfile(Map<String, Object> props) { if (!props.containsKey("id")) { throw new IllegalArgumentException("No id in profile"); } SocialProfile profile = SocialProfile.with(props) .displayName("name") .first("first_name") .last("last_name") .id...
java
private void parsePackageClasses(String name, List<JavaFileObject> files, ListBuffer<JCCompilationUnit> trees, List<String> excludedPackages) throws IOException { if (excludedPackages.contains(name)) { return; } docenv.notice("main.Loa...
java
private static boolean isValidJavaClassFile(String file) { if (!file.endsWith(".class")) return false; String clazzName = file.substring(0, file.length() - ".class".length()); return isValidClassName(clazzName); }
java
public void enter(Symbol sym, Scope s, Scope origin, boolean staticallyImported) { Assert.check(shared == 0); if (nelems * 3 >= hashMask * 2) dble(); int hash = getIndex(sym.name); Entry old = table[hash]; if (old == null) { old = sentinel; nel...
java
@Override public void reportDependence(Symbol from, Symbol to) { // Capture dependencies between the packages. deps.collect(from.packge().fullname, to.packge().fullname); }
java
public void put(Object tree, int flags, int startPc, int endPc) { entries.append(new CRTEntry(tree, flags, startPc, endPc)); }
java
public int writeCRT(ByteBuffer databuf, Position.LineMap lineMap, Log log) { int crtEntries = 0; // compute source positions for the method new SourceComputer().csp(methodTree); for (List<CRTEntry> l = entries.toList(); l.nonEmpty(); l = l.tail) { CRTEntry entry = l.head;...
java
private String getTypes(int flags) { String types = ""; if ((flags & CRT_STATEMENT) != 0) types += " CRT_STATEMENT"; if ((flags & CRT_BLOCK) != 0) types += " CRT_BLOCK"; if ((flags & CRT_ASSIGNMENT) != 0) types += " CRT_ASSIGNMENT"; if ((flags & CRT_FLOW_CONT...
java
@GET @Path("{id}") @RolesAllowed({"ROLE_ADMIN"}) public Response read(@PathParam("id") Long id) { checkNotNull(id); return Response.ok(userService.getById(id)).build(); }
java
@GET @Path("search") @RolesAllowed({"ROLE_ADMIN"}) public Response search(@QueryParam("email") String email, @QueryParam("username") String username, @QueryParam("pageSize") @DefaultValue("10") int pageSize, @QueryParam("cursorKey") String...
java
@GET @RolesAllowed({"ROLE_ADMIN"}) public Response readPage(@QueryParam("pageSize") @DefaultValue("10") int pageSize, @QueryParam("cursorKey") String cursorKey) { CursorPage<DUser> page = userService.readPage(pageSize, cursorKey); return Response.ok(page).build(); }
java
@POST @Path("{id}/username") @RolesAllowed({"ROLE_ADMIN"}) public Response changeUsername(@PathParam("id") Long id, UsernameRequest usernameRequest) { checkUsernameFormat(usernameRequest.username); userService.changeUsername(id, usernameRequest.getUsername()); return Response.ok(id).build(); }
java
@POST @Path("{id}/password") @PermitAll public Response changePassword(@PathParam("id") Long userId, PasswordRequest request) { checkNotNull(userId); checkNotNull(request.getToken()); checkPasswordFormat(request.getNewPassword()); boolean isSuccess = userService.confirmResetPasswordUsingToken(use...
java
@POST @Path("password/reset") @PermitAll public Response resetPassword(PasswordRequest request) { checkNotNull(request.getEmail()); userService.resetPassword(request.getEmail()); return Response.noContent().build(); }
java
@POST @Path("{id}/account/confirm") @PermitAll public Response confirmAccount(@PathParam("id") Long userId, AccountRequest request) { checkNotNull(userId); checkNotNull(request.getToken()); boolean isSuccess = userService.confirmAccountUsingToken(userId, request.getToken()); return isSuccess ? Re...
java
@POST @Path("{id}/account/resend") @PermitAll public Response resendVerifyAccountEmail(@PathParam("id") Long userId) { checkNotNull(userId); boolean isSuccess = userService.resendVerifyAccountEmail(userId); return isSuccess ? Response.noContent().build() : Response.status(Response.Status.BAD_REQUEST)...
java
@POST @Path("{id}/email") @RolesAllowed({"ROLE_ADMIN"}) public Response changeEmail(@PathParam("id") Long userId, EmailRequest request) { checkNotNull(userId); checkEmailFormat(request.getEmail()); boolean isSuccess = userService.changeEmailAddress(userId, request.getEmail()); return isSuccess ? ...
java
@POST @Path("{id}/email/confirm") @PermitAll public Response confirmChangeEmail(@PathParam("id") Long userId, EmailRequest request) { checkNotNull(userId); checkNotNull(request.getToken()); boolean isSuccess = userService.confirmEmailAddressChangeUsingToken(userId, request.getToken()); return isS...
java
public static Protocol createInstance(ProtocolVersion version, SocketManager socketManager) { switch (version) { case _63: return new Protocol63(socketManager); case _72: return new Protocol72(socketManager); case _73: ...
java
public void prepareParameters(Map<String, Object> extra) { if (paramConfig == null) return; for (ParamConfig param : paramConfig) { param.prepareParameter(extra); } }
java
private FieldDoc getFieldDoc(Configuration config, Tag tag, String name) { if (name == null || name.length() == 0) { //Base case: no label. if (tag.holder() instanceof FieldDoc) { return (FieldDoc) tag.holder(); } else { // If the value tag doe...
java
@Constructed public void constructed() { Context context = factory.enterContext(); try { scope = new ImporterTopLevel(context); } finally { Context.exit(); } Container container = Jaguar.component(Container.class); Object store = container.component(container.contexts().get(Application.class))....
java
@Activated public void activated() { logger.info("Importing core packages ['org.eiichiro.gig', 'org.eiichiro.bootleg', 'org.eiichiro.jaguar', 'org.eiichiro.jaguar.deployment'] into JavaScript context"); Context context = factory.enterContext(); try { context.evaluateString(scope, "importPackage(Packages.or...
java
public void load(String file) { Context context = factory.enterContext(); try { URL url = Thread.currentThread().getContextClassLoader().getResource(file); if (url == null) { logger.debug("Configuration [" + file + "] does not exist"); return; } File f = new File(url.getPath()); ...
java
public <T> void set(String key, T value) { Preconditions.checkArgument(key != null && !key.isEmpty(), "Parameter 'key' must not be [" + key + "]"); values.put(key, value); scope.put(key, scope, value); }
java
protected static char calcChecksumChar (@Nonnull final String sMsg, @Nonnegative final int nLength) { ValueEnforcer.notNull (sMsg, "Msg"); ValueEnforcer.isBetweenInclusive (nLength, "Length", 0, sMsg.length ()); return asChar (calcChecksum (sMsg.toCharArray (), nLength)); }
java
protected char scanSurrogates() { if (surrogatesSupported && Character.isHighSurrogate(ch)) { char high = ch; scanChar(); if (Character.isLowSurrogate(ch)) { return high; } ch = high; } return 0; }
java
@Nonnull public static EValidity validateMessage (@Nullable final String sMsg) { final int nLen = StringHelper.getLength (sMsg); if (nLen >= 7 && nLen <= 8) if (AbstractUPCEAN.validateMessage (sMsg).isValid ()) return EValidity.VALID; return EValidity.INVALID; }
java
protected String makeMethodString(ExecutableElement e) { StringBuilder result = new StringBuilder(); for (Modifier modifier : e.getModifiers()) { result.append(modifier.toString()); result.append(" "); } result.append(e.getReturnType().toString()); result....
java
protected String makeVariableString(VariableElement e) { StringBuilder result = new StringBuilder(); for (Modifier modifier : e.getModifiers()) { result.append(modifier.toString()); result.append(" "); } result.append(e.asType().toString()); result.append(...
java
public void add(Collection<Deployment> deployments) { for(Deployment deployment : deployments) this.deployments.put(deployment.getId(), deployment); }
java
Type generateReturnConstraints(JCTree tree, Attr.ResultInfo resultInfo, MethodType mt, InferenceContext inferenceContext) { InferenceContext rsInfoInfContext = resultInfo.checkContext.inferenceContext(); Type from = mt.getReturnType(); if (mt.getReturnType().containsAny(inferenceCont...
java
private void instantiateAsUninferredVars(List<Type> vars, InferenceContext inferenceContext) { ListBuffer<Type> todo = new ListBuffer<>(); //step 1 - create fresh tvars for (Type t : vars) { UndetVar uv = (UndetVar)inferenceContext.asUndetVar(t); List<Type> upperBounds = ...
java
Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, MethodSymbol spMethod, // sig. poly. method or null if none Resolve.MethodResolutionContext resolveContext, List<Type> a...
java
void checkWithinBounds(InferenceContext inferenceContext, Warner warn) throws InferenceException { MultiUndetVarListener mlistener = new MultiUndetVarListener(inferenceContext.undetvars); List<Type> saved_undet = inferenceContext.save(); try { while (true...
java
void checkCompatibleUpperBounds(UndetVar uv, InferenceContext inferenceContext) { List<Type> hibounds = Type.filter(uv.getBounds(InferenceBound.UPPER), new BoundFilter(inferenceContext)); Type hb = null; if (hibounds.isEmpty()) hb = syms.objectType; else if (h...
java
public JwwfServer bindWebapp(final Class<? extends User> user, String url) { if (!url.endsWith("/")) url = url + "/"; context.addServlet(new ServletHolder(new WebClientServelt(clientCreator)), url + ""); context.addServlet(new ServletHolder(new SkinServlet()), url + "__jwwf/skins/*"); ServletHolder fontServ...
java
public JwwfServer attachPlugin(JwwfPlugin plugin) { plugins.add(plugin); if (plugin instanceof IPluginGlobal) ((IPluginGlobal) plugin).onAttach(this); return this; }
java
public JwwfServer startAndJoin() { try { server.start(); server.join(); } catch (Exception e) { e.printStackTrace(); } return this; }
java
public static InputStream decode(DataBinder binder, InputStream stream) throws ParserConfigurationException, SAXException, IOException { XML.newSAXParser().parse(stream, new XDBHandler(binder)); return stream; }
java
void addBridge(DiagnosticPosition pos, MethodSymbol meth, MethodSymbol impl, ClassSymbol origin, boolean hypothetical, ListBuffer<JCTree> bridges) { make.at(pos); Type origType = types.memberType(origin.type, ...
java
void addBridges(DiagnosticPosition pos, ClassSymbol origin, ListBuffer<JCTree> bridges) { Type st = types.supertype(origin.type); while (st.hasTag(CLASS)) { // if (isSpecialization(st)) addBridges(pos, st.tsym, origin, bridges); st = types.supertype(st); } ...
java
public void visitTypeApply(JCTypeApply tree) { JCTree clazz = translate(tree.clazz, null); result = clazz; }
java
public JCTree translateTopLevelClass(JCTree cdef, TreeMaker make) { // note that this method does NOT support recursion. this.make = make; pt = null; return translate(cdef, null); }
java
protected void addAllProfilesLink(Content div) { Content linkContent = getHyperLink(DocPaths.PROFILE_OVERVIEW_FRAME, allprofilesLabel, "", "packageListFrame"); Content span = HtmlTree.SPAN(linkContent); div.addContent(span); }
java
public BiStream<T, U> throwIfNull(BiPredicate<? super T, ? super U> biPredicate, Supplier<? extends RuntimeException> e) { Predicate<T> predicate = (t) -> biPredicate.test(t, object); return nonEmptyStream(stream.filter(predicate), e); }
java
void setCurrent(TreePath path, DocCommentTree comment) { currPath = path; currDocComment = comment; currElement = trees.getElement(currPath); currOverriddenMethods = ((JavacTypes) types).getOverriddenMethods(currElement); AccessKind ak = AccessKind.PUBLIC; for (TreePath ...
java
public static <E extends Enum<E>> Flags<E> valueOf(Class<E> type, String values) { Flags<E> flags = new Flags<E>(type); for (String text : values.trim().split(MULTI_VALUE_SEPARATOR)) { flags.set(Enum.valueOf(type, text)); } return flags; }
java
public static void generate(ConfigurationImpl configuration, PackageDoc packageDoc, int profileValue) { ProfilePackageFrameWriter profpackgen; try { String profileName = Profile.lookup(profileValue).name; profpackgen = new ProfilePackageFrameWriter(configuration, pack...
java
public static <First, Second> Pair<First, Second> from( final First first, final Second second) { return new ImmutablePair<First, Second>(first, second); }
java
public static <CommonSuperType, First extends CommonSuperType, Second extends CommonSuperType> CommonSuperType[] toArray(final Pair<First, Second> pair, final Class<CommonSuperType> commonSuperType) { @SuppressWarnings("unchecked") final CommonSuperType[] array = (CommonSuperType[]) Array.newIns...
java
public static <CommonSuperType, First extends CommonSuperType, Second extends CommonSuperType> CommonSuperType[] toArray( final Pair<First, Second> pair, final CommonSuperType[] target, final int offset) { target[offset] = pair.getFirst(); target[offset + 1] = pair.getSecond(); ret...
java
@Override public void setFilter(Service.Filter filter) { _filter = _filter == null ? filter : new CompoundServiceFilter(filter, _filter); }
java
public void setFilters(List<Service.Filter> filters) { for (Service.Filter filter: filters) setFilter(filter); }
java
private Interaction findContext(String id) { for(int i= _currentInteractions.size() - 1; i >= 0; i--) { Interaction ia= (Interaction) _currentInteractions.get(i); if(ia.id.equals(id)) { return ia; } } return null; }
java
public List<RpcResponse> request(List<RpcRequest> reqList) { for (RpcRequest req : reqList) { this.reqList.add(req); } return null; }
java
public static KindName kindName(int kind) { switch (kind) { case PCK: return KindName.PACKAGE; case TYP: return KindName.CLASS; case VAR: return KindName.VAR; case VAL: return KindName.VAL; case MTH: return KindName.METHOD; default : throw new AssertionError("...
java
public static KindName absentKind(int kind) { switch (kind) { case ABSENT_VAR: return KindName.VAR; case WRONG_MTHS: case WRONG_MTH: case ABSENT_MTH: case WRONG_STATICNESS: return KindName.METHOD; case ABSENT_TYP: return KindName.CLASS; default...
java
@Nonnull @ReturnsMutableCopy public ICommonsList <IBANElementValue> parseToElementValues (@Nonnull final String sIBAN) { ValueEnforcer.notNull (sIBAN, "IBANString"); final String sRealIBAN = IBANManager.unifyIBAN (sIBAN); if (sRealIBAN.length () != m_nExpectedLength) throw new IllegalArgumentEx...
java
@Nonnull public static IBANCountryData createFromString (@Nonnull @Nonempty final String sCountryCode, @Nonnegative final int nExpectedLength, @Nullable final String sLayout, ...
java
protected final void setControllerPath(String path) { requireNonNull(path, "Global path cannot be change to 'null'"); if (!"".equals(path) && !"/".equals(path)) { this.controllerPath = pathCorrector.apply(path); } }
java
public void scan(final String[] packages) { LOGGER.info("Scanning packages {}:", ArrayUtils.toString(packages)); for (final String pkg : packages) { try { final String pkgFile = pkg.replace('.', '/'); final Enumeration<URL> urls = getRootClassloader().getResou...
java
int run(String[] args) { try { handleOptions(args); // the following gives consistent behavior with javac if (classes == null || classes.size() == 0) { if (options.help || options.version || options.fullVersion) return EXIT_OK; ...
java
public String[] getMetaKeywords(Profile profile) { if( configuration.keywords ) { String profileName = profile.name; return new String[] { profileName + " " + "profile" }; } else { return new String[] {}; } }
java
public R scan(Tree node, P p) { return (node == null) ? null : node.accept(this, p); }
java
public void setAuthorizedPatternArray(String[] patterns) { Matcher matcher; patterns: for (String pattern: patterns) { if ((matcher = IPv4_ADDRESS_PATTERN.matcher(pattern)).matches()) { short[] address = new short[4]; for (int i = 0; i < address.length; ++i) ...
java
private boolean findJavaSourceFiles(String[] args) { String prev = ""; for (String s : args) { if (s.endsWith(".java") && !prev.equals("-xf") && !prev.equals("-if")) { return true; } prev = s; } return false; }
java
private boolean findAtFile(String[] args) { for (String s : args) { if (s.startsWith("@")) { return true; } } return false; }
java
private String findLogLevel(String[] args) { for (String s : args) { if (s.startsWith("--log=") && s.length()>6) { return s.substring(6); } if (s.equals("-verbose")) { return "info"; } } return "info"; }
java
private static boolean makeSureExists(File dir) { // Make sure the dest directories exist. if (!dir.exists()) { if (!dir.mkdirs()) { Log.error("Could not create the directory "+dir.getPath()); return false; } } return true; }
java
private static void checkPattern(String s) throws ProblemException { // Package names like foo.bar.gamma are allowed, and // package names suffixed with .* like foo.bar.* are // also allowed. Pattern p = Pattern.compile("[a-zA-Z_]{1}[a-zA-Z0-9_]*(\\.[a-zA-Z_]{1}[a-zA-Z0-9_]*)*(\\.\\*)?+"...
java
private static void checkFilePattern(String s) throws ProblemException { // File names like foo/bar/gamma/Bar.java are allowed, // as well as /bar/jndi.properties as well as, // */bar/Foo.java Pattern p = null; if (File.separatorChar == '\\') { p = Pattern.compile("\\...
java
private static boolean hasOption(String[] args, String option) { for (String a : args) { if (a.equals(option)) return true; } return false; }
java
private static void rewriteOptions(String[] args, String option, String new_option) { for (int i=0; i<args.length; ++i) { if (args[i].equals(option)) { args[i] = new_option; } } }
java
private static File findDirectoryOption(String[] args, String option, String name, boolean needed, boolean allow_dups, boolean create) throws ProblemException, ProblemException { File dir = null; for (int i = 0; i<args.length; ++i) { if (args[i].equals(option)) { if (...
java
private static boolean shouldBeFollowedByPath(String o) { return o.equals("-s") || o.equals("-h") || o.equals("-d") || o.equals("-sourcepath") || o.equals("-classpath") || o.equals("-cp") || o.equals("-bootclasspath") || ...
java
private static String[] addSrcBeforeDirectories(String[] args) { List<String> newargs = new ArrayList<String>(); for (int i = 0; i<args.length; ++i) { File dir = new File(args[i]); if (dir.exists() && dir.isDirectory()) { if (i == 0 || !shouldBeFollowedByPath(args...
java
private static void checkSrcOption(String[] args) throws ProblemException { Set<File> dirs = new HashSet<File>(); for (int i = 0; i<args.length; ++i) { if (args[i].equals("-src")) { if (i+1 >= args.length) { throw new ProblemException("You have to ...
java
private static File findFileOption(String[] args, String option, String name, boolean needed) throws ProblemException, ProblemException { File file = null; for (int i = 0; i<args.length; ++i) { if (args[i].equals(option)) { if (file != null) { thro...
java
public static boolean findBooleanOption(String[] args, String option) { for (int i = 0; i<args.length; ++i) { if (args[i].equals(option)) return true; } return false; }
java
public static int findNumberOption(String[] args, String option) { int rc = 0; for (int i = 0; i<args.length; ++i) { if (args[i].equals(option)) { if (args.length > i+1) { rc = Integer.parseInt(args[i+1]); } } } ...
java