code
stringlengths
73
34.1k
label
stringclasses
1 value
public static ApruveResponse<SubscriptionAdjustment> get( String subscriptionId, String adjustmentId) { return ApruveClient.getInstance().get( getSubscriptionAdjustmentsPath(subscriptionId) + adjustmentId, SubscriptionAdjustment.class); }
java
public static ApruveResponse<List<SubscriptionAdjustment>> getAllAdjustments( String subscriptionId) { return ApruveClient.getInstance().index( getSubscriptionAdjustmentsPath(subscriptionId), new GenericType<List<SubscriptionAdjustment>>() { }); }
java
public ApruveResponse<SubscriptionAdjustmentCreateResponse> create( String subscriptionId) { return ApruveClient.getInstance().post( getSubscriptionAdjustmentsPath(subscriptionId), this, SubscriptionAdjustmentCreateResponse.class); }
java
public static ApruveResponse<SubscriptionAdjustmentDeleteResponse> delete( String subscriptionId, String adjustmentId) { return ApruveClient.getInstance().delete( getSubscriptionAdjustmentsPath(subscriptionId) + adjustmentId, SubscriptionAdjustmentDeleteResponse.class); }
java
public String wrap(String text) { StringBuilder sb = new StringBuilder(); int continuationLength = continuation.length(); int currentPosition = 0; for (String word : text.split(" ")) { String lastWord; int wordLength = word.length(); if (currentPosit...
java
public void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e, AnnotationMirror a, AnnotationValue v) { JavaFileObject oldSource = null; JavaFileObject newSource = null; JCDiagnostic.DiagnosticPosition pos = null; JavacElements elemUtils = processingEnv...
java
public void addWhereClause(FreemarkerWhereClause freemarkerWhereClause) { String outputBody = freemarkerWhereClause.getOutputBody(); if (StringUtils.isNotBlank(outputBody)) freemarkerWhereClauses.add(outputBody); }
java
public static Object invoke(Object object, String methodName, Object ... parameters) { Method method = getMethodThatMatchesParameters(object.getClass(), methodName, parameters); if (method != null) { try { return method.invoke(object, parameters); } catch (IllegalAccessException e) { throw new Runtim...
java
public byte[] getContents(FileColumn[] columns, List<String[]> lines) throws IOException { byte[] ret; // Excel spreadsheet if(format.isExcel()) { ret = getExcelOutput(columns, lines); } else // Assume it's a CSV file { ret = g...
java
private byte[] getCSVOutput(List<String[]> lines) { StringWriter writer = new StringWriter(); csv = new CSVWriter(writer, delimiter.separator().charAt(0)); for(int i = 0; i < lines.size(); i++) { csv.writeNext((String[])lines.get(i), quotes); } // The con...
java
private byte[] getExcelOutput(FileColumn[] columns, List<String[]> lines) throws IOException { // Create the workbook baos = new ByteArrayOutputStream(1024); if(existing != null) workbook = Workbook.createWorkbook(format, baos, existing); else workbook = Workb...
java
public MainFrame put(Widget widget) { widget.addTo(user); content = widget != null ? widget.getID() : -1; this.sendElement(); return this; }
java
public static <T extends Comparable<? super T>> boolean greaterThanOrEquals(final T object, final T other) { return JudgeUtils.greaterThanOrEquals(object, other); }
java
public static <T extends Comparable<? super T>> boolean greaterThan(final T object, final T other) { return JudgeUtils.greaterThan(object, other); }
java
public static <T extends Comparable<? super T>> boolean lessThanOrEquals(final T object, final T other) { return JudgeUtils.lessThanOrEquals(object, other); }
java
public static <T extends Comparable<? super T>> boolean lessThan(final T object, final T other) { return JudgeUtils.lessThan(object, other); }
java
public static <T extends Comparable<? super T>> void ascDeep(final T[] comparableArray) { if (ArrayUtils.isEmpty(comparableArray)) { return; } ascByReflex(comparableArray); }
java
public static <T extends Comparable<? super T>> void descDeep(final T[] comparableArray) { if (ArrayUtils.isEmpty(comparableArray)) { return; } descByReflex(comparableArray); }
java
public static <T> void reverse(final T array) { if (ArrayUtils.isArray(array)) { int mlength = Array.getLength(array) - 1; Object temp = null; for (int i = 0, j = mlength; i < mlength; i++, j--) { Object arg0 = Array.get(array, i); Object arg1...
java
@Override public void contextInitialized(ServletContextEvent event) { _registry.put(INSTANCE, new Pair<Service, Persistence>(this, null)); _context = event.getServletContext(); _application = _context.getContextPath(); _logger.config("application: " + _application); if (_app...
java
final public void plugInterfaces(RobotAction newControl, RobotStatus newStatus, WorldInfo newWorld) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new GamePermission("connectBank")); } control = newControl; info = newStatus; world = newWorld; }
java
final public void setTeamId(int newId) { if (teamId != -1) { throw new IllegalStateException("Team Id cannot be modified"); } SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new GamePermission("setTeamId")); } teamId = newId; }
java
public static String stringFor(int m) { if (m == CUFFT_COMPATIBILITY_NATIVE) { return "CUFFT_COMPATIBILITY_NATIVE"; } if ((m & CUFFT_COMPATIBILITY_FFTW_ALL) == CUFFT_COMPATIBILITY_FFTW_ALL) { return "CUFFT_COMPATIBILITY_FFTW_ALL"; } ...
java
static public String getFormattedBytes(long bytes, String units, String format) { double num = bytes; String[] prefix = {"", "K", "M", "G", "T"}; int count = 0; while(num >= 1024.0) { num = num/1024.0; ++count; } DecimalFormat f = new...
java
static public String getFormattedDate(long dt) { String ret = ""; SimpleDateFormat df = null; try { if(dt > 0) { df = formatPool.getFormat(DATE_FORMAT); df.setTimeZone(DateUtilities.getCurrentTimeZone()); ret = ...
java
static public String getLongFormattedDays(long dt) { StringBuffer ret = new StringBuffer(); long days = dt/86400000L; long millis = dt-(days*86400000L); if(days > 0) { ret.append(Long.toString(days)); ret.append(" day"); if(days > 1) ...
java
public ClassDocImpl loadClass(String name) { try { ClassSymbol c = reader.loadClass(names.fromString(name)); return getClassDoc(c); } catch (CompletionFailure ex) { chk.completionError(null, ex); return null; } }
java
protected void buildProfileIndexFile(String title, boolean includeScript) throws IOException { String windowOverview = configuration.getText(title); Content body = getBody(includeScript, getWindowTitle(windowOverview)); addNavigationBarHeader(body); addOverviewHeader(body); addIn...
java
protected void buildProfilePackagesIndexFile(String title, boolean includeScript, String profileName) throws IOException { String windowOverview = configuration.getText(title); Content body = getBody(includeScript, getWindowTitle(windowOverview)); addNavigationBarHeader(body); ...
java
protected void addIndex(Content body) { addIndexContents(profiles, "doclet.Profile_Summary", configuration.getText("doclet.Member_Table_Summary", configuration.getText("doclet.Profile_Summary"), configuration.getText("doclet.profiles")), body); }
java
protected void addProfilePackagesIndex(Content body, String profileName) { addProfilePackagesIndexContents(profiles, "doclet.Profile_Summary", configuration.getText("doclet.Member_Table_Summary", configuration.getText("doclet.Profile_Summary"), configuration.getTe...
java
protected void addIndexContents(Profiles profiles, String text, String tableSummary, Content body) { if (profiles.getProfileCount() > 0) { HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.indexHeader); addAllClassesLink(div); addAllPack...
java
protected void addProfilePackagesIndexContents(Profiles profiles, String text, String tableSummary, Content body, String profileName) { HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.indexHeader); addAllClassesLink(div); addAllPackagesLink(div); addA...
java
public Iterable<DContact> queryByBirthday(Object parent, java.util.Date birthday) { return queryByField(parent, DContactMapper.Field.BIRTHDAY.getFieldName(), birthday); }
java
public Iterable<DContact> queryByCompanyName(Object parent, java.lang.String companyName) { return queryByField(parent, DContactMapper.Field.COMPANYNAME.getFieldName(), companyName); }
java
public Iterable<DContact> queryByEmail(Object parent, java.lang.String email) { return queryByField(parent, DContactMapper.Field.EMAIL.getFieldName(), email); }
java
public Iterable<DContact> queryByFacebook(Object parent, java.lang.String facebook) { return queryByField(parent, DContactMapper.Field.FACEBOOK.getFieldName(), facebook); }
java
public Iterable<DContact> queryByHomePhone(Object parent, java.lang.String homePhone) { return queryByField(parent, DContactMapper.Field.HOMEPHONE.getFieldName(), homePhone); }
java
public Iterable<DContact> queryByLatitude(Object parent, java.lang.Float latitude) { return queryByField(parent, DContactMapper.Field.LATITUDE.getFieldName(), latitude); }
java
public Iterable<DContact> queryByLinkedIn(Object parent, java.lang.String linkedIn) { return queryByField(parent, DContactMapper.Field.LINKEDIN.getFieldName(), linkedIn); }
java
public Iterable<DContact> queryByLongitude(Object parent, java.lang.Float longitude) { return queryByField(parent, DContactMapper.Field.LONGITUDE.getFieldName(), longitude); }
java
public Iterable<DContact> queryByMobilePhone(Object parent, java.lang.String mobilePhone) { return queryByField(parent, DContactMapper.Field.MOBILEPHONE.getFieldName(), mobilePhone); }
java
public Iterable<DContact> queryByOtherEmail(Object parent, java.lang.String otherEmail) { return queryByField(parent, DContactMapper.Field.OTHEREMAIL.getFieldName(), otherEmail); }
java
public Iterable<DContact> queryByOtherPhone(Object parent, java.lang.String otherPhone) { return queryByField(parent, DContactMapper.Field.OTHERPHONE.getFieldName(), otherPhone); }
java
public Iterable<DContact> queryByPrimaryCustomIndex(Object parent, java.lang.String primaryCustomIndex) { return queryByField(parent, DContactMapper.Field.PRIMARYCUSTOMINDEX.getFieldName(), primaryCustomIndex); }
java
public Iterable<DContact> queryBySecondaryCustomIndex(Object parent, java.lang.String secondaryCustomIndex) { return queryByField(parent, DContactMapper.Field.SECONDARYCUSTOMINDEX.getFieldName(), secondaryCustomIndex); }
java
public Iterable<DContact> queryByTags(Object parent, java.lang.Object tags) { return queryByField(parent, DContactMapper.Field.TAGS.getFieldName(), tags); }
java
public Iterable<DContact> queryByTwitter(Object parent, java.lang.String twitter) { return queryByField(parent, DContactMapper.Field.TWITTER.getFieldName(), twitter); }
java
public DContact findByUniqueTag(Object parent, java.lang.String uniqueTag) { return queryUniqueByField(parent, DContactMapper.Field.UNIQUETAG.getFieldName(), uniqueTag); }
java
public Iterable<DContact> queryByWebPage(Object parent, java.lang.String webPage) { return queryByField(parent, DContactMapper.Field.WEBPAGE.getFieldName(), webPage); }
java
public Iterable<DContact> queryByWorkPhone(Object parent, java.lang.String workPhone) { return queryByField(parent, DContactMapper.Field.WORKPHONE.getFieldName(), workPhone); }
java
public static int string2int(String s, int radix) throws NumberFormatException { if (radix == 10) { return Integer.parseInt(s, radix); } else { char[] cs = s.toCharArray(); int limit = Integer.MAX_VALUE / (radix/2); int n = 0; for (int ...
java
public static long string2long(String s, int radix) throws NumberFormatException { if (radix == 10) { return Long.parseLong(s, radix); } else { char[] cs = s.toCharArray(); long limit = Long.MAX_VALUE / (radix/2); long n = 0; for (int i...
java
public static String getResponseMaybe(SocketManager socketManager, String message) throws IOException { try { return socketManager.sendAndWait(message); } catch (ResponseTimeoutException e) { /* * If the timeout was hit in the previous sen...
java
public static String parsePropertyName(Method method) { String name = method.getName(); int i = 0; if (name.startsWith("get") || name.startsWith("set")) { i = 3; } else if (name.startsWith("is")) { i = 2; } return Character.toLowerCase(name.charAt(i)) + name.substring(i + 1); }
java
public static <E> OptionalFunction<Selection<Method>, E> invoke(Object... args) { return OptionalFunction.of(selection -> factory.createInvoker(selection.result()).on(selection.target()).withArgs(args)); }
java
public static <E> OptionalFunction<Selection<Constructor<?>>, E> instantiate(Object... args) { return OptionalFunction.of(selection -> factory.createInvoker(selection.result()).withArgs(args)); }
java
public static <E> OptionalFunction<Selection<Field>, E> getValue() { return OptionalFunction.of(selection -> factory.createHandler(selection.result()).on(selection.target()).getValue()); }
java
public static Consumer<Selection<Field>> setValue(Object newValue) { return selection -> factory.createHandler(selection.result()).on(selection.target()).setValue(newValue); }
java
public Object users() { return new ArrayList<Map<String, Object>>() {{ add(new HashMap<String, Object>() {{ put("username","testUser1"); put("groups", Arrays.asList("group1")); put("password","thisMechWillChange"); }}); ...
java
@Override public boolean nextKeyValue() throws IOException, InterruptedException { if (!deserializer.hasNextEvent()) { return false; } else { value = deserializer.getNextEvent(); key = value.getEventDateTime(); return true; } }
java
@Override public float getProgress() throws IOException, InterruptedException { if (start == end) { return 0.0f; } else { return Math.min(1.0f, (pos - start) / (float) (end - start)); } }
java
public void addAttr(HtmlAttr attrName, String attrValue) { if (attrs.isEmpty()) attrs = new LinkedHashMap<HtmlAttr,String>(3); attrs.put(nullCheck(attrName), escapeHtmlChars(attrValue)); }
java
public void addContent(Content tagContent) { if (tagContent instanceof ContentBuilder) { for (Content content: ((ContentBuilder)tagContent).contents) { addContent(content); } } else if (tagContent == HtmlTree.EMPTY || tagContent.isValid()) { if...
java
public static HtmlTree A_NAME(String name, Content body) { HtmlTree htmltree = HtmlTree.A_NAME(name); htmltree.addContent(nullCheck(body)); return htmltree; }
java
public static HtmlTree A_NAME(String name) { HtmlTree htmltree = new HtmlTree(HtmlTag.A); htmltree.addAttr(HtmlAttr.NAME, nullCheck(name)); return htmltree; }
java
public static HtmlTree FRAME(String src, String name, String title, String scrolling) { HtmlTree htmltree = new HtmlTree(HtmlTag.FRAME); htmltree.addAttr(HtmlAttr.SRC, nullCheck(src)); htmltree.addAttr(HtmlAttr.NAME, nullCheck(name)); htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title)); ...
java
public static HtmlTree FRAME(String src, String name, String title) { return FRAME(src, name, title, null); }
java
public static HtmlTree FRAMESET(String cols, String rows, String title, String onload) { HtmlTree htmltree = new HtmlTree(HtmlTag.FRAMESET); if (cols != null) htmltree.addAttr(HtmlAttr.COLS, cols); if (rows != null) htmltree.addAttr(HtmlAttr.ROWS, rows); htmltree....
java
public static HtmlTree TABLE(HtmlStyle styleClass, int border, int cellPadding, int cellSpacing, String summary, Content body) { HtmlTree htmltree = new HtmlTree(HtmlTag.TABLE, nullCheck(body)); if (styleClass != null) htmltree.addStyle(styleClass); htmltree.addAttr(HtmlA...
java
public static String execute(final boolean withResponse, final String... command) throws IOException { final List<String> commands = new ArrayList<>(); commands.add("bash"); commands.add("-c"); commands.addAll(Arrays.asList(command)); String response = ""; final ProcessBuilder pb = new ProcessBuilder(co...
java
private static int checkResult(int result) { if (exceptionsEnabled && result != cufftResult.CUFFT_SUCCESS) { throw new CudaException(cufftResult.stringFor(result)); } return result; }
java
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return connectionHandler.remoteInvocation(proxy, method, args); }
java
public static ImageReader getImageReader(final Object sourceImage) throws IOException { ImageInputStream imageInputStream = ImageIO.createImageInputStream(sourceImage); Iterator<ImageReader> imageReaders = ImageIO.getImageReaders(imageInputStream); ImageReader destinationImageReader = null;...
java
public static ImageReader getImageReaderFromHttpImage(final String sourceImageHttpURL) throws IOException { InputStream inputStream = new URL(sourceImageHttpURL).openConnection().getInputStream(); return getImageReader(inputStream); }
java
public <T> T get(Key<T> key) { checkState(ht); Object o = ht.get(key); if (o instanceof Factory<?>) { Factory<?> fac = (Factory<?>)o; o = fac.make(this); if (o instanceof Factory<?>) throw new AssertionError("T extends Context.Factory"); ...
java
protected void configure(Properties p) { _properties = p; _host = (String)p.remove(HOST); if (_host == null) throw new NoSuchElementException(HOST); _path = (String)p.remove(PATH); if (_path == null) throw new NoSuchElementException(PATH); }
java
public <T> RemoteService.Response call(long pause, Functor<T, String> reporter) throws Exception { String message = null; while (true) { RemoteService.Response response = _caller.call(); String news = response.params.get("message"); if (news == null) { ...
java
public synchronized V invalidate(K key) { Singleton<V> singleton = _cache.get(key); if (singleton != null) { return singleton.clear(); } else { return null; } }
java
public List<Attribute.Compound> getRawAttributes() { return (metadata == null) ? List.<Attribute.Compound>nil() : metadata.getDeclarationAttributes(); }
java
public List<Attribute.TypeCompound> getRawTypeAttributes() { return (metadata == null) ? List.<Attribute.TypeCompound>nil() : metadata.getTypeAttributes(); }
java
public ClassSymbol enclClass() { Symbol c = this; while (c != null && ((c.kind & TYP) == 0 || !c.type.hasTag(CLASS))) { c = c.owner; } return (ClassSymbol)c; }
java
public static int floor(int n, int m) { return n >= 0 ? (n / m) * m : ((n - m + 1) / m) * m; }
java
public static int ceiling(int n, int m) { return n >= 0 ? ((n + m - 1) / m) * m : (n / m) * m; }
java
public void add(Collection<PluginComponent> components) { for(PluginComponent component : components) this.components.put(component.getId(), component); }
java
private void checkIndex() throws IOException { boolean isUpToDate = true; if (!isUpToDate()) { closeFile(); isUpToDate = false; } if (zipRandomFile != null || isUpToDate) { lastReferenceTimeStamp = System.currentTimeMillis(); return; ...
java
synchronized Entry getZipIndexEntry(RelativePath path) { try { checkIndex(); DirectoryEntry de = directories.get(path.dirname()); String lookFor = path.basename(); return (de == null) ? null : de.getEntry(lookFor); } catch (IOException e) { ...
java
public synchronized com.sun.tools.javac.util.List<String> getFiles(RelativeDirectory path) { try { checkIndex(); DirectoryEntry de = directories.get(path); com.sun.tools.javac.util.List<String> ret = de == null ? null : de.getFiles(); if (ret == null) { ...
java
public synchronized boolean contains(RelativePath path) { try { checkIndex(); return getZipIndexEntry(path) != null; } catch (IOException e) { return false; } }
java
public static List<Event> fromFile(final File file) throws IOException, ClassNotFoundException { return fromInputStream(new FileInputStream(file)); }
java
public boolean add(String field, List<RDFNode> result) { this.result.put(field, result); return true; }
java
public boolean add(String field, RDFNode result) { if (!this.result.containsKey(field)) { this.result.put(field, new ArrayList<RDFNode>()); } this.result.get(field).add(result); return true; }
java
public Manifest getManifest(MavenProject project, ManifestConfiguration config) throws ManifestException, DependencyResolutionRequiredException { // Added basic entries Manifest m = new Manifest(); Manifest.Attribute buildAttr = new Manifest.Attribute("Built-By", System.getProperty("user.name"))...
java
@SuppressWarnings("unchecked") public Map marshal() { HashMap map = new HashMap(); map.put("jsonrpc", "2.0"); if (id != null) map.put("id", id); if (error != null) map.put("error", error.toMap()); else map.put("result", result); re...
java
public static void scan(ServletContext c, Set<String> jars, Functor<Void, ServiceModule>collector, Logger logger) { for (String j : jars) { logger.config("... " + j); try (JarInputStream jis = new JarInputStream(j.startsWith("/") ? c.getResourceAsStream(j) : new URL(j).openStream())) { ...
java
public void writeToJsonGenerator(final JsonGenerator gen) throws IOException { // writes '{eventName:<name>,payload:{<data>}}' --it's kind of silly but ultimately inconsequential to nest them like this. gen.writeStartObject(); gen.writeStringField("eventName", eventName); gen.writeFi...
java
public synchronized boolean waitForValidValues() throws IOException, FileNotFoundException { for (int tries = 0; tries < 50; tries++) { lock(); getValues(); unlock(); if (containsPortInfo) { Log.debug("Found valid values in port file after waiting ...
java
public synchronized boolean stillMyValues() throws IOException, FileNotFoundException { for (;;) { try { lock(); getValues(); unlock(); if (containsPortInfo) { if (serverPort == myServerPort && ...
java
@SuppressWarnings("unchecked") public static <T> T instantiateDefault(Class<T> someClass) { if (someClass.isArray()) { return (T) Array.newInstance(someClass.getComponentType(), 0); } else { if (boolean.class.equals(someClass) || Boolean.class.equals(someClass)) { ...
java
@SuppressWarnings("unchecked") public static <T> Optional<Class<T>> optional(String dependency) { try { return Optional.of((Class<T>) Class.forName(dependency)); } catch (ClassNotFoundException | NoClassDefFoundError e) { return Optional.empty(); } }
java