code
stringlengths
73
34.1k
label
stringclasses
1 value
public Date dateTime(ImapRequestLineReader request) throws ProtocolException { char next = request.nextWordChar(); String dateString; // From https://tools.ietf.org/html/rfc3501 : // date-time = DQUOTE date-day-fixed "-" date-month "-" date-year // SP time...
java
protected String consumeWord(ImapRequestLineReader request, CharacterValidator validator) throws ProtocolException { StringBuilder atom = new StringBuilder(); char next = request.nextWordChar(); while (!isWhitespace(next)) { if (validator...
java
protected void consumeChar(ImapRequestLineReader request, char expected) throws ProtocolException { char consumed = request.consume(); if (consumed != expected) { throw new ProtocolException("Expected:'" + expected + "' found:'" + consumed + '\''); } }
java
protected String consumeQuoted(ImapRequestLineReader request) throws ProtocolException { // The 1st character must be '"' consumeChar(request, '"'); StringBuilder quoted = new StringBuilder(); char next = request.nextChar(); while (next != '"') { if (next...
java
public Flags flagList(ImapRequestLineReader request) throws ProtocolException { Flags flags = new Flags(); request.nextWordChar(); consumeChar(request, '('); CharacterValidator validator = new NoopCharValidator(); String nextWord = consumeWord(request, validator); while (...
java
public long number(ImapRequestLineReader request) throws ProtocolException { String digits = consumeWord(request, new DigitCharValidator()); return Long.parseLong(digits); }
java
public IdRange[] parseIdRange(ImapRequestLineReader request) throws ProtocolException { CharacterValidator validator = new MessageSetCharValidator(); String nextWord = consumeWord(request, validator); int commaPos = nextWord.indexOf(','); if (commaPos == -1) { re...
java
public ServerSetup[] build(Properties properties) { List<ServerSetup> serverSetups = new ArrayList<>(); String hostname = properties.getProperty("greenmail.hostname", ServerSetup.getLocalHostAddress()); long serverStartupTimeout = Long.parseLong(properties.getProperty("greenmail...
java
public static String format(Flags flags) { StringBuilder buf = new StringBuilder(); buf.append('('); if (flags.contains(Flags.Flag.ANSWERED)) { buf.append("\\Answered "); } if (flags.contains(Flags.Flag.DELETED)) { buf.append("\\Deleted "); ...
java
public void eol() throws ProtocolException { char next = nextChar(); // Ignore trailing spaces. while (next == ' ') { consume(); next = nextChar(); } // handle DOS and unix end-of-lines if (next == '\r') { consume(); ...
java
public void read(byte[] holder) throws ProtocolException { int readTotal = 0; try { while (readTotal < holder.length) { int count = input.read(holder, readTotal, holder.length - readTotal); if (count == -1) { throw new ProtocolExcepti...
java
public void commandContinuationRequest() throws ProtocolException { try { output.write('+'); output.write(' '); output.write('O'); output.write('K'); output.write('\r'); output.write('\n'); output.flush(); ...
java
public static void createUsers(GreenMailOperations greenMail, InternetAddress... addresses) { for (InternetAddress address : addresses) { greenMail.setUser(address.getAddress(), address.getAddress()); } }
java
public static boolean containsUid(IdRange[] idRanges, long uid) { if (null != idRanges && idRanges.length > 0) { for (IdRange range : idRanges) { if (range.includes(uid)) { return true; } } } return false; }
java
SimpleJsonEncoder appendToJSON(final String key, final Object value) { if (closed) { throw new IllegalStateException("Encoder already closed"); } if (value != null) { appendKey(key); if (value instanceof Number) { sb.append(value.toString()); ...
java
SimpleJsonEncoder appendToJSONUnquoted(final String key, final Object value) { if (closed) { throw new IllegalStateException("Encoder already closed"); } if (value != null) { appendKey(key); sb.append(value); } return this; }
java
@SuppressWarnings("checkstyle:illegalcatch") private boolean sendMessage(final byte[] messageToSend) { try { connectionPool.execute(new PooledObjectConsumer<TcpConnection>() { @Override public void accept(final TcpConnection tcpConnection) throws IOException { ...
java
@Override public void run() { try { startBarrier.await(); int idleCount = 0; while (!isRunning.compareAndSet(idleCount > lingerIterations && pidToProcessMap.isEmpty(), false)) { idleCount = (!shutdown && process()) ? 0 : (idleCount + 1); } } catch...
java
public static String dump(final int displayOffset, final byte[] data, final int offset, final int len) { StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb); StringBuilder ascii = new StringBuilder(); int dataNdx = offset; final int maxDataNdx = offset + len...
java
@Override public void run() { try { startBarrier.await(); int idleCount = 0; while (!isRunning.compareAndSet(idleCount > LINGER_ITERATIONS && deadPool.isEmpty() && completionKeyToProcessMap.isEmpty(), false)) { idleCount = (!shutdown && process()) ? 0 : (idleCount + 1...
java
public Snackbar actionLabel(CharSequence actionButtonLabel) { mActionLabel = actionButtonLabel; if (snackbarAction != null) { snackbarAction.setText(mActionLabel); } return this; }
java
public static void setBackgroundDrawable(View view, Drawable drawable) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { view.setBackgroundDrawable(drawable); } else { view.setBackground(drawable); } }
java
public void visitRequire(String module, int access, String version) { if (mv != null) { mv.visitRequire(module, access, version); } }
java
public void visitExport(String packaze, int access, String... modules) { if (mv != null) { mv.visitExport(packaze, access, modules); } }
java
public void visitOpen(String packaze, int access, String... modules) { if (mv != null) { mv.visitOpen(packaze, access, modules); } }
java
private int[] readTypeAnnotations(final MethodVisitor mv, final Context context, int u, boolean visible) { char[] c = context.buffer; int[] offsets = new int[readUnsignedShort(u)]; u += 2; for (int i = 0; i < offsets.length; ++i) { offsets[i] = u; int ...
java
private void visitImplicitFirstFrame() { // There can be at most descriptor.length() + 1 locals int frameIndex = startFrame(0, descriptor.length() + 1, 0); if ((access & Opcodes.ACC_STATIC) == 0) { if ((access & ACC_CONSTRUCTOR) == 0) { frame[frameIndex++] = Frame.OBJ...
java
Item newStringishItem(final int type, final String value) { key2.set(type, value, null, null); Item result = get(key2); if (result == null) { pool.put12(type, newUTF8(value)); result = new Item(index++, key2); put(result); } return result; ...
java
public void visitParameter(String name, int access) { if (mv != null) { mv.visitParameter(name, access); } }
java
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (mv != null) { mv.visitMethodInsn(opcode, owner, name, desc, itf); } }
java
public AnnotationVisitor visitLocalVariableAnnotation(int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, String desc, boolean visible) { if (mv != null) { return mv.visitLocalVariableAnnotation(typeRef, typePath, start, end, index, de...
java
public void setHeader(String header) { headerLabel.getElement().setInnerSafeHtml(SafeHtmlUtils.fromString(header)); addStyleName(CssName.WITH_HEADER); ListItem item = new ListItem(headerLabel); UiHelper.addMousePressedHandlers(item); item.setStyleName(CssName.COLLECTION_HEADER); ...
java
public void setHtml(String html) { this.html = html; if (widget != null) { if (widget.isAttached()) { tooltipElement.find("span") .html(html != null ? html : ""); } else { widget.addAttachHandler(event -> ...
java
public void addItem(T value, String text, boolean reload) { values.add(value); listBox.addItem(text, keyFactory.generateKey(value)); if (reload) { reload(); } }
java
public void addItem(T value, Direction dir, String text) { addItem(value, dir, text, true); }
java
public void removeValue(T value, boolean reload) { int idx = getIndex(value); if (idx >= 0) { removeItemInternal(idx, reload); } }
java
@Override public void clear() { values.clear(); listBox.clear(); clearStatusText(); if (emptyPlaceHolder != null) { insertEmptyPlaceHolder(emptyPlaceHolder); } reload(); if (isAllowBlank()) { addBlankItemIfNeeded(); } }
java
public String[] getItemsSelected() { List<String> selected = new LinkedList<>(); for (int i = getIndexOffset(); i < listBox.getItemCount(); i++) { if (listBox.isItemSelected(i)) { selected.add(listBox.getValue(i)); } } return selected.toArray(new S...
java
public void setValueSelected(T value, boolean selected) { int idx = getIndex(value); if (idx >= 0) { setItemSelectedInternal(idx, selected); } }
java
public int getIndex(T value) { int count = getItemCount(); for (int i = 0; i < count; i++) { if (Objects.equals(getValue(i), value)) { return i; } } return -1; }
java
@Override public HandlerRegistration addSearchFinishHandler(final SearchFinishEvent.SearchFinishHandler handler) { return addHandler(handler, SearchFinishEvent.TYPE); }
java
@Override public HandlerRegistration addSearchNoResultHandler(final SearchNoResultEvent.SearchNoResultHandler handler) { return addHandler(handler, SearchNoResultEvent.TYPE); }
java
public void setSize(ButtonSize size) { if (this.size != null) { removeStyleName(this.size.getCssName()); } this.size = size; if (size != null) { addStyleName(size.getCssName()); } }
java
public void setText(String text) { span.setText(text); if (!span.isAttached()) { add(span); } }
java
public static <E extends Enum<? extends Style.HasCssName>> E fromStyleName(final String styleName, final Class<E> enumClass, final E defaultValue) { retur...
java
public void stopAnimation() { if(widget != null) { widget.removeStyleName("animated"); widget.removeStyleName(transition.getCssName()); widget.removeStyleName(CssName.INFINITE); } }
java
public void clear() { valueBoxBase.setText(""); clearStatusText(); if (getPlaceholder() == null || getPlaceholder().isEmpty()) { label.removeStyleName(CssName.ACTIVE); } }
java
protected void updateLabelActiveStyle() { if (this.valueBoxBase.getText() != null && !this.valueBoxBase.getText().isEmpty()) { label.addStyleName(CssName.ACTIVE); } else { label.removeStyleName(CssName.ACTIVE); } }
java
protected void checkActiveState(Widget child) { // Check if this widget has a valid href String href = child.getElement().getAttribute("href"); String url = Window.Location.getHref(); int pos = url.indexOf("#"); String location = pos >= 0 ? url.substring(pos, url.length()) : ""; ...
java
@Override public void setActive(boolean active) { this.active = active; if (parent != null) { fireCollapsibleHandler(); removeStyleName(CssName.ACTIVE); if (header != null) { header.removeStyleName(CssName.ACTIVE); } if (ac...
java
public void setDateMin(Date dateMin) { this.dateMin = dateMin; if (isAttached() && dateMin != null) { getPicker().set("min", JsDate.create((double) dateMin.getTime())); } }
java
public void setDateMax(Date dateMax) { this.dateMax = dateMax; if (isAttached() && dateMax != null) { getPicker().set("max", JsDate.create((double) dateMax.getTime())); } }
java
protected Date getPickerDate() { try { JsDate pickerDate = getPicker().get("select").obj; return new Date((long) pickerDate.getTime()); } catch (Exception e) { e.printStackTrace(); return null; } }
java
public void setSelectionType(MaterialDatePickerType selectionType) { this.selectionType = selectionType; switch (selectionType) { case MONTH_DAY: options.selectMonths = true; break; case YEAR_MONTH_DAY: options.selectYears = yearsTo...
java
public void setAutoClose(boolean autoClose) { this.autoClose = autoClose; if (autoCloseHandlerRegistration != null) { autoCloseHandlerRegistration.removeHandler(); autoCloseHandlerRegistration = null; } if (autoClose) { autoCloseHandlerRegistration =...
java
public void setAllowBlank(boolean allowBlank) { this.allowBlank = allowBlank; // Setup the allow blank validation if (!allowBlank) { if (blankValidator == null) { blankValidator = createBlankValidator(); } setupBlurValidation(); ad...
java
protected String ensureTextColorFormat(String textColor) { String formatted = ""; boolean mainColor = true; for (String style : textColor.split(" ")) { if (mainColor) { // the main color if (!style.endsWith("-text")) { style += "-te...
java
public void selectTab() { for (Widget child : getChildren()) { if (child instanceof HasHref) { String href = ((HasHref) child).getHref(); if (parent != null && !href.isEmpty()) { parent.selectTab(href.replaceAll("[^a-zA-Z\\d\\s:]", "")); ...
java
public static String format(String pattern, Object... arguments) { String msg = pattern; if (arguments != null) { for (int index = 0; index < arguments.length; index++) { msg = msg.replaceAll("\\{" + (index + 1) + "\\}", String.valueOf(arguments[index])); } ...
java
@Override public void setValue(Boolean value, boolean fireEvents) { boolean oldValue = getValue(); if (value) { input.getElement().setAttribute("checked", "true"); } else { input.getElement().removeAttribute("checked"); } if (fireEvents && oldValue !=...
java
public static <E extends Style.HasCssName, F extends Enum<? extends Style.HasCssName>> void addUniqueEnumStyleName(final UIObject uiObject, final Class<F> enumClass, ...
java
public static void toggleStyleName(final UIObject uiObject, final boolean toggleStyle, final String styleName) { if (toggleStyle) { uiObject.addStyleName(styleName); } else { uiObject.removeStyleName(st...
java
protected void setupRegistration() { if (isServiceWorkerSupported()) { Navigator.serviceWorker.register(getResource()).then(object -> { logger.info("Service worker has been successfully registered"); registration = (ServiceWorkerRegistration) object; ...
java
@Override public HandlerRegistration addChangeHandler(final ChangeHandler handler) { return getRangeInputElement().addDomHandler(handler, ChangeEvent.getType()); }
java
public ViewPort then(Functions.Func1<ViewPortChange> then, ViewPortFallback fallback) { assert then != null : "'then' callback cannot be null"; this.then = then; this.fallback = fallback; return load(); }
java
protected ViewPort load() { resize = Window.addResizeHandler(event -> { execute(event.getWidth(), event.getHeight()); }); execute(window().width(), (int)window().height()); return viewPort; }
java
public static String format(String format) { if (format == null) { format = DEFAULT_FORMAT; } else { if (format.contains("M")) { format = format.replace("M", "m"); } if (format.contains("Y")) { format = format.replace("Y",...
java
public void setWidth(int width) { this.width = width; getElement().getStyle().setWidth(width, Style.Unit.PX); }
java
public void setAccordion(boolean accordion) { getElement().setAttribute("data-collapsible", accordion ? CssName.ACCORDION : CssName.EXPANDABLE); reload(); }
java
public String getInvalidMessage(String key) { return invalidMessageOverride == null ? messageMixin.lookup(key, messageValueArgs) : MessageFormat.format( invalidMessageOverride, messageValueArgs); }
java
public void installApp(Functions.Func callback) { if (isPwaSupported()) { appInstaller = new AppInstaller(callback); appInstaller.prompt(); } }
java
public void show() { if (!(container instanceof RootPanel)) { if (!(container instanceof MaterialDialog)) { container.getElement().getStyle().setPosition(Style.Position.RELATIVE); } div.getElement().getStyle().setPosition(Style.Position.ABSOLUTE); } ...
java
public void hide() { div.removeFromParent(); if (scrollDisabled) { RootPanel.get().getElement().getStyle().setOverflow(Style.Overflow.AUTO); } if (type == LoaderType.CIRCULAR) { preLoader.removeFromParent(); } else if (type == LoaderType.PROGRESS) { ...
java
public static void detectAndApply(Widget widget) { if (!widget.isAttached()) { widget.addAttachHandler(event -> { if (event.isAttached()) { detectAndApply(); } }); } else { detectAndApply(); } }
java
public void setType(CheckBoxType type) { this.type = type; switch (type) { case FILLED: Element input = DOM.getChild(getElement(), 0); input.setAttribute("class", CssName.FILLED_IN); break; case INTERMEDIATE: addStyl...
java
ArgumentsBuilder param(String param, Integer value) { if (value != null) { args.add(param); args.add(value.toString()); } return this; }
java
ArgumentsBuilder param(String param, String value) { if (value != null) { args.add(param); args.add(value); } return this; }
java
protected List<String> arguments() { List<String> args = new ArgumentsBuilder() .flag("-v", verbose) .flag("--package-dir", packageDir) .param("-d", outputDirectory.getPath()) .param("-p", packageName) .map("--package:", packageNameMap()) ....
java
Map<String, String> packageNameMap() { if (packageNames == null) { return emptyMap(); } Map<String, String> names = new LinkedHashMap<String, String>(); for (PackageName name : packageNames) { names.put(name.getUri(), name.getPackage()); } return ...
java
@NonNull public static String placeholders(final int numberOfPlaceholders) { if (numberOfPlaceholders == 1) { return "?"; // fffast } else if (numberOfPlaceholders == 0) { return ""; } else if (numberOfPlaceholders < 0) { throw new IllegalArgumentException...
java
public Tuple get(RowKey key) { AssociationOperation result = currentState.get( key ); if ( result == null ) { return cleared ? null : snapshot.get( key ); } else if ( result.getType() == REMOVE ) { return null; } return result.getValue(); }
java
public void remove(RowKey key) { currentState.put( key, new AssociationOperation( key, null, REMOVE ) ); }
java
public boolean isEmpty() { int snapshotSize = cleared ? 0 : snapshot.size(); //nothing in both if ( snapshotSize == 0 && currentState.isEmpty() ) { return true; } //snapshot bigger than changeset if ( snapshotSize > currentState.size() ) { return false; } return size() == 0; }
java
public int size() { int size = cleared ? 0 : snapshot.size(); for ( Map.Entry<RowKey,AssociationOperation> op : currentState.entrySet() ) { switch ( op.getValue().getType() ) { case PUT: if ( cleared || !snapshot.containsKey( op.getKey() ) ) { size++; } break; case REMOVE: if ( ...
java
public Iterable<RowKey> getKeys() { if ( currentState.isEmpty() ) { if ( cleared ) { // if the association has been cleared and the currentState is empty, we consider that there are no rows. return Collections.emptyList(); } else { // otherwise, the snapshot rows are the current ones return s...
java
public Object getColumnValue(String columnName) { for ( int j = 0; j < columnNames.length; j++ ) { if ( columnNames[j].equals( columnName ) ) { return columnValues[j]; } } return null; }
java
public boolean contains(String column) { for ( String columnName : columnNames ) { if ( columnName.equals( column ) ) { return true; } } return false; }
java
private void loadResourceFile(URL configurationResourceUrl, Properties hotRodConfiguration) { if ( configurationResourceUrl != null ) { try ( InputStream openStream = configurationResourceUrl.openStream() ) { hotRodConfiguration.load( openStream ); } catch (IOException e) { throw log.failedLoadingHot...
java
private static <D extends DatastoreConfiguration<G>, G extends GlobalContext<?, ?>> AppendableConfigurationContext invokeOptionConfigurator( OptionConfigurator configurator) { ConfigurableImpl configurable = new ConfigurableImpl(); configurator.configure( configurable ); return configurable.getContext(); }
java
@Override public boolean isKeyColumn(String columnName) { for ( String keyColumName : getColumnNames() ) { if ( keyColumName.equals( columnName ) ) { return true; } } return false; }
java
@Override public List<Object> loadEntitiesFromTuples(SharedSessionContractImplementor session, LockOptions lockOptions, OgmLoadingContext ogmContext) { return loadEntity( null, null, session, lockOptions, ogmContext ); }
java
public final void loadCollection( final SharedSessionContractImplementor session, final Serializable id, final Type type) throws HibernateException { if ( log.isDebugEnabled() ) { log.debug( "loading collection: " + MessageHelper.collectionInfoString( getCollectionPersisters()[0], id, getFactory()...
java
private List<Object> doQueryAndInitializeNonLazyCollections( SharedSessionContractImplementor session, QueryParameters qp, OgmLoadingContext ogmLoadingContext, boolean returnProxies) { //TODO handles the read only final PersistenceContext persistenceContext = session.getPersistenceContext(); boolean...
java
private List<Object> doQuery( SharedSessionContractImplementor session, QueryParameters qp, OgmLoadingContext ogmLoadingContext, boolean returnProxies) { //TODO support lock timeout int entitySpan = entityPersisters.length; final List<Object> hydratedObjects = entitySpan == 0 ? null : new ArrayList<O...
java
private void readCollectionElement( final Object optionalOwner, final Serializable optionalKey, final CollectionPersister persister, final CollectionAliases descriptor, final ResultSet rs, final SharedSessionContractImplementor session) throws HibernateException, SQLException { final PersistenceConte...
java
private void instanceAlreadyLoaded( final Tuple resultset, final int i, //TODO create an interface for this usage final OgmEntityPersister persister, final org.hibernate.engine.spi.EntityKey key, final Object object, final LockMode lockMode, final SharedSessionContractImplementor session) throws Hiber...
java
private Object instanceNotYetLoaded( final Tuple resultset, final int i, final Loadable persister, final String rowIdAlias, final org.hibernate.engine.spi.EntityKey key, final LockMode lockMode, final org.hibernate.engine.spi.EntityKey optionalObjectKey, final Object optionalObject, final List hydrate...
java
private void registerNonExists( final org.hibernate.engine.spi.EntityKey[] keys, final Loadable[] persisters, final SharedSessionContractImplementor session) { final int[] owners = getOwners(); if ( owners != null ) { EntityType[] ownerAssociationTypes = getOwnerAssociationTypes(); for ( int i = 0; i ...
java
public Rule CriteriaOnlyFindQuery() { return Sequence( !peek().isCliQuery(), JsonParameter( JsonObject() ) , peek().setOperation( Operation.FIND ), peek().setCriteria( match() ) ); }
java
public static Map<String, Object> introspect(Object obj) throws IntrospectionException, InvocationTargetException, IllegalAccessException { Map<String, Object> result = new HashMap<>(); BeanInfo info = Introspector.getBeanInfo( obj.getClass() ); for ( PropertyDescriptor pd : info.getPropertyDescriptors() ) { M...
java