idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
40,900 | public ClassModelMethod getMethod ( MethodEntry _methodEntry , boolean _isSpecial ) { final String entryClassNameInDotForm = _methodEntry . getClassEntry ( ) . getNameUTF8Entry ( ) . getUTF8 ( ) . replace ( ' ' , ' ' ) ; // Shortcut direct calls to supers to allow "foo() { super.foo() }" type stuff to work if ( _isSpec... | Look up a ConstantPool MethodEntry and return the corresponding Method . | 306 | 13 |
40,901 | public MethodModel getMethodModel ( String _name , String _signature ) throws AparapiException { if ( CacheEnabler . areCachesEnabled ( ) ) return methodModelCache . computeIfAbsent ( MethodKey . of ( _name , _signature ) ) ; else { final ClassModelMethod method = getMethod ( _name , _signature ) ; return new MethodMod... | Create a MethodModel for a given method name and signature . | 89 | 12 |
40,902 | public void setProfileReport ( final long reportId , final long [ ] _currentTimes ) { id = reportId ; System . arraycopy ( _currentTimes , 0 , currentTimes , 0 , NUM_EVENTS ) ; } | Sets specific report data . | 48 | 6 |
40,903 | public double getElapsedTime ( int stage ) { if ( stage == ProfilingEvent . START . ordinal ( ) ) { return 0 ; } return ( currentTimes [ stage ] - currentTimes [ stage - 1 ] ) / MILLION ; } | Elapsed time for a single event only i . e . since the previous stage rather than from the start . | 52 | 22 |
40,904 | public void configure ( ) { if ( configurator != null && ! underConfiguration . get ( ) && underConfiguration . compareAndSet ( false , true ) ) { try { configurator . configure ( this ) ; } finally { underConfiguration . set ( false ) ; } } } | Called by the underlying Aparapi OpenCL platform upon device detection . | 60 | 15 |
40,905 | public static List < OpenCLDevice > listDevices ( TYPE type ) { final OpenCLPlatform platform = new OpenCLPlatform ( 0 , null , null , null ) ; final ArrayList < OpenCLDevice > results = new ArrayList <> ( ) ; for ( final OpenCLPlatform p : platform . getOpenCLPlatforms ( ) ) { for ( final OpenCLDevice device : p . get... | List OpenCLDevices of a given TYPE or all OpenCLDevices if type == null . | 122 | 20 |
40,906 | void onStart ( Device device ) { KernelDeviceProfile currentDeviceProfile = deviceProfiles . get ( device ) ; if ( currentDeviceProfile == null ) { currentDeviceProfile = new KernelDeviceProfile ( this , kernelClass , device ) ; KernelDeviceProfile existingProfile = deviceProfiles . putIfAbsent ( device , currentDevice... | Starts a profiling information gathering sequence for the current thread invoking this method regarding the specified execution device . | 112 | 20 |
40,907 | void onEvent ( Device device , ProfilingEvent event ) { if ( event == null ) { logger . log ( Level . WARNING , "Discarding profiling event " + event + " for null device, for Kernel class: " + kernelClass . getName ( ) ) ; return ; } final KernelDeviceProfile deviceProfile = deviceProfiles . get ( device ) ; switch ( e... | Updates the profiling information for the current thread invoking this method regarding the specified execution device . | 241 | 18 |
40,908 | @ Override public String convertType ( String _typeDesc , boolean useClassModel , boolean isLocal ) { if ( _typeDesc . equals ( "Z" ) || _typeDesc . equals ( "boolean" ) ) { return ( cvtBooleanToChar ) ; } else if ( _typeDesc . equals ( "[Z" ) || _typeDesc . equals ( "boolean[]" ) ) { return isLocal ? ( cvtBooleanArray... | These three convert functions are here to perform any type conversion that may be required between Java and OpenCL . | 652 | 21 |
40,909 | private ClassModel getClassModelFromArg ( KernelArg arg , final Class < ? > arrayClass ) { ClassModel c = null ; if ( arg . getObjArrayElementModel ( ) == null ) { final String tmp = arrayClass . getName ( ) . substring ( 2 ) . replace ( ' ' , ' ' ) ; final String arrayClassInDotForm = tmp . substring ( 0 , tmp . lengt... | Helper method to retrieve the class model from a kernel argument . | 225 | 12 |
40,910 | public boolean allocateArrayBufferIfFirstTimeOrArrayChanged ( KernelArg arg , Object newRef , final int objArraySize , final int totalStructSize , final int totalBufferSize ) { boolean didReallocate = false ; if ( ( arg . getObjArrayBuffer ( ) == null ) || ( newRef != arg . getArray ( ) ) ) { final ByteBuffer structBuf... | Helper method that manages the memory allocation for storing the kernel argument data so that the data can be exchanged between the host and the OpenCL device . | 224 | 29 |
40,911 | public boolean isDeviceAmongPreferredDevices ( Device device ) { maybeSetUpDefaultPreferredDevices ( ) ; boolean result = false ; synchronized ( this ) { result = preferredDevices . get ( ) . contains ( device ) ; } return result ; } | Validates if the specified devices is among the preferred devices for executing the kernel associated with the current kernel preferences . | 55 | 22 |
40,912 | public static OpenCLKernel createKernel ( OpenCLProgram _program , String _kernelName , List < OpenCLArgDescriptor > _args ) { final OpenCLArgDescriptor [ ] argArray = _args . toArray ( new OpenCLArgDescriptor [ 0 ] ) ; final OpenCLKernel oclk = new OpenCLKernel ( ) . createKernelJNI ( _program , _kernelName , argArray... | This method is used to create a new Kernel from JNI | 128 | 12 |
40,913 | public boolean doesNotContainContinueOrBreak ( Instruction _start , Instruction _extent ) { boolean ok = true ; boolean breakOrContinue = false ; for ( Instruction i = _start ; i != null ; i = i . getNextExpr ( ) ) { if ( i . isBranch ( ) ) { if ( i . asBranch ( ) . isForwardUnconditional ( ) && i . asBranch ( ) . getT... | Determine whether the sequence of instructions from _start to _extent is free of branches which extend beyond _extent . | 235 | 26 |
40,914 | public Instruction add ( Instruction _instruction ) { if ( head == null ) { head = _instruction ; } else { _instruction . setPrevExpr ( tail ) ; tail . setNextExpr ( _instruction ) ; } tail = _instruction ; logger . log ( Level . FINE , "After PUSH of " + _instruction + " tail=" + tail ) ; return ( tail ) ; } | Add this instruction to the end of the list . | 90 | 10 |
40,915 | public void replaceInclusive ( Instruction _head , Instruction _tail , Instruction _newOne ) { _newOne . setNextExpr ( null ) ; _newOne . setPrevExpr ( null ) ; final Instruction prevHead = _head . getPrevExpr ( ) ; if ( _tail == null ) { // this is the new tail _newOne . setPrevExpr ( prevHead ) ; prevHead . setNextEx... | Inclusive replace between _head and _tail with _newOne . | 320 | 14 |
40,916 | public static < T extends Kernel > T sharedKernelInstance ( Class < T > kernelClass ) { return instance ( ) . getSharedKernelInstance ( kernelClass ) ; } | This method returns a shared instance of a given Kernel subclass . The kernelClass needs a no - args constructor which need not be public . | 38 | 27 |
40,917 | public void deoptimizeReverseBranches ( ) { for ( Instruction instruction = pcHead ; instruction != null ; instruction = instruction . getNextPC ( ) ) { if ( instruction . isBranch ( ) ) { final Branch branch = instruction . asBranch ( ) ; if ( branch . isReverse ( ) ) { final Instruction target = branch . getTarget ( ... | Javac optimizes some branches to avoid goto - > goto branch - > goto etc . | 177 | 19 |
40,918 | void checkForSetter ( Map < Integer , Instruction > pcMap ) throws ClassParseException { final String methodName = getMethod ( ) . getName ( ) ; if ( methodName . startsWith ( "set" ) ) { final String rawVarNameCandidate = methodName . substring ( 3 ) ; final String firstLetter = rawVarNameCandidate . substring ( 0 , 1... | Determine if this method is a setter and record the accessed field if so | 640 | 17 |
40,919 | public static String getSimpleName ( Class < ? > klass ) { String simpleName = klass . getSimpleName ( ) ; if ( simpleName . isEmpty ( ) ) { String fullName = klass . getName ( ) ; int index = fullName . lastIndexOf ( ' ' ) ; simpleName = ( index < 0 ) ? fullName : fullName . substring ( index + 1 ) ; } return simpleNa... | Avoids getting dumb empty names for anonymous inners . | 94 | 11 |
40,920 | public void loadFromResource ( String resource , Candidate . CandidateType type ) throws IOException { InputStream candidatesConfig = classloader . getResourceAsStream ( resource ) ; if ( candidatesConfig == null ) { throw new IOException ( "Resource '" + resource + "' not found" ) ; } try { loadFrom ( candidatesConfig... | Load a candidate property file | 85 | 5 |
40,921 | public static void main ( String [ ] args ) { TextReporter reporter = new TextReporter ( System . out , System . err ) ; run ( reporter ) ; if ( reporter . hasErrors ( ) ) { System . exit ( 1 ) ; } } | Main class of the TCK . Can also be called as a normal method from an application server . | 55 | 20 |
40,922 | public static void run ( Reporter reporter ) { TCK tck = new TCK ( new ObjenesisStd ( ) , new ObjenesisSerializer ( ) , reporter ) ; tck . runTests ( ) ; } | Run the full test suite using standard Objenesis instances | 49 | 11 |
40,923 | public static SortedSet < String > getClassesForPackage ( Package pkg , ClassLoader classLoader ) { SortedSet < String > classes = new TreeSet <> ( new Comparator < String > ( ) { public int compare ( String o1 , String o2 ) { String simpleName1 = getSimpleName ( o1 ) ; String simpleName2 = getSimpleName ( o2 ) ; retur... | Return all the classes in this package recursively . | 294 | 11 |
40,924 | public static byte [ ] readClass ( String className ) throws IOException { // convert to a resource className = ClassUtils . classNameToResource ( className ) ; byte [ ] b = new byte [ 2500 ] ; // I'm assuming that I'm reading class that are not too big int length ; try ( InputStream in = ClassDefinitionUtils . class .... | Read the bytes of a class from the classpath | 165 | 10 |
40,925 | public static void writeClass ( String fileName , byte [ ] bytes ) throws IOException { try ( BufferedOutputStream out = new BufferedOutputStream ( new FileOutputStream ( fileName ) ) ) { out . write ( bytes ) ; } } | Write all class bytes to a file . | 53 | 8 |
40,926 | @ SuppressWarnings ( "unchecked" ) public static < T > Class < T > getExistingClass ( ClassLoader classLoader , String className ) { try { return ( Class < T > ) Class . forName ( className , true , classLoader ) ; } catch ( ClassNotFoundException e ) { return null ; } } | Check if this class already exists in the class loader and return it if it does | 74 | 16 |
40,927 | public void registerCandidate ( Class < ? > candidateClass , String description , Candidate . CandidateType type ) { Candidate candidate = new Candidate ( candidateClass , description , type ) ; int index = candidates . indexOf ( candidate ) ; if ( index >= 0 ) { Candidate existingCandidate = candidates . get ( index )... | Register a candidate class to attempt to instantiate . | 135 | 10 |
40,928 | @ SuppressWarnings ( "unchecked" ) public < T > ObjectInstantiator < T > newInstantiatorOf ( Class < T > type ) { try { return ( ObjectInstantiator < T > ) constructor . newInstance ( type ) ; } catch ( InstantiationException | IllegalAccessException | InvocationTargetException e ) { throw new ObjenesisException ( e ) ... | Return an instantiator for the wanted type and of the one and only type of instantiator returned by this class . | 86 | 23 |
40,929 | public static < T > Class < ? super T > getNonSerializableSuperClass ( Class < T > type ) { Class < ? super T > result = type ; while ( Serializable . class . isAssignableFrom ( result ) ) { result = result . getSuperclass ( ) ; if ( result == null ) { throw new Error ( "Bad class hierarchy: No non-serializable parents... | Returns the first non - serializable superclass of a given class . According to Java Object Serialization Specification objects read from a stream are initialized by calling an accessible no - arg constructor from the first non - serializable superclass in the object s hierarchy allowing the state of non - serializable... | 93 | 65 |
40,930 | public static String describePlatform ( ) { String desc = "Java " + SPECIFICATION_VERSION + " (" + "VM vendor name=\"" + VENDOR + "\", " + "VM vendor version=" + VENDOR_VERSION + ", " + "JVM name=\"" + JVM_NAME + "\", " + "JVM version=" + VM_VERSION + ", " + "JVM info=" + VM_INFO ; // Add the API level if it's an Andro... | Describes the platform . Outputs Java version and vendor . | 138 | 12 |
40,931 | private Map < String , TypeName > convertPropertiesToTypes ( Map < String , ExecutableElement > properties ) { Map < String , TypeName > types = new LinkedHashMap <> ( ) ; for ( Map . Entry < String , ExecutableElement > entry : properties . entrySet ( ) ) { ExecutableElement el = entry . getValue ( ) ; types . put ( e... | Converts the ExecutableElement properties to TypeName properties | 109 | 11 |
40,932 | private static String classNameOf ( TypeElement type , String delimiter ) { String name = type . getSimpleName ( ) . toString ( ) ; while ( type . getEnclosingElement ( ) instanceof TypeElement ) { type = ( TypeElement ) type . getEnclosingElement ( ) ; name = type . getSimpleName ( ) + delimiter + name ; } return name... | Returns the name of the given type including any enclosing types but not the package separated by a delimiter . | 85 | 22 |
40,933 | public static float [ ] checkArrayElementsInRange ( float [ ] value , float lower , float upper , String valueName ) { checkNotNull ( value , valueName + " must not be null" ) ; for ( int i = 0 ; i < value . length ; ++ i ) { float v = value [ i ] ; if ( Float . isNaN ( v ) ) { throw new IllegalArgumentException ( valu... | Ensures that all elements in the argument floating point array are within the inclusive range | 221 | 17 |
40,934 | private void initializeUserStoreAndCheckVersion ( ) throws Exception { int i = 0 ; String version = com . evernote . edam . userstore . Constants . EDAM_VERSION_MAJOR + "." + com . evernote . edam . userstore . Constants . EDAM_VERSION_MINOR ; for ( String url : mBootstrapServerUrls ) { i ++ ; try { EvernoteUserStoreCl... | Initialized the User Store to check for supported version of the API . | 315 | 13 |
40,935 | BootstrapInfoWrapper getBootstrapInfo ( ) throws Exception { Log . d ( LOGTAG , "getBootstrapInfo()" ) ; BootstrapInfo bsInfo = null ; try { if ( mBootstrapServerUsed == null ) { initializeUserStoreAndCheckVersion ( ) ; } bsInfo = mEvernoteSession . getEvernoteClientFactory ( ) . getUserStoreClient ( getUserStoreUrl ( ... | Makes a web request to get the latest bootstrap information . This is a requirement during the oauth process | 173 | 22 |
40,936 | public Response fetchEvernoteUrl ( String url ) throws IOException { Request . Builder requestBuilder = new Request . Builder ( ) . url ( url ) . addHeader ( "Cookie" , mAuthHeader ) . get ( ) ; return mHttpClient . newCall ( requestBuilder . build ( ) ) . execute ( ) ; } | Fetches the URL with the current authentication token as cookie in the header . | 71 | 16 |
40,937 | public static String createEnMediaTag ( Resource resource ) { return "<en-media hash=\"" + bytesToHex ( resource . getData ( ) . getBodyHash ( ) ) + "\" type=\"" + resource . getMime ( ) + "\"/>" ; } | Create an ENML < ; en - media> ; tag for the specified Resource object . | 60 | 20 |
40,938 | public static byte [ ] hash ( byte [ ] body ) { if ( HASH_DIGEST != null ) { return HASH_DIGEST . digest ( body ) ; } else { throw new EvernoteUtilException ( EDAM_HASH_ALGORITHM + " not supported" , new NoSuchAlgorithmException ( EDAM_HASH_ALGORITHM ) ) ; } } | Returns an MD5 checksum of the provided array of bytes . | 90 | 13 |
40,939 | public static byte [ ] hash ( InputStream in ) throws IOException { if ( HASH_DIGEST == null ) { throw new EvernoteUtilException ( EDAM_HASH_ALGORITHM + " not supported" , new NoSuchAlgorithmException ( EDAM_HASH_ALGORITHM ) ) ; } byte [ ] buf = new byte [ 1024 ] ; int n ; while ( ( n = in . read ( buf ) ) != - 1 ) { H... | Returns an MD5 checksum of the contents of the provided InputStream . | 136 | 15 |
40,940 | public static String bytesToHex ( byte [ ] bytes , boolean withSpaces ) { StringBuilder sb = new StringBuilder ( ) ; for ( byte hashByte : bytes ) { int intVal = 0xff & hashByte ; if ( intVal < 0x10 ) { sb . append ( ' ' ) ; } sb . append ( Integer . toHexString ( intVal ) ) ; if ( withSpaces ) { sb . append ( ' ' ) ; ... | Takes the provided byte array and converts it into a hexadecimal string with two characters per byte . | 114 | 22 |
40,941 | public static byte [ ] hexToBytes ( String hexString ) { byte [ ] result = new byte [ hexString . length ( ) / 2 ] ; for ( int i = 0 ; i < result . length ; ++ i ) { int offset = i * 2 ; result [ i ] = ( byte ) Integer . parseInt ( hexString . substring ( offset , offset + 2 ) , 16 ) ; } return result ; } | Takes a string in hexadecimal format and converts it to a binary byte array . This does no checking of the format of the input so this should only be used after confirming the format or origin of the string . The input string should only contain the hex data two characters per byte . | 90 | 59 |
40,942 | public static void removeAllCookies ( Context context ) { if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . LOLLIPOP ) { removeAllCookiesV21 ( ) ; } else { removeAllCookiesV14 ( context . getApplicationContext ( ) ) ; } } | Removes all cookies for this application . | 68 | 8 |
40,943 | public static EvernoteInstallStatus getEvernoteInstallStatus ( Context context , String action ) { PackageManager packageManager = context . getPackageManager ( ) ; Intent intent = new Intent ( action ) . setPackage ( PACKAGE_NAME ) ; List < ResolveInfo > resolveInfos = packageManager . queryIntentActivities ( intent ,... | Checks if Evernote is installed and if the app can resolve this action . | 174 | 17 |
40,944 | public static Intent createGetBootstrapProfileNameIntent ( Context context , EvernoteSession evernoteSession ) { if ( evernoteSession . isForceAuthenticationInThirdPartyApp ( ) ) { // we don't want to use the main app, return null return null ; } EvernoteUtil . EvernoteInstallStatus installStatus = EvernoteUtil . getEv... | Returns an Intent to query the bootstrap profile name from the main Evernote app . This is useful if you want to use the main app to authenticate the user and he is already signed in . | 176 | 41 |
40,945 | public static String generateUserAgentString ( Context ctx ) { String packageName = null ; int packageVersion = 0 ; try { packageName = ctx . getPackageName ( ) ; packageVersion = ctx . getPackageManager ( ) . getPackageInfo ( packageName , 0 ) . versionCode ; } catch ( PackageManager . NameNotFoundException e ) { CAT ... | Construct a user - agent string based on the running application and the device and operating system information . This information is included in HTTP requests made to the Evernote service and assists in measuring traffic and diagnosing problems . | 209 | 43 |
40,946 | public synchronized EvernoteHtmlHelper getHtmlHelperDefault ( ) { checkLoggedIn ( ) ; if ( mHtmlHelperDefault == null ) { mHtmlHelperDefault = createHtmlHelper ( mEvernoteSession . getAuthToken ( ) ) ; } return mHtmlHelperDefault ; } | Use this method if you want to download a personal note as HTML . | 67 | 14 |
40,947 | public synchronized EvernoteHtmlHelper getHtmlHelperBusiness ( ) throws TException , EDAMUserException , EDAMSystemException { if ( mHtmlHelperBusiness == null ) { authenticateToBusiness ( ) ; mHtmlHelperBusiness = createHtmlHelper ( mBusinessAuthenticationResult . getAuthenticationToken ( ) ) ; } return mHtmlHelperBus... | Use this method if you want to download a business note as HTML . | 81 | 14 |
40,948 | public Note loadNote ( boolean withContent , boolean withResourcesData , boolean withResourcesRecognition , boolean withResourcesAlternateData ) throws TException , EDAMUserException , EDAMSystemException , EDAMNotFoundException { EvernoteNoteStoreClient noteStore = NoteRefHelper . getNoteStore ( this ) ; if ( noteStor... | Loads the concrete note from the server . | 113 | 9 |
40,949 | public synchronized EvernoteClientFactory getEvernoteClientFactory ( ) { if ( mFactoryThreadLocal == null ) { mFactoryThreadLocal = new ThreadLocal <> ( ) ; } if ( mEvernoteClientFactoryBuilder == null ) { mEvernoteClientFactoryBuilder = new EvernoteClientFactory . Builder ( this ) ; } EvernoteClientFactory factory = m... | Returns a factory to create various clients and helper objects to get access to the Evernote API . | 126 | 20 |
40,950 | public void authenticate ( FragmentActivity activity ) { authenticate ( activity , EvernoteLoginFragment . create ( mConsumerKey , mConsumerSecret , mSupportAppLinkedNotebooks , mLocale ) ) ; } | Recommended approach to authenticate the user . If the main Evernote app is installed and up to date the app is launched and authenticates the user . Otherwise the old OAuth process is launched and the user needs to enter his credentials . | 48 | 48 |
40,951 | public synchronized boolean logOut ( ) { if ( ! isLoggedIn ( ) ) { return false ; } mAuthenticationResult . clear ( ) ; mAuthenticationResult = null ; EvernoteUtil . removeAllCookies ( getApplicationContext ( ) ) ; return true ; } | Clears all stored session information . If the user is not logged in then this is a no - op . | 61 | 22 |
40,952 | public T getValue ( ModelElementInstance modelElement ) { String value ; if ( namespaceUri == null ) { value = modelElement . getAttributeValue ( attributeName ) ; } else { value = modelElement . getAttributeValueNs ( namespaceUri , attributeName ) ; if ( value == null ) { String alternativeNamespace = owningElementTyp... | returns the value of the attribute . | 155 | 8 |
40,953 | private Collection < DomElement > getView ( ModelElementInstanceImpl modelElement ) { return modelElement . getDomElement ( ) . getChildElementsByType ( modelElement . getModelInstance ( ) , childElementTypeClass ) ; } | Internal method providing access to the view represented by this collection . | 50 | 12 |
40,954 | private void performClearOperation ( ModelElementInstanceImpl modelElement , Collection < DomElement > elementsToRemove ) { Collection < ModelElementInstance > modelElements = ModelUtil . getModelElementCollection ( elementsToRemove , modelElement . getModelInstance ( ) ) ; for ( ModelElementInstance element : modelEle... | the clear operation used by this collection | 80 | 7 |
40,955 | @ SuppressWarnings ( "unchecked" ) public T getReferenceTargetElement ( ModelElementInstance referenceSourceElement ) { String identifier = getReferenceIdentifier ( referenceSourceElement ) ; ModelElementInstance referenceTargetElement = referenceSourceElement . getModelInstance ( ) . getModelElementById ( identifier )... | Get the reference target model element instance | 164 | 7 |
40,956 | public void setReferenceTargetElement ( ModelElementInstance referenceSourceElement , T referenceTargetElement ) { ModelInstance modelInstance = referenceSourceElement . getModelInstance ( ) ; String referenceTargetIdentifier = referenceTargetAttribute . getValue ( referenceTargetElement ) ; ModelElementInstance existi... | Set the reference target model element instance | 151 | 7 |
40,957 | public void referencedElementUpdated ( ModelElementInstance referenceTargetElement , String oldIdentifier , String newIdentifier ) { for ( ModelElementInstance referenceSourceElement : findReferenceSourceElements ( referenceTargetElement ) ) { updateReference ( referenceSourceElement , oldIdentifier , newIdentifier ) ;... | Update the reference identifier | 63 | 4 |
40,958 | public void referencedElementRemoved ( ModelElementInstance referenceTargetElement , Object referenceIdentifier ) { for ( ModelElementInstance referenceSourceElement : findReferenceSourceElements ( referenceTargetElement ) ) { if ( referenceIdentifier . equals ( getReferenceIdentifier ( referenceSourceElement ) ) ) { r... | Remove the reference if the target element is removed | 75 | 9 |
40,959 | public static List < String > splitCommaSeparatedList ( String text ) { if ( text == null || text . isEmpty ( ) ) { return Collections . emptyList ( ) ; } Matcher matcher = pattern . matcher ( text ) ; List < String > parts = new ArrayList < String > ( ) ; while ( matcher . find ( ) ) { parts . add ( matcher . group ( ... | Splits a comma separated list in to single Strings . The list can contain expressions with commas in it . | 100 | 23 |
40,960 | private ModelElementInstance findElementToInsertAfter ( ModelElementInstance elementToInsert ) { List < ModelElementType > childElementTypes = elementType . getAllChildElementTypes ( ) ; List < DomElement > childDomElements = domElement . getChildElements ( ) ; Collection < ModelElementInstance > childElements = ModelU... | Returns the element after which the new element should be inserted in the DOM document . | 191 | 16 |
40,961 | private void unlinkAllReferences ( ) { Collection < Attribute < ? > > attributes = elementType . getAllAttributes ( ) ; for ( Attribute < ? > attribute : attributes ) { Object identifier = attribute . getValue ( this ) ; if ( identifier != null ) { ( ( AttributeImpl < ? > ) attribute ) . unlinkReference ( this , identi... | Removes all reference to this . | 82 | 7 |
40,962 | private void unlinkAllChildReferences ( ) { List < ModelElementType > childElementTypes = elementType . getAllChildElementTypes ( ) ; for ( ModelElementType type : childElementTypes ) { Collection < ModelElementInstance > childElementsForType = getChildElementsByType ( type ) ; for ( ModelElementInstance childElement :... | Removes every reference to children of this . | 101 | 9 |
40,963 | public static DomDocument getEmptyDocument ( DocumentBuilderFactory documentBuilderFactory ) { try { DocumentBuilder documentBuilder = documentBuilderFactory . newDocumentBuilder ( ) ; return new DomDocumentImpl ( documentBuilder . newDocument ( ) ) ; } catch ( ParserConfigurationException e ) { throw new ModelParseExc... | Get an empty DOM document | 80 | 5 |
40,964 | public static DomDocument parseInputStream ( DocumentBuilderFactory documentBuilderFactory , InputStream inputStream ) { try { DocumentBuilder documentBuilder = documentBuilderFactory . newDocumentBuilder ( ) ; documentBuilder . setErrorHandler ( new DomErrorHandler ( ) ) ; return new DomDocumentImpl ( documentBuilder ... | Create a new DOM document from the input stream | 157 | 9 |
40,965 | @ SuppressWarnings ( "unchecked" ) public static < T extends ModelElementInstance > Collection < T > getModelElementCollection ( Collection < DomElement > view , ModelInstanceImpl model ) { List < ModelElementInstance > resultList = new ArrayList < ModelElementInstance > ( ) ; for ( DomElement element : view ) { result... | Get a collection of all model element instances in a view | 99 | 11 |
40,966 | public static int getIndexOfElementType ( ModelElementInstance modelElement , List < ModelElementType > childElementTypes ) { for ( int index = 0 ; index < childElementTypes . size ( ) ; index ++ ) { ModelElementType childElementType = childElementTypes . get ( index ) ; Class < ? extends ModelElementInstance > instanc... | Find the index of the type of a model element in a list of element types | 209 | 16 |
40,967 | public static Collection < ModelElementType > calculateAllExtendingTypes ( Model model , Collection < ModelElementType > baseTypes ) { Set < ModelElementType > allExtendingTypes = new HashSet < ModelElementType > ( ) ; for ( ModelElementType baseType : baseTypes ) { ModelElementTypeImpl modelElementTypeImpl = ( ModelEl... | Calculate a collection of all extending types for the given base types | 115 | 14 |
40,968 | public static Collection < ModelElementType > calculateAllBaseTypes ( ModelElementType type ) { List < ModelElementType > baseTypes = new ArrayList < ModelElementType > ( ) ; ModelElementTypeImpl typeImpl = ( ModelElementTypeImpl ) type ; typeImpl . resolveBaseTypes ( baseTypes ) ; return baseTypes ; } | Calculate a collection of all base types for the given type | 70 | 13 |
40,969 | public static void setNewIdentifier ( ModelElementType type , ModelElementInstance modelElementInstance , String newId , boolean withReferenceUpdate ) { Attribute < ? > id = type . getAttribute ( ID_ATTRIBUTE_NAME ) ; if ( id != null && id instanceof StringAttribute && id . isIdAttribute ( ) ) { ( ( StringAttribute ) i... | Set new identifier if the type has a String id attribute | 98 | 11 |
40,970 | public static void setGeneratedUniqueIdentifier ( ModelElementType type , ModelElementInstance modelElementInstance , boolean withReferenceUpdate ) { setNewIdentifier ( type , modelElementInstance , ModelUtil . getUniqueIdentifier ( type ) , withReferenceUpdate ) ; } | Set unique identifier if the type has a String id attribute | 57 | 11 |
40,971 | public static < T > T createInstance ( Class < T > type , Object ... parameters ) { // get types for parameters Class < ? > [ ] parameterTypes = new Class < ? > [ parameters . length ] ; for ( int i = 0 ; i < parameters . length ; i ++ ) { Object parameter = parameters [ i ] ; parameterTypes [ i ] = parameter . getClas... | Create a new instance of the provided type | 144 | 8 |
40,972 | public void resolveExtendingTypes ( Set < ModelElementType > allExtendingTypes ) { for ( ModelElementType modelElementType : extendingTypes ) { ModelElementTypeImpl modelElementTypeImpl = ( ModelElementTypeImpl ) modelElementType ; if ( ! allExtendingTypes . contains ( modelElementTypeImpl ) ) { allExtendingTypes . add... | Resolve all types recursively which are extending this type | 99 | 12 |
40,973 | public void resolveBaseTypes ( List < ModelElementType > baseTypes ) { if ( baseType != null ) { baseTypes . add ( baseType ) ; baseType . resolveBaseTypes ( baseTypes ) ; } } | Resolve all types which are base types of this type | 46 | 11 |
40,974 | public boolean isBaseTypeOf ( ModelElementType elementType ) { if ( this . equals ( elementType ) ) { return true ; } else { Collection < ModelElementType > baseTypes = ModelUtil . calculateAllBaseTypes ( elementType ) ; return baseTypes . contains ( this ) ; } } | Test if a element type is a base type of this type . So this type extends the given element type . | 64 | 22 |
40,975 | public Collection < Attribute < ? > > getAllAttributes ( ) { List < Attribute < ? > > allAttributes = new ArrayList < Attribute < ? > > ( ) ; allAttributes . addAll ( getAttributes ( ) ) ; Collection < ModelElementType > baseTypes = ModelUtil . calculateAllBaseTypes ( this ) ; for ( ModelElementType baseType : baseType... | Returns a list of all attributes including the attributes of all base types . | 105 | 14 |
40,976 | public Attribute < ? > getAttribute ( String attributeName ) { for ( Attribute < ? > attribute : getAllAttributes ( ) ) { if ( attribute . getAttributeName ( ) . equals ( attributeName ) ) { return attribute ; } } return null ; } | Return the attribute for the attribute name | 56 | 7 |
40,977 | private void protectAgainstXxeAttacks ( final DocumentBuilderFactory dbf ) { try { dbf . setFeature ( "http://xml.org/sax/features/external-general-entities" , false ) ; } catch ( ParserConfigurationException ignored ) { } try { dbf . setFeature ( "http://apache.org/xml/features/disallow-doctype-decl" , true ) ; } catc... | Configures the DocumentBuilderFactory in a way that it is protected against XML External Entity Attacks . If the implementing parser does not support one or multiple features the failed feature is ignored . The parser might not protected if the feature assignment fails . | 171 | 47 |
40,978 | public void validateModel ( DomDocument document ) { Schema schema = getSchema ( document ) ; if ( schema == null ) { return ; } Validator validator = schema . newValidator ( ) ; try { synchronized ( document ) { validator . validate ( document . getDomSource ( ) ) ; } } catch ( IOException e ) { throw new ModelValidat... | Validate DOM document | 121 | 4 |
40,979 | private boolean requiresFullyQualifiedName ( ) { String currentPackage = PackageScope . get ( ) ; if ( currentPackage != null ) { if ( definition != null && definition . getPackageName ( ) != null && definition . getFullyQualifiedName ( ) != null ) { String conflictingFQCN = getDefinition ( ) . getFullyQualifiedName ( ... | Checks if the ref needs to be done by fully qualified name . Why? Because an other reference to a class with the same name but different package has been made already . | 241 | 35 |
40,980 | @ SuppressWarnings ( "static-method" ) public void addOperationToGroup ( String tag , String resourcePath , Operation operation , CodegenOperation co , Map < String , List < CodegenOperation > > operations ) { String prefix = co . returnBaseType != null && co . returnBaseType . contains ( "." ) ? co . returnBaseType . ... | Add operation to group | 142 | 4 |
40,981 | private void checkConstructorArguments ( int arguments ) { if ( arguments == 0 && ( typeDef . getConstructors ( ) == null || typeDef . getConstructors ( ) . isEmpty ( ) ) ) { return ; } for ( Method m : typeDef . getConstructors ( ) ) { int a = m . getArguments ( ) != null ? m . getArguments ( ) . size ( ) : 0 ; if ( a... | Checks that a constructor with the required number of arguments is found . | 136 | 14 |
40,982 | private void checkFactoryMethodArguments ( int arguments ) { for ( Method m : typeDef . getMethods ( ) ) { int a = m . getArguments ( ) != null ? m . getArguments ( ) . size ( ) : 0 ; if ( m . getName ( ) . equals ( staticFactoryMethod ) && a == arguments && m . isStatic ( ) ) { return ; } } throw new IllegalArgumentEx... | Checks that a factory method with the required number of arguments is found . | 129 | 15 |
40,983 | private static boolean classExists ( TypeDef typeDef ) { try { Class . forName ( typeDef . getFullyQualifiedName ( ) ) ; return true ; } catch ( ClassNotFoundException e ) { return false ; } } | Checks if class already exists . | 51 | 7 |
40,984 | private static List < Method > adaptConstructors ( List < Method > methods , TypeDef target ) { List < Method > adapted = new ArrayList < Method > ( ) ; for ( Method m : methods ) { adapted . add ( new MethodBuilder ( m ) . withName ( null ) . withReturnType ( target . toUnboundedReference ( ) ) . build ( ) ) ; } retur... | The method adapts constructor method to the current class . It unsets any name that may be presetn in the method . It also sets as a return type a reference to the current type . | 86 | 39 |
40,985 | public String getFullyQualifiedName ( ) { StringBuilder sb = new StringBuilder ( ) ; if ( packageName != null && ! packageName . isEmpty ( ) ) { sb . append ( getPackageName ( ) ) . append ( "." ) ; } if ( outerType != null ) { sb . append ( outerType . getName ( ) ) . append ( "." ) ; } sb . append ( getName ( ) ) ; r... | Returns the fully qualified name of the type . | 108 | 9 |
40,986 | private static String convertReference ( String ref , TypeDef source , TypeDef target , TypeDef targetBuilder ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "new " ) . append ( targetBuilder . getName ( ) ) . append ( "(" ) . append ( convertReference ( ref , source , target ) ) . append ( ")" ) ; return ... | Converts a reference from the source type to the target type by using the builder . | 90 | 17 |
40,987 | private static String convertMap ( String ref , TypeDef source , TypeDef target ) { Method ctor = BuilderUtils . findBuildableConstructor ( target ) ; String arguments = ctor . getArguments ( ) . stream ( ) . map ( p -> readMapValue ( ref , source , p ) ) . collect ( joining ( ",\n" , "\n" , "" ) ) ; StringBuilder sb =... | Converts a map describing the source type to the target . | 146 | 12 |
40,988 | private static String readObjectArrayValue ( String ref , TypeDef source , Property property ) { StringBuilder sb = new StringBuilder ( ) ; Method getter = getterOf ( source , property ) ; TypeRef getterTypeRef = getter . getReturnType ( ) ; TypeRef propertyTypeRef = property . getTypeRef ( ) ; if ( propertyTypeRef ins... | Returns the string representation of the code that reads an object array property . | 445 | 14 |
40,989 | public static boolean hasMethod ( TypeDef typeDef , String method ) { return unrollHierarchy ( typeDef ) . stream ( ) . flatMap ( h -> h . getMethods ( ) . stream ( ) ) . filter ( m -> method . equals ( m . getName ( ) ) ) . findAny ( ) . isPresent ( ) ; } | Check if method exists on the specified type . | 75 | 9 |
40,990 | public static boolean hasProperty ( TypeDef typeDef , String property ) { return unrollHierarchy ( typeDef ) . stream ( ) . flatMap ( h -> h . getProperties ( ) . stream ( ) ) . filter ( p -> property . equals ( p . getName ( ) ) ) . findAny ( ) . isPresent ( ) ; } | Checks if property exists on the specified type . | 76 | 10 |
40,991 | public static Set < TypeDef > unrollHierarchy ( TypeDef typeDef ) { if ( OBJECT . equals ( typeDef ) ) { return new HashSet <> ( ) ; } Set < TypeDef > hierarchy = new HashSet <> ( ) ; hierarchy . add ( typeDef ) ; hierarchy . addAll ( typeDef . getExtendsList ( ) . stream ( ) . flatMap ( s -> unrollHierarchy ( s . getD... | Unrolls the hierararchy of a specified type . | 123 | 12 |
40,992 | public Map < Artifact , Dependency > resolve ( BomConfig config ) throws Exception { Map < Artifact , Dependency > dependencies = new LinkedHashMap < Artifact , Dependency > ( ) ; if ( config != null && config . getImports ( ) != null ) { for ( BomImport bom : config . getImports ( ) ) { Map < Artifact , Dependency > d... | Resolve all imports contained in the given configuration . | 161 | 10 |
40,993 | public static boolean isDescendant ( TypeDef item , TypeDef candidate ) { if ( item == null || candidate == null ) { return false ; } else if ( candidate . isAssignableFrom ( item ) ) { return true ; } return false ; } | Checks if a type is an descendant of an other type | 54 | 12 |
40,994 | public static boolean is ( Method method , boolean acceptPrefixless ) { int length = method . getName ( ) . length ( ) ; if ( method . isPrivate ( ) || method . isStatic ( ) ) { return false ; } if ( ! method . getArguments ( ) . isEmpty ( ) ) { return false ; } if ( method . getReturnType ( ) . equals ( VOID ) ) { ret... | Checks if the specified method is a getter . | 244 | 11 |
40,995 | static String readAnyField ( Object obj , String ... names ) { try { for ( String name : names ) { try { Field field = obj . getClass ( ) . getDeclaredField ( name ) ; field . setAccessible ( true ) ; return ( String ) field . get ( obj ) ; } catch ( NoSuchFieldException e ) { //ignore and try next field... } } return ... | Read any field that matches the specified name . | 100 | 9 |
40,996 | private static < V , F > Boolean hasCompatibleVisitMethod ( V visitor , F fluent ) { for ( Method method : visitor . getClass ( ) . getMethods ( ) ) { if ( ! method . getName ( ) . equals ( VISIT ) || method . getParameterTypes ( ) . length != 1 ) { continue ; } Class visitorType = method . getParameterTypes ( ) [ 0 ] ... | Checks if the specified visitor has a visit method compatible with the specified fluent . | 121 | 16 |
40,997 | public static final String toPojoName ( String name , String prefix , String suffix ) { LinkedList < String > parts = new LinkedList <> ( Arrays . asList ( name . split ( SPLITTER_REGEX ) ) ) ; if ( parts . isEmpty ( ) ) { return prefix + name + suffix ; } if ( parts . getFirst ( ) . equals ( "I" ) ) { parts . removeFi... | Converts a name of an interface or abstract class to Pojo name . Remove leading I and Abstract or trailing Interface . | 179 | 24 |
40,998 | public void generatePojos ( BuilderContext builderContext , Set < TypeDef > buildables ) { Set < TypeDef > additonalBuildables = new HashSet <> ( ) ; Set < TypeDef > additionalTypes = new HashSet <> ( ) ; for ( TypeDef typeDef : buildables ) { try { if ( typeDef . isInterface ( ) || typeDef . isAnnotation ( ) ) { typeD... | Returns true if pojos where generated . | 410 | 9 |
40,999 | public static boolean methodHasArgument ( Method method , Property property ) { for ( Property candidate : method . getArguments ( ) ) { if ( candidate . equals ( property ) ) { return true ; } } return false ; } | Checks if method has a specific argument . | 48 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.