code
stringlengths
73
34.1k
label
stringclasses
1 value
public void remove( Widget w ) { int index = indexOf( w ); if( index == -1 ) { throw new NoSuchElementException(); } remove( index ); }
java
Class<?> getSetterPropertyType( Clazz<?> clazz, String name ) { ClassInfoCache cache = retrieveCache( clazz ); Class<?> res = cache.getSetterType( name ); if( res != null ) return res; String setterName = "set" + capitalizeFirstLetter( name ); Method setter = clazz.getMethod( setterName ); if( setter !...
java
boolean hasObjectDynamicProperty( Object object, String propertyName ) { DynamicPropertyBag bag = propertyBagAccess.getObjectDynamicPropertyBag( object ); return bag != null && bag.contains( propertyName ); }
java
public void register( Object source, String path ) { unregister(); dataBinding = Binder.bind( source, path ).mode( Mode.OneWay ).to( adapter ).activate(); }
java
public static BindingCreation bind( Object source, String propertyPath ) { return createBinder( new CompositePropertyAdapter( source, propertyPath ) ); }
java
public static DataBinding map( Object source, Object destination ) { return bindObject( source ).mapTo( destination ); }
java
public HttpResponse postTopicMessage(String topicName, String jsonPayload, Map<String, String> headers) throws RestClientException { return postMessage(Type.TOPIC, topicName, jsonPayload, headers); }
java
public HttpResponse postQueueMessage(String queueName, String jsonPayload, Map<String, String> headers) throws RestClientException { return postMessage(Type.QUEUE, queueName, jsonPayload, headers); }
java
public void run( AcceptsOneWidget container ) { /** Add our widgets in the container */ container.setWidget( UiBuilder.addIn( new VerticalPanel(), personListWidget, personneForm, categoryForm, nextButton ) ); /* * Bind things together */ // selectedPerson to person form Bind( pers...
java
private void _RemoveValidator( Row item, int column ) { // already clean ? if( m_currentEditedItem == null && m_currentEditedColumn < 0 ) return; // touch the table if( m_callback != null ) m_callback.onTouchCellContent( item, column ); if( m_currentEditor != null ) m_currentEditor.removeFromParen...
java
public static void processFile( String input, String mappingPath, String outputFile, boolean doPrune, Log log ) throws IOException { Set<String> usedClassNames = new HashSet<>(); input = replaceClassNames( input, mappingPath, usedClassNames, log ); log.debug( usedClassNames.size() + " used css classes in the m...
java
public void updateGroup(long groupId, String name, boolean isPrivate) { LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(); params.set("name",name); params.set("private", String.valueOf(isPrivate)); restTemplate.put(buildUri("groups/"+groupId), params); }
java
static Map<String, String> getVersionAttributes(URL url) throws IOException { Map<String, String> ret = new LinkedHashMap<>(); try (InputStream inputStream = url.openStream()) { Manifest manifest = new Manifest(inputStream); Attributes attributes = manifest.getMainAttributes(); ...
java
@Override protected View createOverlayView() { LinearLayout ll = new LinearLayout(getContext()); ll.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,FrameLayout.LayoutParams.MATCH_PARENT)); ll.setGravity(Gravity.CENTER); View progressBar = createProg...
java
protected String getNestName() { if (nestName == null || nestName.equals(NestSubsystemExtension.NEST_NAME_AUTOGENERATE)) { return this.envServiceValue.getValue().getNodeName(); } else { return nestName; } }
java
@RobotKeyword("Connect to MQTT Broker") @ArgumentNames({ "broker", "clientId" }) public void connectToMQTTBroker(String broker, String clientId) throws MqttException { client = new MqttClient(broker, clientId); System.out.println("*INFO:" + System.currentTimeMillis() ...
java
@RobotKeywordOverload @ArgumentNames({ "topic", "message" }) public void publishToMQTTSynchronously(String topic, Object message) throws MqttException { publishToMQTTSynchronously(topic, message, 0, false); }
java
@RobotKeyword("Publish to MQTT Synchronously") @ArgumentNames({ "topic", "message", "qos=0", "retained=false" }) public void publishToMQTTSynchronously(String topic, Object message, int qos, boolean retained) throws MqttException { MqttMessage msg; if (message instanceof String) { ...
java
@RobotKeyword("Disconnect from MQTT Broker") public void disconnectFromMQTTBroker() { if (client != null) { try { client.disconnect(); } catch (MqttException e) { throw new RuntimeException(e.getLocalizedMessage()); } } }
java
@RobotKeyword("Subscribe to MQTT Broker and validate that it received a specific message") @ArgumentNames({ "broker", "clientId", "topic", "expectedPayload", "timeout" }) public void subscribeToMQTTAndValidate(String broker, String clientId, String topic, String expectedPayload, long tim...
java
private String _getUniqueKey() { StringBuilder b = new StringBuilder(); b.append( service ); b.append( "#" ); b.append( method ); if( params != null ) { b.append( "#" ); b.append( params.toString() ); } return b.toString(); }
java
public void initialize(@Observes @Initialized(ApplicationScoped.class) Object ignore) { log.debugf("Initializing [%s]", this.getClass().getName()); try { feedSessionListenerProducer = new BiFunction<String, Session, WsSessionListener>() { @Override public WsSe...
java
void modifyData(final TrieNode<V> node, final V value) { node.value = value; ++modCount; ++size; }
java
private void addNode(final TrieNode<V> node, final CharSequence key, final int beginIndex, final TrieNode<V> newNode) { final int lastKeyIndex = key.length() - 1; TrieNode<V> currentNode = node; int i = beginIndex; for (; i < lastKeyIndex; i++) { fin...
java
V removeMapping(final Object o) { if (!(o instanceof Map.Entry)) { throw new IllegalArgumentException(); } @SuppressWarnings("unchecked") final Entry<? extends CharSequence, V> e = (Map.Entry<? extends CharSequence, V>) o; final CharSequence key = keyCheck(e.getKey()); ...
java
private void compact(final CharSequence key) { final int keyLength = key.length(); TrieNode<V> currentNode = getRoot(); TrieNode<V> lastInUseNode = currentNode; int lastInUseIndex = 0; for (int i = 0; i < keyLength && currentNode != null; i++) { if (currentNode.inUse...
java
public static String getTypeQualifiedName(TypeMirror type) throws CodeGenerationIncompleteException { if(type.toString().equals("<any>")) { throw new CodeGenerationIncompleteException("Type reported as <any> is likely a not-yet " + "generated parameterized type."); } switch( type.getKind() ) { case ...
java
public boolean IsInside( String pDate ) { if( periods == null ) { if( days == null ) // security added to avoid null exception return false; if( days.getDay( CalendarFunctions.date_get_day( pDate ) ).get() > 0 ) return true; return false; } for( int i = 0; i < periods.size(); i++ ) { P...
java
public boolean IsContained( String pFrom, String pTo ) { if( periods == null ) { // echo "IsContained() TO BE IMPLEMENTED FLLKJ :: {{ } ''<br/>"; throw new RuntimeException( "Error Periods is Null" ); } for( int i = 0; i < periods.size(); i++ ) { Period period = periods.get( i ); if( period.getF...
java
public void Resolve( String pFrom, String pTo ) { if( periods != null ) { // call on an already resolved CalendarPeriod // echo // "LJLJKZHL KJH ELF B.EB EKJGF EFJBH EKLFJHL JGH <{{ : ' } <br/>"; throw new RuntimeException( "Error call on an already resolved CalendarPeriod" ); } // echo "Resolving...
java
private List<Period> _Intersect( List<Period> periods1, List<Period> periods2 ) { List<Period> result = new ArrayList<Period>(); int count1 = periods1.size(); int count2 = periods2.size(); int i = 0; int j = 0; while( i < count1 && j < count2 ) { // one of the periods begins after the end of the ot...
java
protected Integer compareNullObjects(Object object1, Object object2) { if ((object1 == null) && (object2 == null)) { return 0; } if (object1 == null) { return 1; } if (object2 == null) { return -1; } return null; ...
java
public PathBuilder append( String cmd, double... coords ) { s.append( cmd ).append( " " ); for( double a : coords ) { s.append( a ).append( " " ); } return this; }
java
@AroundInvoke public Object handle(InvocationContext ic) throws Exception { Method m = ic.getMethod(); Object targetObject = ic.getTarget(); Class<?> targetClass = targetObject == null ? m.getDeclaringClass() : targetObject.getClass(); CatchHandler exceptionHandlerAnn...
java
private boolean invokeCleanups(Class<?> clazz, Object target, Class<?> cleanupClazz, Throwable exception) throws Exception { boolean invoked = false; if (!cleanupClazz.equals(Object.class)) { // Christian Beikov 29.07.2013: Traverse whole hierarchy ...
java
public ProducerConnectionContext createProducerConnectionContext(Endpoint endpoint) throws JMSException { ProducerConnectionContext context = new ProducerConnectionContext(); createOrReuseConnection(context, true); createSession(context); createDestination(context, endpoint); cre...
java
protected void cacheConnection(Connection connection, boolean closeExistingConnection) { if (this.connection != null && closeExistingConnection) { try { // make sure it is closed to free up any resources it was using this.connection.close(); } catch (JMSEx...
java
protected void createConnection(ConnectionContext context) throws JMSException { if (context == null) { throw new IllegalStateException("The context is null"); } ConnectionFactory factory = getConnectionFactory(); Connection conn = factory.createConnection(); context....
java
protected void createSession(ConnectionContext context) throws JMSException { if (context == null) { throw new IllegalStateException("The context is null"); } Connection conn = context.getConnection(); if (conn == null) { throw new IllegalStateException("The conte...
java
protected void createDestination(ConnectionContext context, Endpoint endpoint) throws JMSException { if (endpoint == null) { throw new IllegalStateException("Endpoint is null"); } if (context == null) { throw new IllegalStateException("The context is null"); } ...
java
protected void createProducer(ProducerConnectionContext context) throws JMSException { if (context == null) { throw new IllegalStateException("The context is null"); } Session session = context.getSession(); if (session == null) { throw new IllegalStateException("...
java
protected void createConsumer(ConsumerConnectionContext context, String messageSelector) throws JMSException { if (context == null) { throw new IllegalStateException("The context is null"); } Session session = context.getSession(); if (session == null) { throw new...
java
public static Bindings defaultBindings() { return noHashMapBindings() .set( ClassLoader.class, Thread.currentThread().getContextClassLoader() ) .set( ConfigParseOptions.class, ConfigParseOptions.defaults() ...
java
public void Init( CalendarPeriod period, T value ) { for( int i = 0; i < period.getPeriods().size(); i++ ) { Period p = period.getPeriods().get( i ); periods.add( new PeriodAssociative<T>( p.getFrom(), p.getTo(), value ) ); } }
java
public Boolean Add( CalendarPeriodAssociative<T> period, AddFunction<T> addFunction ) { // combine les deux tableaux dans ordre croissant List<PeriodAssociative<T>> combined = _Combine( periods, period.getPeriods() ); // merge overlapping periods List<PeriodAssociative<T>> result = _Merge( combined, addFuncti...
java
public CalendarPeriod GetCalendarPeriod() { CalendarPeriod res = new CalendarPeriod(); List<Period> periods = new ArrayList<Period>(); for( int i = 0; i < this.periods.size(); i++ ) { PeriodAssociative<T> p = this.periods.get( i ); periods.add( new Period( p.getFrom(), p.getTo() ) ); } // use merge t...
java
private boolean _readDate() { int endIndex = pos + 10; if( endIndex <= len ) { _date = text.substring( pos, endIndex ); pos += 10; return true; } pos = len; return false; }
java
public void emphasizePoint( int index ) { if( dots == null || dots.length < (index - 1) ) return; // impossible ! // if no change, nothing to do if( emphasizedPoint == index ) return; // de-emphasize the current emphasized point if( emphasizedPoint >= 0 ) { dots[emphasizedPoint].attr( "r", dotNo...
java
public void moveLastChild( Row newParent ) { if( this == newParent ) return; // remove from its current position Row parentItem = m_parent; if( parentItem == null ) parentItem = this.treeTable.m_rootItem; parentItem.getChilds().remove( this ); // DOM.removeChild( m_body, m_tr ); if( newParent == ...
java
public void moveBefore( Row item ) { if( this == item ) return; Element lastTrToMove = getLastLeafTR(); Element firstChildRow = DOM.getNextSibling( m_tr ); // remove from its current position Row parentItem = m_parent; if( parentItem == null ) parentItem = this.treeTable.m_rootItem; parentItem.ge...
java
void removeHandler( Object handlerRegistration ) { // Through object's interface implementation if( handlerRegistration instanceof DirectHandlerInfo ) { DirectHandlerInfo info = (DirectHandlerInfo) handlerRegistration; info.source.removePropertyChangedHandler( info.registrationObject ); return; } ...
java
public static void filterRequest(ContainerRequestContext requestContext, Predicate<String> predicate) { //NOT a CORS request String requestOrigin = requestContext.getHeaderString(Headers.ORIGIN); if (requestOrigin == null) { return; } if (!predicate.test(requestOrigi...
java
public static void filterResponse(ContainerRequestContext requestContext, ContainerResponseContext responseContext, String extraAccesControlAllowHeaders) { String requestOrigin = requestContext.getHeaderString(Headers.ORIGIN); ...
java
public static TableCellElement getCell( Element root, int column, int row ) { TableSectionElement tbody = getTBodyElement( root ); TableRowElement tr = tbody.getChild( row ).cast(); TableCellElement td = tr.getChild( column ).cast(); return td; }
java
public static Pair<Integer, Integer> getParentCellForElement( Element root, Element element ) { Element tbody = getTBodyElement( root ); // Is the element in our table ? and what's the path from the table to it ? ArrayList<Element> path = TemplateUtils.isDescendant( tbody, element ); if( path == null ) r...
java
public static void setDragData( Object source, Object data ) { DragUtils.source = source; DragUtils.data = data; }
java
public static ConfigFactory webappConfigFactory(ServletContext servletContext) { checkNotNull(servletContext); return webappConfigFactory() .bind(ServletContextPath.class) .toInstance(ServletContextPath.fromServletContext(servletContext)); }
java
@Override public void setWidget( Widget w ) { // Validate if( w == widget ) return; // Detach new child. if( w != null ) w.removeFromParent(); // Remove old child. if( widget != null ) remove( widget ); // Logical attach. widget = w; if( w != null ) { // Physical attach. DOM.app...
java
private String getSentenceFromTokens(final String[] tokens) { final StringBuilder sb = new StringBuilder(); for (final String token : tokens) { sb.append(token).append(" "); } final String sentence = sb.toString(); return sentence; }
java
private String addHeadWordsToTreebank(final List<String> inputTrees) { final StringBuffer parsedDoc = new StringBuffer(); for (final String parseSent : inputTrees) { final Parse parsedSentence = Parse.parseParse(parseSent); this.headFinder.printHeads(parsedSentence); parsedSentence.show(parsed...
java
public void terminate() { log( "term" ); fActivated = false; converter = null; source.removePropertyChangedHandler( sourceHandler ); source = null; sourceHandler = null; destination.removePropertyChangedHandler( destinationHandler ); destination = null; destinationHandler = null; }
java
public static void tryToShowPrompt(Context context, OnCompleteListener onCompleteListener) { tryToShowPrompt(context, null, null, onCompleteListener); }
java
public static void resetIfAppVersionChanged(Context context) { SharedPreferences prefs = getSharedPreferences(context); int appVersionCode = Integer.MIN_VALUE; final int previousAppVersionCode = prefs.getInt(PREF_KEY_APP_VERSION_CODE, Integer.MIN_VALUE); try { appVersionCode...
java
public static Class<?> getObjectClassOfPrimitve(Class<?> primitive) { Class<?> objectClass = PRIMITIVE_TO_WRAPPER.get(primitive); if (objectClass != null) { return objectClass; } return primitive; }
java
public static int getTypeVariablePosition(GenericDeclaration genericDeclartion, TypeVariable<?> typeVariable) { int position = -1; TypeVariable<?>[] typeVariableDeclarationParameters = genericDeclartion .getTypeParameters(); // Try to find the position of the type variable in th...
java
public static Field[] getMatchingFields(Class<?> clazz, final int modifiers) { final Set<Field> fields = new TreeSet<Field>( FIELD_NAME_AND_DECLARING_CLASS_COMPARATOR); traverseHierarchy(clazz, new TraverseTask<Field>() { @Override public Field run(Class<?> clazz...
java
public static Field getField(Class<?> clazz, String fieldName) { final String internedName = fieldName.intern(); return traverseHierarchy(clazz, new TraverseTask<Field>() { @Override public Field run(Class<?> clazz) { Field[] fields = clazz.getDeclaredFields(); ...
java
public static Method getMethod(Class<?> clazz, final String methodName, final Class<?>... parameterTypes) { final String internedName = methodName.intern(); return traverseHierarchy(clazz, new TraverseTask<Method>() { @Override public Method run(Class<?> clazz) { ...
java
public static List<Method> getMethods(Class<?> clazz, final Class<? extends Annotation> annotation) { final List<Method> methods = new ArrayList<Method>(); traverseHierarchy(clazz, new TraverseTask<Method>() { @Override public Method run(Class<?> clazz) { Method[...
java
public static ArrayList<Element> verifyPath( Element root, ArrayList<Element> path ) { if( root == path.get( 0 ) ) return path; return null; }
java
public T getRecordForRow( Row row ) { Integer recordId = rowToRecordIds.get( row ); if( recordId == null ) return null; return getRecordForId( recordId ); }
java
public static Class<?> getSetterPropertyType( Clazz<?> clazz, String name ) { return propertyValues.getSetterPropertyType(clazz, name); }
java
private Map<String, Object> extractErrorDetailsFromResponse(ClientHttpResponse response) throws IOException { ObjectMapper mapper = new ObjectMapper(new JsonFactory()); try { return mapper.<Map<String, Object>> readValue(response.getBody(), new TypeReference<Map<String, Object>>() { }); } catch (JsonParseEx...
java
private void key(final byte key[]) { int i; final int koffp[] = {0}; final int lr[] = {0, 0}; final int plen = P.length, slen = S.length; for (i = 0; i < plen; i++) { P[i] = P[i] ^ streamtoword(key, koffp); } for (i = 0; i < plen; i += 2) { ...
java
public final static int createLocalId() { Storage storage = Storage.getLocalStorageIfSupported(); if( storage == null ) return 0; int increment = 0; String incrementString = storage.getItem( LOCAL_CURRENT_ID_INCREMENT ); try { increment = Integer.parseInt( incrementString ); } catch( Exception e...
java
public <T> void RegisterClazz( Clazz<T> clazz ) { _ensureMap(); if( clazzz.containsKey( clazz.getReflectedClass() ) ) return; clazzz.put( clazz.getReflectedClass(), clazz ); }
java
public void init( String baseUrl, XRPCBatchRequestSender callback ) { this.url = baseUrl + "&locale=" + LocaleInfo.getCurrentLocale().getLocaleName(); this.callback = callback; }
java
private void checkCallService( RequestCallInfo info ) { String service = info.request.service; String interfaceChecksum = info.request.interfaceChecksum; String key = getServiceKey( info ); if( usedServices.containsKey( key ) ) return; ServiceInfo serviceInfo = new ServiceInfo( service, interfaceChecks...
java
public boolean send() { assert sentRequests == null; sentRequests = new ArrayList<RequestCallInfo>(); // add prepended requests, addPrependedRequests( sentRequests ); // add requests to send while( !requestsToSend.isEmpty() ) sentRequests.add( requestsToSend.remove( 0 ) ); // add appended requests ...
java
private RequestBuilder buildMultipart( String name, String value ) { String boundary = "AJAX------" + Math.random() + "" + new Date().getTime(); RequestBuilder builderPost = new RequestBuilder( RequestBuilder.POST, url ); builderPost.setHeader( "Content-Type", "multipart/form-data; charset=utf-8; boundary=" + b...
java
public FormCreator field( Widget widget ) { return field( widget, totalWidth - currentlyUsedWidth - (fFirstItem ? 0 : spacing) ); }
java
public void copy(ConnectionContext source) { this.connection = source.connection; this.session = source.session; this.destination = source.destination; }
java
public static Set<Annotation> getAllAnnotations(Method m) { Set<Annotation> annotationSet = new LinkedHashSet<Annotation>(); Annotation[] annotations = m.getAnnotations(); List<Class<?>> annotationTypes = new ArrayList<Class<?>>(); // Iterate through all annotations of the current class...
java
public static <T extends Annotation> T findAnnotation(Method m, Class<T> annotationClazz) { T annotation = m.getAnnotation(annotationClazz); if (annotation != null) { return annotation; } if (stereotypeAnnotationClass != null) { List<Class<?>> annotations = new A...
java
public static <T extends Annotation> T findAnnotation(Class<?> clazz, Class<T> annotationClazz) { T annotation = clazz.getAnnotation(annotationClazz); if (annotation != null) { return annotation; } Set<Class<?>> superTypes = ReflectionUtils.getSuperTypes(clazz); for ...
java
public <T extends BasicMessage> void listen(ConsumerConnectionContext context, AbstractBasicMessageListener<T> listener) throws JMSException { if (context == null) { throw new NullPointerException("context must not be null"); } if (listener == null) { throw ne...
java
public MessageId send(ProducerConnectionContext context, BasicMessage basicMessage, Map<String, String> headers) throws JMSException { if (context == null) { throw new IllegalArgumentException("context must not be null"); } if (basicMessage == null) { throw ne...
java
public <T extends BasicMessage> RPCConnectionContext sendAndListen(ProducerConnectionContext context, BasicMessage basicMessage, BasicMessageListener<T> responseListener, Map<String, String> headers) throws JMSException { if (context == null) { throw new IllegalArgum...
java
public void sendBasicMessageAsync(Session session, BasicMessage msg) { String text = ApiDeserializer.toHawkularFormat(msg); sendTextAsync(session, text); }
java
public void sendBinaryAsync(Session session, InputStream inputStream, ExecutorService threadPool) { if (session == null) { return; } if (inputStream == null) { throw new IllegalArgumentException("inputStream must not be null"); } log.debugf("Attempting t...
java
public void sendBinarySync(Session session, InputStream inputStream) throws IOException { if (session == null) { return; } if (inputStream == null) { throw new IllegalArgumentException("inputStream must not be null"); } log.debugf("Attempting to send bin...
java
@OnOpen public void uiClientSessionOpen(Session session) { log.infoWsSessionOpened(session.getId(), endpoint); wsEndpoints.getUiClientSessions().addSession(session.getId(), session); WelcomeResponse welcomeResponse = new WelcomeResponse(); // FIXME we should not send the true session...
java
private void doStart() throws LifecycleException { tomcat.getServer().addLifecycleListener(new TomcatLifecycleListener()); logger.info("Deploying application to [" + getConfig().getDeployUrl() + "]"); tomcat.start(); // Let's set the port that was used to actually start the application ...
java
private void doStop() throws LifecycleException { logger.info("Stopping tomcat."); long startTime = System.currentTimeMillis(); tomcat.stop(); long duration = System.currentTimeMillis() - startTime; logger.info("Tomcat shutdown finished in " + duration + " ms."); }
java
public LogTarget addDelegate(Log log) { LogProxyTarget logProxyTarget = new LogProxyTarget(log); this.addTarget(logProxyTarget); return logProxyTarget; }
java
public Object addingService(ServiceReference reference) { HttpService httpService = (HttpService) context.getService(reference); String alias = this.getAlias(); String name = this.getProperty(RESOURCE_NAME); if (name == null) name = alias; try { httpS...
java
public final void setTypeName(final String typeName) { if (typeName == null) { type = LOOKING_AT; } else if (typeName.equalsIgnoreCase(TYPES[0])) { type = MATCHES; } else if (typeName.equalsIgnoreCase(TYPES[1])) { type = LOOKING_AT; } else if (t...
java
public static Reflect onObject(Object object) { if (object == null) { return new Reflect(null, null); } return new Reflect(object, object.getClass()); }
java
public static Reflect onClass(String clazz) throws Exception { return new Reflect(null, ReflectionUtils.getClassForName(clazz)); }
java
public boolean containsField(String name) { if (StringUtils.isNullOrBlank(name)) { return false; } return ClassDescriptorCache.getInstance() .getClassDescriptor(clazz) .getFields(accessAll) .str...
java