code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static String getDisplayedTimezone(long startMillis, String localTimezone,
String eventTimezone) {
String tzDisplay = null;
if (!TextUtils.equals(localTimezone, eventTimezone)) {
// Figure out if this is in DST
TimeZone tz = Ti... | java |
private static boolean singleDayEvent(long startMillis, long endMillis, long localGmtOffset) {
if (startMillis == endMillis) {
return true;
}
// An event ending at midnight should still be a single-day event, so check
// time end-1.
int startDay = Time.getJulianDay(s... | java |
private static int isTodayOrTomorrow(Resources r, long dayMillis,
long currentMillis, long localGmtOffset) {
int startDay = Time.getJulianDay(dayMillis, localGmtOffset);
int currentDay = Time.getJulianDay(currentMillis, localGmtOffset);
int days = startD... | java |
public static Intent createEmailAttendeesIntent(Resources resources, String eventTitle,
String body, List<String> toEmails, List<String> ccEmails, String ownerAccount) {
List<String> toList = toEmails;
List<String> ccList = ccEmails;
if (toEmai... | java |
public static String getVersionCode(Context context) {
if (sVersion == null) {
try {
sVersion = context.getPackageManager().getPackageInfo(
context.getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
... | java |
private static int findNanpMatchEnd(CharSequence text, int startPos) {
/*
* A few interesting cases:
* 94043 # too short, ignore
* 123456789012 # too long, ignore
* +1 (650) 555-1212 # 11 digits, spaces... | java |
private static boolean spanWillOverlap(Spannable spanText, URLSpan[] spanList, int start,
int end) {
if (start == end) {
// empty span, ignore
return false;
}
for (URLSpan span : spanList) {
int existingStart = spanTe... | java |
private static int dayToUtilDay(int day) {
switch (day) {
case EventRecurrence.SU: return Calendar.SUNDAY;
case EventRecurrence.MO: return Calendar.MONDAY;
case EventRecurrence.TU: return Calendar.TUESDAY;
case EventRecurrence.WE: return Calendar.WEDNESDAY;
... | java |
protected static String reportURL(String type) throws EasyPostException {
try {
String urlType = URLEncoder.encode(type, "UTF-8").toLowerCase();
return String.format("%s/reports/%s/", EasyPost.API_BASE, urlType);
} catch (java.io.UnsupportedEncodingException e) {
throw new EasyPostException("U... | java |
public Item retrieveReference(String name, String value) throws EasyPostException {
return retrieveReference(name, value, null);
} | java |
private URI getOriginalUri(HttpServletRequest request) {
String requestUrl = request.getRequestURL().toString();
String incomingScheme = URI.create(requestUrl).getScheme();
String originalScheme = request.getHeader("X-Forwarded-Proto");
if (originalScheme != null && !incomingScheme.equals(originalScheme... | java |
private static byte[] hmacSha(String crypto, byte[] keyBytes, byte[] text) {
try {
Mac hmac;
hmac = Mac.getInstance(crypto);
SecretKeySpec macKey = new SecretKeySpec(keyBytes, "RAW");
hmac.init(macKey);
return hmac.doFinal(text);
} catch (Gener... | java |
public static int generateTOTP(byte[] key, long time, int digits, String crypto) {
byte[] msg = ByteBuffer.allocate(8).putLong(time).array();
byte[] hash = hmacSha(crypto, key, msg);
// put selected bytes into result int
int offset = hash[hash.length - 1] & 0xf;
int binary = (... | java |
@SuppressWarnings("unchecked")
public final List<RegisteredService> loadServices() {
logger.info("Loading Registered Services from: [ {} ]...", this.servicesConfigFile);
final List<RegisteredService> resolvedServices = new ArrayList<RegisteredService>();
try {
... | java |
public void init() throws Exception {
try {
unmarshalAndSetBackingMap();
}
//If we get to this point, the JSON file is well-formed, but its structure does not map into PersonDir backingMap generic type - fail fast.
catch (final ClassCastException ex) {
throw new B... | java |
@Override
public void onApplicationEvent(final ResourceChangeDetectingEventNotifier.ResourceChangedEvent resourceChangedEvent) {
try {
if (!resourceChangedEvent.getResourceUri().equals(this.personAttributesConfigFile.getURI())) {
//Not our resource. Just get out of here.
... | java |
void init() throws Throwable {
if (this.digestAlgorithmName != null) {
this.hashService.setHashAlgorithmName(this.digestAlgorithmName);
}
if (this.hashIterations > 0) {
this.hashService.setHashIterations(this.hashIterations);
}
} | java |
public OutlookMessage parseMsg(@Nonnull final InputStream msgFileStream)
throws IOException {
// the .msg file, like a file system, contains directories and documents within this directories
// we now gain access to the root node and recursively go through the complete 'filesystem'.
final OutlookMessage msg = ... | java |
private byte[] getBytesFromStream(final InputStream dstream)
throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final byte[] buffer = new byte[1024];
int read;
while ((read = dstream.read(buffer)) > 0) {
baos.write(buffer, 0, read);
}
return baos.toByteArray();
} | java |
public void setProperty(final OutlookMessageProperty msgProp) {
final String name = msgProp.getClazz();
final Object value = msgProp.getData();
if (name != null && value != null) {
switch (name) {
case "3701":
setSize(msgProp.getSize());
setData((byte[]) value);
break;
case "3704":
... | java |
private String getStringResource(String path) {
InputStream in = getClass().getResourceAsStream(path);
StringBuilder index = new StringBuilder();
char[] buffer = new char[1024];
int read = 0;
try(InputStreamReader reader = new InputStreamReader(in)){
while((read = reader.read(buffer... | java |
public Service getServiceObjectFromId(String id) {
log.fine("Return service object for " + id);
Service service = null;
for (Service s : services.getServices()) {
if (id.equals(s.getId())) {
return s;
}
}
return service;
} | java |
public File createGitRepository(String repositoryName) throws IOException {
RepositoryService service = new RepositoryService();
service.getClient().setOAuth2Token(oAuthToken);
Repository repository = new Repository();
repository.setName(repositoryName);
repository = service.crea... | java |
public static boolean hasChildNode(Node parentNode, String nodeName){
return getChildNode(parentNode, nodeName, null) != null ? true : false;
} | java |
public static Node getChildNode(Node parentNode, String name, String value){
List<Node> matchingChildren = getChildren(parentNode, name, value);
return (matchingChildren.size() > 0) ? matchingChildren.get(0) : null;
} | java |
public static Node getGrandchildNode(Node parentNode, String childNodeName, String grandChildNodeName, String grandChildNodeValue){
List<Node> matchingChildren = getChildren(parentNode, childNodeName, null);
for(Node child : matchingChildren){
Node matchingGrandCh... | java |
private static List<Node> getChildren(Node parentNode, String name, String value){
List<Node> childNodes = new ArrayList<Node>();
if(parentNode == null || name == null){
return childNodes;
}
if (parentNode.getNodeType() == Node.ELE... | java |
public static Node addChildNode(Document doc, Node parentNode, String childName, String childValue){
if(doc == null || parentNode == null || childName == null){
return null;
}
Node childNode = doc.createElement(childName);
if(childV... | java |
public static Node findOrAddChildNode(Document doc, Node parentNode, String childName, String childValue){
Node matchingChild = getChildNode(parentNode, childName, childValue);
return matchingChild != null ? matchingChild : addChildNode(doc, parentNode, childName, childValue);
} | java |
public WebElement waitForElement(By by) {
int attempts = 0;
int size = driver.findElements(by).size();
while (size == 0) {
size = driver.findElements(by).size();
if (attempts == MAX_ATTEMPTS) fail(String.format("Could not find %s after %d seconds",
... | java |
@Override
public String url() {
String url = "";
if (!StringUtils.isEmpty(baseUrl())) {
url = baseUrl() + path();
} else {
if (!StringUtils.isEmpty(properties.getProperty(Constants.DEFAULT_PROPERTY_URL))) {
url = properties.getProperty(Constants.DEFAUL... | java |
public static IDataSource create(JsonObject config) throws DataSourceCreationException {
String title = config.getAsJsonPrimitive("title").getAsString();
String description = config.getAsJsonPrimitive("description").getAsString();
String typeName = config.getAsJsonPrimitive("type").getAsString()... | java |
private IDataSource getDataSource(HttpServletRequest request) throws DataSourceNotFoundException {
String contextPath = request.getContextPath();
String requestURI = request.getRequestURI();
String path = contextPath == null
? requestURI
: requestURI.substring(co... | java |
public void addMetadata( final Model model )
{
final Resource datasetId = model.createResource( getDatasetURI() );
final Resource fragmentId = model.createResource( fragmentURL );
datasetId.addProperty( CommonResources.RDF_TYPE, CommonResources.VOID_DATASET );
datasetId.addProperty(... | java |
public void addControls( final Model model )
{
final URIBuilder pagedURL;
try {
pagedURL = new URIBuilder( fragmentURL );
}
catch ( URISyntaxException e ) {
throw new IllegalArgumentException( e );
}
final Resource fragmentId = model.createRes... | java |
private Triple toTriple(TripleID tripleId) {
return new Triple(
dictionary.getNode(tripleId.getSubject(), TripleComponentRole.SUBJECT),
dictionary.getNode(tripleId.getPredicate(), TripleComponentRole.PREDICATE),
dictionary.getNode(tripleId.getObject(), TripleComponentRole.OBJ... | java |
public ElasticsearchContainer withSecureSetting(String key, String value) {
securedKeys.put(key, value);
return this;
} | java |
public ElasticsearchContainer withPluginDir(Path pluginDir) {
if (pluginDir == null) {
return this;
}
// When we have a plugin dir, we need to mount it in the docker instance
this.pluginDir = createVolumeDirectory(true);
// We create the volume that will be needed f... | java |
public void start() {
Thread thread = new Thread(new LogCatCommandExecutor());
thread.setName(getClass().getSimpleName() + " logcat for " + device.getSerialNumber());
thread.start();
try {
sleep(500); // ignore old output that logcat feeds us
} catch (InterruptedExce... | java |
public static RGBColor rgb(int r, int g, int b) {
return new RGBColor(makeRgb(r, g, b));
} | java |
public double cur(Element elem, String prop, boolean force) {
if (JsUtils.isWindow(elem)) {
if ("width".equals(prop)) {
return getContentDocument(elem).getClientWidth();
}
if ("height".equals(prop)) {
return getContentDocument(elem).getClientHeight();
}
elem = GQuery.bo... | java |
public String curCSS(Element elem, String name, boolean force) {
if (elem == null) {
return "";
}
name = fixPropertyName(name);
// value defined in the element style
String ret = elem.getStyle().getProperty(name);
if (force) {
Element toDetach = null;
if (JsUtils.isDetached(e... | java |
private void fixInlineElement(Element e) {
if (e.getClientHeight() == 0 && e.getClientWidth() == 0
&& "inline".equals(curCSS(e, "display", true))) {
setStyleProperty(e, "display", "inline-block");
setStyleProperty(e, "width", "auto");
setStyleProperty(e, "height", "auto");
}
} | java |
public void setStyleProperty(Element e, String prop, String val) {
if (e == null || prop == null) {
return;
}
prop = fixPropertyName(prop);
// put it in lower-case only when all letters are upper-case, to avoid
// modifying already camelized properties
if (prop.matches("^[A-Z]+$")) {
... | java |
public String defaultDisplay(String tagName) {
String ret = elemdisplay.get(tagName);
if (ret == null) {
Element e = DOM.createElement(tagName);
Document.get().getBody().appendChild(e);
ret = curCSS(e, "display", false);
e.removeFromParent();
if (ret == null || ret.matches("(|none)... | java |
public void setItems(java.util.Collection<java.util.Map<String,AttributeValue>> items) {
if (items == null) {
this.items = null;
return;
}
java.util.List<java.util.Map<String,AttributeValue>> itemsCopy = new java.util.ArrayList<java.util.Map<String,AttributeValue>>(items... | java |
public void queueAnimation(final GQAnimation anim, final int duration) {
if (isOff()) {
anim.onStart();
anim.onComplete();
} else {
queue(anim.e, DEFAULT_NAME, new Function() {
public void cancel(Element e) {
Animation anim = (Animation) data(e, GQAnimation.ACTUAL_ANIMATION, ... | java |
public static String vendorProperty(String prop) {
return vendorPropNames.get(prop) != null ? vendorPropNames.get(prop) : prop;
} | java |
public Effects slideToggle(Function... f) {
return as(Effects).slideToggle(Speed.DEFAULT, f);
} | java |
private void initResultsTable(DeferredSelector[] dg, Benchmark... benchs) {
int numRows = dg.length;
grid = new FlexTable();
grid.addStyleName("resultstable");
RootPanel.get("results").clear();
RootPanel.get("results").add(grid);
grid.setText(0, 0, "Selector");
for (int i=0; i < benchs.leng... | java |
public Callbacks add(com.google.gwt.core.client.Callback<?, ?>... c) {
addAll((Object[]) c);
return this;
} | java |
public Callbacks fire(Object... o) {
if (!done) {
done = isOnce;
if (isMemory) {
memory = new ArrayList<>(Arrays.asList(o));
}
if (stack != null)
for (Object c : stack) {
if (!run(c, o) && stopOnFalse) {
break;
}
}
}
return this... | java |
public synchronized void save(String persistence) {
try {
createObjectMapper().writeValue(new File(persistence), tableList);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
} | java |
public ObjectMapper createObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
.setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY)
.setVisibility(PropertyAccessor.SETTER, JsonAutoDetect.Visibility.NONE)
... | java |
public void setSS(java.util.Collection<String> sS) {
if (sS == null) {
this.sS = null;
return;
}
java.util.List<String> sSCopy = new java.util.ArrayList<String>(sS.size());
sSCopy.addAll(sS);
this.sS = sSCopy;
} | java |
public void setNS(java.util.Collection<String> nS) {
if (nS == null) {
this.nS = null;
return;
}
java.util.List<String> nSCopy = new java.util.ArrayList<String>(nS.size());
nSCopy.addAll(nS);
this.nS = nSCopy;
} | java |
public void setBS(java.util.Collection<java.nio.ByteBuffer> bS) {
if (bS == null) {
this.bS = null;
return;
}
java.util.List<java.nio.ByteBuffer> bSCopy = new java.util.ArrayList<java.nio.ByteBuffer>(bS.size());
bSCopy.addAll(bS);
this.bS = bSCopy;
} | java |
public static Promise when(Object... d) {
int l = d.length;
Promise[] p = new Promise[l];
for (int i = 0; i < l; i++) {
p[i] = makePromise(d[i]);
}
return when(p);
} | java |
protected void trigger(GwtEvent<?> e, Function callback, Element element) {
trigger(e, callback, element, eventBus);
} | java |
@Override
public Iterator<T> iterator() {
/*
* We make a copy of the allResults list to iterate over in order to
* avoid ConcurrentModificationExceptions caused by other methods
* loading more results into the list while someone iterates over it.
* This is a more... | java |
@Override
public List<T> subList(int arg0, int arg1) {
while ( allResults.size() < arg1 && nextResultsAvailable() ) {
moveNextResults();
}
return Collections.unmodifiableList(allResults.subList(arg0, arg1));
} | java |
@Override
public int indexOf(Object arg0) {
int indexOf = allResults.indexOf(arg0);
if ( indexOf >= 0 )
return indexOf;
while ( nextResultsAvailable() ) {
indexOf = nextResults.indexOf(arg0);
int size = allResults.size();
moveNextResults();
... | java |
private static boolean supportsTransform3d() {
if (transform == null) {
return false;
}
String rotate = "rotateY(1deg)";
divStyle.setProperty(transform, rotate);
rotate = divStyle.getProperty(transform);
return rotate != null && !rotate.isEmpty();
} | java |
public static String getVendorPropertyName(String prop) {
// we prefer vendor specific names by default
String vendorProp = JsUtils.camelize("-" + prefix + "-" + prop);
if (JsUtils.hasProperty(divStyle, vendorProp)) {
return vendorProp;
}
if (JsUtils.hasProperty(divStyle, prop)) {
retur... | java |
public static Transform getInstance(Element e, String initial) {
Transform t = GQuery.data(e, TRANSFORM);
if (t == null || initial != null) {
if (initial == null) {
initial = GQuery.getSelectorEngine().getDocumentStyleImpl().curCSS(e, transform, false);
}
t = new Transform(initial);
... | java |
private void parse(String s) {
if (s != null) {
for (MatchResult r = transformParseRegex.exec(s); r != null; r = transformParseRegex.exec(s)) {
setFromString(vendorProperty(r.getGroup(1)), r.getGroup(2));
}
}
} | java |
public void setFromString(String prop, String ...val) {
if (val.length == 1) {
String[] vals = val[0].split("[\\s,]+");
set(prop, vals);
} else {
set(prop, val);
}
} | java |
@SuppressWarnings("unchecked")
public T clearQueue(String name) {
for (Element e : elements()) {
queue(e, name, null).clear();
}
return (T) this;
} | java |
@SuppressWarnings("unchecked")
public T delay(int milliseconds, String name, Function... funcs) {
for (Element e : elements()) {
queue(e, name, new DelayFunction(e, name, milliseconds, funcs));
}
return (T) this;
} | java |
@SuppressWarnings("unchecked")
public T dequeue(String name) {
for (Element e : elements()) {
dequeueCurrentAndRunNext(e, name);
}
return (T) this;
} | java |
public Promise promise(final String name) {
final Promise.Deferred dfd = Deferred();
// This is the unique instance of the resolve function which will be added to each element.
final Function resolve = new Function() {
// Because it is an inner function, the counter cannot final outside the function
... | java |
public int queue(String name) {
Queue<?> q = isEmpty() ? null : queue(get(0), name, null);
return q == null ? 0 : q.size();
} | java |
@SuppressWarnings("unchecked")
public T queue(Function... funcs) {
for (Element e : elements()) {
for (Function f : funcs) {
queue(e, DEFAULT_NAME, f);
}
}
return (T) this;
} | java |
@SuppressWarnings("unchecked")
public T queue(final String name, Function... funcs) {
for (final Function f : funcs) {
for (Element e : elements()) {
queue(e, name, f);
}
}
return (T) this;
} | java |
@SuppressWarnings("unchecked")
public T queue(String name, Queue<?> queue) {
for (Element e : elements()) {
replacequeue(e, name, queue);
}
return (T) this;
} | java |
public void dequeueIfNotDoneYet(Element elem, String name, Object object) {
@SuppressWarnings("rawtypes")
Queue queue = queue(elem, name, null);
if (queue != null && object.equals(queue.peek())) {
dequeueCurrentAndRunNext(elem, name);
}
} | java |
public final Object f(Object... args) {
return dfd != null &&
(cache == CacheType.ALL ||
cache == CacheType.RESOLVED && dfd.promise().isResolved() ||
cache == CacheType.REJECTED && dfd.promise().isRejected())
? dfd.promise()
: new PromiseFunction() {
public void... | java |
@SuppressWarnings("unchecked")
public <T extends JavaScriptObject> T getArgumentJSO(int argIdx, int pos) {
return (T) getArgument(argIdx, pos, JavaScriptObject.class);
} | java |
public Object[] getArgumentArray(int idx) {
Object o = idx < 0 ? arguments : getArgument(idx);
if (o != null) {
return o.getClass().isArray() ? (Object[]) o : new Object[] {o};
} else if (idx == 0) {
return arguments;
}
return new Object[0];
} | java |
public <T> T getArgument(int idx, Class<? extends T> type) {
return getArgument(-1, idx, type);
} | java |
@SuppressWarnings("unchecked")
public <T> T getArgument(int argIdx, int pos, Class<? extends T> type) {
Object[] objs = getArgumentArray(argIdx);
Object o = objs.length > pos ? objs[pos] : null;
if (o != null && (
// When type is null we don't safety check
type == null ||
// Th... | java |
public Object f(Widget w, int i) {
setElement(w.getElement());
setIndex(i);
f(w);
return null;
} | java |
public void f(int i, Object... args) {
setIndex(i);
setArguments(args);
if (args.length == 1 && args[0] instanceof JavaScriptObject) {
if (JsUtils.isElement((JavaScriptObject) args[0])) {
setElement((com.google.gwt.dom.client.Element) args[0]);
f(getElement(), i);
} else if (JsUt... | java |
public boolean f(Event e, Object... arg) {
setArguments(arg);
setEvent(e);
return f(e);
} | java |
public void f(Widget w) {
setElement(w.getElement());
if (loop) {
loop = false;
f();
} else {
f(w.getElement().<com.google.gwt.dom.client.Element> cast());
}
} | java |
public static Promise ajax(Settings settings) {
resolveSettings(settings);
final Function onSuccess = settings.getSuccess();
if (onSuccess != null) {
onSuccess.setElement(settings.getContext());
}
final Function onError = settings.getError();
if (onError != null) {
onError.setEleme... | java |
public static final <T extends JavaScriptObject> T checkNull(T js) {
if (!GWT.isProdMode() && js == null) {
throw new NullPointerException();
}
return js;
} | java |
public static <T> T prop(JavaScriptObject o, Object id, Class<? extends T> type) {
return o == null ? null : o.<JsCache> cast().get(id, type);
} | java |
public static void prop(JavaScriptObject o, Object id, Object val) {
if (o != null) {
o.<JsCache> cast().put(id, val);
}
} | java |
public static <T> T exec(JavaScriptObject jsFunction, Object... args) {
assert isFunction(jsFunction);
return jsni(jsFunction, "call", jsFunction, args);
} | java |
public static void export(String name, Function f) {
export(GQuery.window, name, f);
} | java |
public static void export(JavaScriptObject o, String name, Function f) {
prop(o, name, (Object)(f != null ? wrapFunction(f) : null));
} | java |
public static NodeList<Element> copyNodeList(NodeList<Element> oldNodes,
NodeList<Element> newNodes, boolean create) {
NodeList<Element> ret = oldNodes == null || create ? JsNodeArray.create()
: oldNodes;
JsCache idlist = JsCache.create();
for (int i = 0; oldNodes != null && i < oldNodes.getLe... | java |
public static Document getOwnerDocument(Node n) {
return n == null || !isElement(n) ? null : n.getNodeType() == Node.DOCUMENT_NODE
? n.<Document> cast() : n.getOwnerDocument();
} | java |
public static boolean isDetached(Node n) {
assert n != null;
if ("html".equalsIgnoreCase(n.getNodeName())) {
return false;
}
return !getOwnerDocument(n).getBody().isOrHasChild(n);
} | java |
public static boolean isXML(Node o) {
return o == null ? false
: !"HTML".equals(getOwnerDocument(o).getDocumentElement().getNodeName());
} | java |
public static Properties parseJSON(String json) {
try {
return utilsImpl.parseJSON(json);
} catch (Exception e) {
if (!GWT.isProdMode()) {
System.err.println("Error while parsing json: " + e.getMessage() + ".\n" + json);
}
return Properties.create();
}
} | java |
public static <T> T jsni(JavaScriptObject jso, String meth, Object... args) {
return runJavascriptFunction(jso, meth, args);
} | java |
public static <T> T jsni(String meth, Object... args) {
return runJavascriptFunction(null, meth, args);
} | java |
public static <T> T runJavascriptFunction(JavaScriptObject o, String meth, Object... args) {
return runJavascriptFunctionImpl(o, meth, JsObjectArray.create().add(args).<JsArrayMixed>cast());
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.