idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
6,400
void computeScroll ( ) { if ( ! overScroller . computeScrollOffset ( ) ) { isScrollingFast = false ; return ; } int distanceX = overScroller . getCurrX ( ) - view . getScrollX ( ) ; int distanceY = overScroller . getCurrY ( ) - view . getScrollY ( ) ; int dX = ( int ) calculateDx ( distanceX ) ; int dY = ( int ) calculateDy ( distanceY ) ; boolean stopScrolling = dX == 0 && dY == 0 ; if ( stopScrolling ) { isScrollingFast = false ; } view . scrollBy ( dX , dY ) ; }
Computes the current scroll using a OverScroller instance and the time lapsed from the previous call . Also controls if the view is performing a fast scroll after a fling gesture .
6,401
private GestureDetectorCompat getGestureDetector ( ) { if ( gestureDetector == null ) { gestureDetector = new GestureDetectorCompat ( view . getContext ( ) , gestureListener ) ; } return gestureDetector ; }
Returns the GestureDetectorCompat instance where the view should delegate touch events .
6,402
private float calculateDx ( float distanceX ) { int currentX = view . getScrollX ( ) ; float nextX = distanceX + currentX ; boolean isInsideHorizontally = nextX >= minX && nextX <= maxX ; return isInsideHorizontally ? distanceX : 0 ; }
Returns the distance in the X axes to perform the scroll taking into account the view boundary .
6,403
private float calculateDy ( float distanceY ) { int currentY = view . getScrollY ( ) ; float nextY = distanceY + currentY ; boolean isInsideVertically = nextY >= minY && nextY <= maxY ; return isInsideVertically ? distanceY : 0 ; }
Returns the distance in the Y axes to perform the scroll taking into account the view boundary .
6,404
public boolean isValidGitRepository ( Path folder ) { if ( Files . exists ( folder ) && Files . isDirectory ( folder ) ) { if ( RepositoryCache . FileKey . isGitRepository ( folder . toFile ( ) , FS . DETECTED ) ) { return true ; } else { return false ; } } else { return false ; } }
Checks if given folder is a git repository
6,405
public Ref checkoutTag ( Git git , String tag ) { try { return git . checkout ( ) . setName ( "tags/" + tag ) . call ( ) ; } catch ( GitAPIException e ) { throw new IllegalStateException ( e ) ; } }
Checkout existing tag .
6,406
public boolean isLocalBranch ( final Git git , final String branch ) { try { final List < Ref > refs = git . branchList ( ) . call ( ) ; return refs . stream ( ) . anyMatch ( ref -> ref . getName ( ) . endsWith ( branch ) ) ; } catch ( GitAPIException e ) { throw new IllegalStateException ( e ) ; } }
Checks if given branch has been checkedout locally too .
6,407
public boolean isRemoteBranch ( final Git git , final String branch , final String remote ) { try { final List < Ref > refs = git . branchList ( ) . setListMode ( ListBranchCommand . ListMode . REMOTE ) . call ( ) ; final String remoteBranch = remote + "/" + branch ; return refs . stream ( ) . anyMatch ( ref -> ref . getName ( ) . endsWith ( remoteBranch ) ) ; } catch ( GitAPIException e ) { throw new IllegalStateException ( e ) ; } }
Checks if given branch is remote .
6,408
public Ref checkoutBranch ( Git git , String branch ) { try { return git . checkout ( ) . setName ( branch ) . call ( ) ; } catch ( GitAPIException e ) { throw new IllegalStateException ( e ) ; } }
Checkout existing branch .
6,409
public Ref createBranchAndCheckout ( Git git , String branch ) { try { return git . checkout ( ) . setCreateBranch ( true ) . setName ( branch ) . setUpstreamMode ( CreateBranchCommand . SetupUpstreamMode . TRACK ) . call ( ) ; } catch ( GitAPIException e ) { throw new IllegalStateException ( e ) ; } }
Executes a checkout - b command using given branch .
6,410
public RevCommit addAndCommit ( Git git , String message ) { try { git . add ( ) . addFilepattern ( "." ) . call ( ) ; return git . commit ( ) . setMessage ( message ) . call ( ) ; } catch ( GitAPIException e ) { throw new IllegalStateException ( e ) ; } }
Add all files and commit them with given message . This is equivalent as doing git add . git commit - m message .
6,411
public Ref createTag ( Git git , String name ) { try { return git . tag ( ) . setName ( name ) . call ( ) ; } catch ( GitAPIException e ) { throw new IllegalStateException ( e ) ; } }
Creates a tag .
6,412
public Git cloneRepository ( String remoteUrl , Path localPath ) { try { return Git . cloneRepository ( ) . setURI ( remoteUrl ) . setDirectory ( localPath . toFile ( ) ) . call ( ) ; } catch ( GitAPIException e ) { throw new IllegalStateException ( e ) ; } }
Clones a public remote git repository . Caller is responsible of closing git repository .
6,413
public boolean hasAtLeastOneReference ( Repository repo ) { for ( Ref ref : repo . getAllRefs ( ) . values ( ) ) { if ( ref . getObjectId ( ) == null ) continue ; return true ; } return false ; }
Checks if a repo has been cloned correctly .
6,414
public List < Node > removeChildren ( final String name ) throws IllegalArgumentException { if ( name == null || name . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( "Path must not be null or empty" ) ; } List < Node > found = get ( name ) ; for ( Node child : found ) { children . remove ( child ) ; } return found ; }
Remove all child nodes found at the given query .
6,415
public String getTextValueForPatternName ( final String name ) { Node n = this . getSingle ( name ) ; String text = n == null ? null : n . getText ( ) ; return text ; }
Get the text value of the element found at the given query name . If no element is found or no text exists return null ;
6,416
public List < String > getTextValuesForPatternName ( final String name ) { List < String > result = new ArrayList < String > ( ) ; List < Node > jars = this . get ( name ) ; for ( Node node : jars ) { String text = node . getText ( ) ; if ( text != null ) { result . add ( text ) ; } } return Collections . unmodifiableList ( result ) ; }
Get the text values of all elements found at the given query name . If no elements are found or no text exists return an empty list ;
6,417
private Pattern [ ] validateAndMergePatternInput ( final Pattern pattern , final Pattern ... patterns ) { if ( pattern == null ) { throw new IllegalArgumentException ( "At least one pattern must not be specified" ) ; } final List < Pattern > merged = new ArrayList < Pattern > ( ) ; merged . add ( pattern ) ; for ( final Pattern p : patterns ) { merged . add ( p ) ; } return merged . toArray ( PATTERN_CAST ) ; }
Validates that at least one pattern was specified merges all patterns together and returns the result
6,418
public static < T extends Descriptor > T create ( final Class < T > type ) throws IllegalArgumentException { return create ( type , null ) ; }
Creates a new Descriptor instance ; the predefined default descriptor name for this type will be used .
6,419
public void generateEnums ( ) throws JClassAlreadyExistsException , IOException { final JCodeModel cm = new JCodeModel ( ) ; for ( final MetadataEnum metadataEnum : metadata . getEnumList ( ) ) { final String fqnEnum = metadataEnum . getPackageApi ( ) + "." + getPascalizeCase ( metadataEnum . getName ( ) ) ; final JDefinedClass dc = cm . _class ( fqnEnum , ClassType . ENUM ) ; final JDocComment javaDocComment = dc . javadoc ( ) ; final Map < String , String > part = javaDocComment . addXdoclet ( "author" ) ; part . put ( "<a href" , "'mailto:ralf.battenfeld@bluewin.ch'>Ralf Battenfeld</a>" ) ; for ( final String enumConstant : metadataEnum . getValueList ( ) ) { dc . enumConstant ( getEnumConstantName ( enumConstant ) ) ; } final JMethod toStringMethod = dc . method ( 1 , String . class , "toString" ) ; toStringMethod . body ( ) . _return ( JExpr . direct ( "name().substring(1)" ) ) ; } final File file = new File ( "./src/test/java" ) ; file . mkdirs ( ) ; cm . build ( file ) ; }
Generates all enumeration classes .
6,420
public boolean isEnum ( final String elementType ) { final String namespace = splitElementType ( elementType ) [ 0 ] ; final String localname = splitElementType ( elementType ) [ 1 ] ; boolean isEnum = false ; for ( final MetadataEnum metadataEnum : metadata . getEnumList ( ) ) { if ( metadataEnum . getName ( ) . equals ( localname ) && metadataEnum . getNamespace ( ) . equals ( namespace ) ) { isEnum = true ; break ; } } return isEnum ; }
Returns true if the given string argument represents a enumeration class .
6,421
public static Long getProfileLastModifiedCookie ( HttpServletRequest request ) { String profileLastModified = HttpUtils . getCookieValue ( PROFILE_LAST_MODIFIED_COOKIE_NAME , request ) ; if ( StringUtils . isNotEmpty ( profileLastModified ) ) { try { return new Long ( profileLastModified ) ; } catch ( NumberFormatException e ) { logger . error ( "Invalid profile last modified cookie format: {}" , profileLastModified ) ; } } return null ; }
Returns the last modified timestamp cookie from the request .
6,422
public static Authentication getCurrentAuthentication ( ) { RequestContext context = RequestContext . getCurrent ( ) ; if ( context != null ) { return getAuthentication ( context . getRequest ( ) ) ; } else { return null ; } }
Returns the authentication attribute from the current request .
6,423
public static void setCurrentAuthentication ( Authentication authentication ) { RequestContext context = RequestContext . getCurrent ( ) ; if ( context != null ) { setAuthentication ( context . getRequest ( ) , authentication ) ; } }
Sets the authentication attribute in the current request .
6,424
public static void removeCurrentAuthentication ( ) { RequestContext context = RequestContext . getCurrent ( ) ; if ( context != null ) { removeAuthentication ( context . getRequest ( ) ) ; } }
Removes the authentication attribute from the current request .
6,425
public static Profile getCurrentProfile ( ) { RequestContext context = RequestContext . getCurrent ( ) ; if ( context != null ) { return getProfile ( context . getRequest ( ) ) ; } else { return null ; } }
Returns the profile from authentication attribute from the current request .
6,426
public static Profile getProfile ( HttpServletRequest request ) { Authentication auth = getAuthentication ( request ) ; if ( auth != null ) { return auth . getProfile ( ) ; } else { return null ; } }
Returns the profile from authentication attribute from the specified request .
6,427
public void setUrlRestrictions ( Map < String , String > restrictions ) { urlRestrictions = new LinkedHashMap < > ( ) ; ExpressionParser parser = new SpelExpressionParser ( ) ; for ( Map . Entry < String , String > entry : restrictions . entrySet ( ) ) { urlRestrictions . put ( entry . getKey ( ) , parser . parseExpression ( entry . getValue ( ) ) ) ; } }
Sets the map of restrictions . Each key of the map is ANT - style path pattern used to match the URLs of incoming requests and each value is a Spring EL expression .
6,428
private void loadImage ( ) { List < Transformation > transformations = getTransformations ( ) ; boolean hasUrl = url != null ; boolean hasResourceId = resourceId != null ; boolean hasPlaceholder = placeholderId != null ; ListenerTarget listenerTarget = getLinearTarget ( listener ) ; if ( hasUrl ) { RequestCreator bitmapRequest = Picasso . with ( context ) . load ( url ) . tag ( PICASSO_IMAGE_LOADER_TAG ) ; applyPlaceholder ( bitmapRequest ) . resize ( size , size ) . transform ( transformations ) . into ( listenerTarget ) ; } else if ( hasResourceId || hasPlaceholder ) { Resources resources = context . getResources ( ) ; Drawable placeholder = null ; Drawable drawable = null ; if ( hasPlaceholder ) { placeholder = resources . getDrawable ( placeholderId ) ; listenerTarget . onPrepareLoad ( placeholder ) ; } if ( hasResourceId ) { drawable = resources . getDrawable ( resourceId ) ; listenerTarget . onDrawableLoad ( drawable ) ; } } else { throw new IllegalArgumentException ( "Review your request, you are trying to load an image without a url or a resource id." ) ; } }
Uses the configuration previously applied using this ImageLoader builder to download a resource asynchronously and notify the result to the listener .
6,429
private ListenerTarget getLinearTarget ( final Listener listener ) { ListenerTarget target = targets . get ( listener ) ; if ( target == null ) { target = new ListenerTarget ( listener ) ; targets . put ( listener , target ) ; } return target ; }
Given a listener passed as argument creates or returns a lazy instance of a Picasso Target . This implementation is needed because Picasso doesn t keep a strong reference to the target passed as parameter . Without this method Picasso looses the reference to the target and never notifies when the resource has been downloaded .
6,430
private void delegate ( RequestDelegationService service , HttpServletRequest request , HttpServletResponse response , FilterChain filterChain ) { try { service . delegate ( request , response , filterChain ) ; } catch ( Exception e ) { throw new RequestDelegationException ( String . format ( "The request processing delegation failed: %s" , e . getCause ( ) ) , e ) ; } }
Delegates given request and response to be processed by given service .
6,431
private boolean canDelegate ( RequestDelegationService delegate , HttpServletRequest request ) { try { return delegate . canDelegate ( request ) ; } catch ( Exception e ) { log . log ( Level . SEVERE , String . format ( "The delegation service can't check the delegability of the request: %s" , e . getCause ( ) ) , e . getCause ( ) ) ; return false ; } }
Checks whether the given service can serve given request .
6,432
void awaitRequests ( ) { if ( ! isWaitingForEnriching ( ) ) { return ; } for ( int i = 0 ; i < NUMBER_OF_WAIT_LOOPS ; i ++ ) { try { Thread . sleep ( THREAD_SLEEP ) ; if ( ! isEnrichmentAdvertised ( ) ) { return ; } } catch ( InterruptedException e ) { throw new IllegalStateException ( e ) ; } } throw new SettingRequestTimeoutException ( ) ; }
Await client activity causing requests in order to enrich requests
6,433
void awaitResponses ( ) { try { boolean finishedNicely = responseFinished . await ( WAIT_TIMEOUT_MILISECONDS , TimeUnit . MILLISECONDS ) ; if ( ! finishedNicely ) { throw new WarpSynchronizationException ( WarpContextStore . get ( ) ) ; } } catch ( InterruptedException e ) { } }
Await responses for requests or premature finishing
6,434
public void setDateTimeZone ( Object dtz ) throws JspTagException { if ( dtz == null || dtz instanceof String && ( ( String ) dtz ) . length ( ) == 0 ) { this . dateTimeZone = null ; } else if ( dtz instanceof DateTimeZone ) { this . dateTimeZone = ( DateTimeZone ) dtz ; } else { try { this . dateTimeZone = DateTimeZone . forID ( ( String ) dtz ) ; } catch ( IllegalArgumentException iae ) { this . dateTimeZone = DateTimeZone . UTC ; } } }
Sets the zone attribute .
6,435
public void setLocale ( Object loc ) throws JspTagException { if ( loc == null || ( loc instanceof String && ( ( String ) loc ) . length ( ) == 0 ) ) { this . locale = null ; } else if ( loc instanceof Locale ) { this . locale = ( Locale ) loc ; } else { locale = Util . parseLocale ( ( String ) loc ) ; } }
Sets the style attribute .
6,436
protected boolean hasNoInvalidScope ( Attributes a ) { String scope = a . getValue ( SCOPE ) ; if ( ( scope != null ) && ! scope . equals ( PAGE_SCOPE ) && ! scope . equals ( REQUEST_SCOPE ) && ! scope . equals ( SESSION_SCOPE ) && ! scope . equals ( APPLICATION_SCOPE ) ) { return false ; } return true ; }
returns true if the scope attribute is valid
6,437
protected boolean hasDanglingScope ( Attributes a ) { return ( a . getValue ( SCOPE ) != null && a . getValue ( VAR ) == null ) ; }
returns true if the scope attribute is present without var
6,438
protected String getLocalPart ( String qname ) { int colon = qname . indexOf ( ":" ) ; return ( colon == - 1 ) ? qname : qname . substring ( colon + 1 ) ; }
retrieves the local part of a QName
6,439
private void executeGetOperation ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ClassNotFoundException { if ( request . getContentLength ( ) > 0 ) { response . setStatus ( HttpServletResponse . SC_NO_CONTENT ) ; ObjectInputStream input = new ObjectInputStream ( new BufferedInputStream ( request . getInputStream ( ) ) ) ; CommandPayload paylod = ( CommandPayload ) input . readObject ( ) ; events . put ( currentCall , paylod ) ; } else { if ( events . containsKey ( currentCall ) && ! events . get ( currentCall ) . isExecuted ( ) ) { response . setStatus ( HttpServletResponse . SC_OK ) ; ObjectOutputStream output = new ObjectOutputStream ( response . getOutputStream ( ) ) ; output . writeObject ( events . remove ( currentCall ) ) ; output . flush ( ) ; output . close ( ) ; } else { response . setStatus ( HttpServletResponse . SC_NO_CONTENT ) ; } } }
Container - to - Client command execution
6,440
private void executePutOperation ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ClassNotFoundException { if ( request . getContentLength ( ) > 0 ) { ObjectInputStream input = new ObjectInputStream ( new BufferedInputStream ( request . getInputStream ( ) ) ) ; CommandPayload payload = ( CommandPayload ) input . readObject ( ) ; Command operation = payload . getCommand ( ) ; Manager manager = ( Manager ) request . getAttribute ( ARQUILLIAN_MANAGER_ATTRIBUTE ) ; try { manager . fire ( new ActivateManager ( manager ) ) ; manager . inject ( operation ) ; operation . perform ( ) ; manager . fire ( new PassivateManager ( manager ) ) ; } catch ( Throwable e ) { payload . setThrowable ( e ) ; } response . setStatus ( HttpServletResponse . SC_OK ) ; ObjectOutputStream output = new ObjectOutputStream ( response . getOutputStream ( ) ) ; output . writeObject ( payload ) ; output . flush ( ) ; output . close ( ) ; } else { response . setStatus ( HttpServletResponse . SC_NO_CONTENT ) ; } }
Client - to - Container event propagation
6,441
public FutureData < Dpu > dpu ( String historicsId ) { final FutureData < Dpu > future = new FutureData < Dpu > ( ) ; URI uri = newParams ( ) . put ( "historics_id" , historicsId ) . forURL ( config . newAPIEndpointURI ( DPU ) ) ; Request request = config . http ( ) . GET ( uri , new PageReader ( newRequestCallback ( future , new Dpu ( ) , config ) ) ) ; performRequest ( future , request ) ; return future ; }
Retrieve the DPU usage of a historics job
6,442
private String computeRequestMethod ( Element e ) { for ( AnnotationMirror am : e . getAnnotationMirrors ( ) ) { final String typeString = am . getAnnotationType ( ) . toString ( ) ; if ( typeString . endsWith ( ".GET" ) ) { return "GET" ; } else if ( typeString . endsWith ( ".PUT" ) ) { return "PUT" ; } else if ( typeString . endsWith ( ".POST" ) ) { return "POST" ; } else if ( typeString . endsWith ( ".PATCH" ) ) { return "PATCH" ; } else if ( typeString . endsWith ( ".DELETE" ) ) { return "DELETE" ; } } return null ; }
Find the request method annotation the method was annotated with and return a string representing the request method .
6,443
private void generateOutput ( ) { final Filer filer = processingEnv . getFiler ( ) ; writeJsonToFile ( filer , "JSONClasses" , jsonClasses ) ; writeJsonToFile ( filer , "debugcrud" , debugMessages ) ; final List < ResourceMethod > resources = Lists . newArrayList ( ) ; for ( ResourceClass klass : resourceClasses . values ( ) ) { final String path = klass . getPath ( ) ; for ( final ResourceMethod method : klass . getMembers ( ) ) { resources . add ( new ResourceMethod ( "" , method . getMethod ( ) , computeDisplayPath ( path , method . getPath ( ) ) , method . getReturnContentType ( ) , method . getReturnType ( ) , method . getArguments ( ) , method . getJavadoc ( ) ) ) ; } } writeJsonToFile ( filer , "RESTEndpoints" , resources ) ; }
Dump the contents of our discoveries .
6,444
public void process ( TestDeployment testDeployment , Archive < ? > protocolArchive ) { final TestClass testClass = this . testClass . get ( ) ; final Archive < ? > applicationArchive = testDeployment . getApplicationArchive ( ) ; if ( WarpCommons . isWarpTest ( testClass . getJavaClass ( ) ) ) { if ( ! Validate . isArchiveOfType ( WebArchive . class , protocolArchive ) ) { throw new IllegalArgumentException ( "Protocol archives of type " + protocolArchive . getClass ( ) + " not supported by Warp. Please use the Servlet 3.0 protocol." ) ; } addWarpPackageToDeployment ( protocolArchive . as ( WebArchive . class ) ) ; addWarpExtensionsDeployment ( protocolArchive . as ( WebArchive . class ) ) ; removeTestClassFromDeployment ( applicationArchive , testClass ) ; } }
Adds Warp archive to the protocol archive to make it available for WARs and EARs .
6,445
private void addWarpExtensionsDeployment ( WebArchive archive ) { final Collection < WarpDeploymentEnrichmentExtension > lifecycleExtensions = serviceLoader . get ( ) . all ( WarpDeploymentEnrichmentExtension . class ) ; for ( WarpDeploymentEnrichmentExtension extension : lifecycleExtensions ) { JavaArchive library = extension . getEnrichmentLibrary ( ) ; if ( library != null ) { archive . addAsLibrary ( library ) ; } extension . enrichWebArchive ( archive ) ; } }
Adds all Warp lifecycle extension packages to the archive
6,446
public static int getScope ( String scope ) { int ret = PageContext . PAGE_SCOPE ; if ( REQUEST . equalsIgnoreCase ( scope ) ) { ret = PageContext . REQUEST_SCOPE ; } else if ( SESSION . equalsIgnoreCase ( scope ) ) { ret = PageContext . SESSION_SCOPE ; } else if ( APPLICATION . equalsIgnoreCase ( scope ) ) { ret = PageContext . APPLICATION_SCOPE ; } return ret ; }
Converts the given string description of a scope to the corresponding PageContext constant .
6,447
private static Locale findFormattingMatch ( Locale pref , Locale [ ] avail ) { Locale match = null ; boolean langAndCountryMatch = false ; for ( int i = 0 ; i < avail . length ; i ++ ) { if ( pref . equals ( avail [ i ] ) ) { match = avail [ i ] ; break ; } else if ( ! "" . equals ( pref . getVariant ( ) ) && "" . equals ( avail [ i ] . getVariant ( ) ) && pref . getLanguage ( ) . equals ( avail [ i ] . getLanguage ( ) ) && pref . getCountry ( ) . equals ( avail [ i ] . getCountry ( ) ) ) { match = avail [ i ] ; langAndCountryMatch = true ; } else if ( ! langAndCountryMatch && pref . getLanguage ( ) . equals ( avail [ i ] . getLanguage ( ) ) && ( "" . equals ( avail [ i ] . getCountry ( ) ) ) ) { if ( match == null ) { match = avail [ i ] ; } } } return match ; }
Returns the best match between the given preferred locale and the given available locales .
6,448
public static LocalizationContext getLocalizationContext ( PageContext pc ) { LocalizationContext locCtxt = null ; Object obj = Config . find ( pc , Config . FMT_LOCALIZATION_CONTEXT ) ; if ( obj == null ) { return null ; } if ( obj instanceof LocalizationContext ) { locCtxt = ( LocalizationContext ) obj ; } else { locCtxt = getLocalizationContext ( pc , ( String ) obj ) ; } return locCtxt ; }
Gets the default I18N localization context .
6,449
public RestRequestBuilder < B , R > addQueryParam ( String name , Collection < ? > values ) { if ( null != values ) { List < Object > allValues = getQueryParams ( name ) ; allValues . addAll ( values ) ; } return this ; }
Add a query parameter . If a null or empty collection is passed the param is ignored .
6,450
public RestRequestBuilder < B , R > addQueryParam ( String name , Object [ ] values ) { if ( null != values ) { List < Object > allValues = getQueryParams ( name ) ; for ( Object value : values ) { allValues . add ( value ) ; } } return this ; }
Add a query parameter . If a null or empty array is passed the param is ignored .
6,451
public static byte [ ] encodeInteger ( BigInteger bigInt ) { if ( bigInt == null ) { throw new NullPointerException ( "encodeInteger called with null parameter" ) ; } return encodeBase64 ( toIntegerBytes ( bigInt ) , false ) ; }
Encodes to a byte64 - encoded integer according to crypto standards such as W3C s XML - Signature
6,452
private String removeEnclosedCurlyBraces ( String str ) { final char curlyReplacement = 6 ; char [ ] chars = str . toCharArray ( ) ; int open = 0 ; for ( int i = 0 ; i < chars . length ; i ++ ) { if ( chars [ i ] == '{' ) { if ( open != 0 ) chars [ i ] = curlyReplacement ; open ++ ; } else if ( chars [ i ] == '}' ) { open -- ; if ( open != 0 ) { chars [ i ] = curlyReplacement ; } } } char [ ] res = new char [ chars . length ] ; int j = 0 ; for ( int i = 0 ; i < chars . length ; i ++ ) { if ( chars [ i ] != curlyReplacement ) { res [ j ++ ] = chars [ i ] ; } } return new String ( Arrays . copyOf ( res , j ) ) ; }
Enclosed curly braces cannot be matched with a regex . Thus we remove them before applying the replaceAll method
6,453
public static WarpExecutionBuilder initiate ( Activity activity ) { WarpRuntime runtime = WarpRuntime . getInstance ( ) ; if ( runtime == null ) { throw new IllegalStateException ( "The Warp runtime isn't initialized. You need to make sure arquillian-warp-impl is on classpath and annotate a test class with @WarpTest in order to initialize Warp." ) ; } return runtime . getWarpActivityBuilder ( ) . initiate ( activity ) ; }
Takes client activity which should be performed in order to cause server request .
6,454
public int readInt ( ) throws IOException { int value = 0 ; value += ( read ( ) & 0xff ) << 0 ; value += ( read ( ) & 0xff ) << 8 ; value += ( read ( ) & 0xff ) << 16 ; value += ( read ( ) & 0xff ) << 24 ; return ( int ) value ; }
Read 32bit word as integer .
6,455
public int [ ] readIntArray ( int length ) throws IOException { int arr [ ] = new int [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { arr [ i ] = readInt ( ) ; } return arr ; }
Read an array of 32bit words .
6,456
public byte [ ] readByteArray ( int length ) throws IOException { byte buf [ ] = new byte [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { buf [ i ] = ( byte ) read ( ) ; } return buf ; }
Read an array of bytes .
6,457
public static void asUnchecked ( Throwable t , Class < ? extends RuntimeException > checkedExceptionWrapper ) { if ( t instanceof AssertionError ) { throw ( AssertionError ) t ; } else if ( t instanceof RuntimeException ) { throw ( RuntimeException ) t ; } else { RuntimeException exception ; try { exception = checkedExceptionWrapper . getConstructor ( Throwable . class ) . newInstance ( t ) ; } catch ( Exception e ) { throw new RuntimeException ( t ) ; } throw exception ; } }
Checks whether given throwable is unchecked and if not it will be wrapped as unchecked exception of given type
6,458
public static String getMessage ( String name , Object [ ] a ) throws MissingResourceException { String res = rb . getString ( name ) ; return MessageFormat . format ( res , a ) ; }
Retrieves a message with arbitrarily many arguments .
6,459
public static String getMessage ( String name , Object a1 , Object a2 , Object a3 , Object a4 ) throws MissingResourceException { return getMessage ( name , new Object [ ] { a1 , a2 , a3 , a4 } ) ; }
Retrieves a message with four arguments .
6,460
static Class < ? > [ ] getAncestors ( Class < ? > clazz ) { Set < Class < ? > > classes = new HashSet < Class < ? > > ( ) ; while ( clazz != null ) { classes . add ( clazz ) ; if ( clazz . getSuperclass ( ) != null ) { classes . add ( clazz . getSuperclass ( ) ) ; } classes . addAll ( Arrays . asList ( clazz . getInterfaces ( ) ) ) ; for ( Class < ? > interfaze : clazz . getInterfaces ( ) ) { classes . addAll ( Arrays . asList ( getAncestors ( interfaze ) ) ) ; } clazz = clazz . getSuperclass ( ) ; } return classes . toArray ( new Class < ? > [ classes . size ( ) ] ) ; }
Get all subclasses and interfaces in whole class hierarchy
6,461
private TypeSpec generateBuilder ( RestService restService ) { TypeSpec . Builder typeBuilder = TypeSpec . classBuilder ( restService . getBuilderSimpleClassName ( ) ) . addModifiers ( Modifier . PUBLIC , Modifier . FINAL ) . addJavadoc ( "Generated REST service builder for {@link $L}.\n" , restService . getTypeElement ( ) . getQualifiedName ( ) ) . addMethod ( MethodSpec . constructorBuilder ( ) . addModifiers ( Modifier . PRIVATE ) . build ( ) ) ; Map < TypeMirror , MethodSpec > mapperGetters = buildMappers ( typeBuilder , restService ) ; for ( RestServiceMethod method : restService . getMethods ( ) ) { buildMethod ( typeBuilder , mapperGetters , method ) ; } return typeBuilder . build ( ) ; }
Generate the rest service builder
6,462
public void note ( Element e , String msg , Object ... args ) { messager . printMessage ( Diagnostic . Kind . NOTE , String . format ( msg , args ) , e ) ; }
Prints a note message
6,463
public void warn ( Element e , String msg , Object ... args ) { messager . printMessage ( Diagnostic . Kind . WARNING , String . format ( msg , args ) , e ) ; }
Prints a warning message
6,464
public void error ( Element e , String msg , Object ... args ) { messager . printMessage ( Diagnostic . Kind . ERROR , String . format ( msg , args ) , e ) ; }
Prints an error message
6,465
public FacebookPage addInstagramLinkedPage ( String pageid ) { ResourceParams parameterSet = newResourceParams ( ) ; parameterSet . set ( "id" , pageid ) ; parameterSet . set ( "type" , "instagram" ) ; return this ; }
Add a facebook page to be crawled for instagram content
6,466
public FacebookPage addInstagramUser ( String username ) { ResourceParams parameterSet = newResourceParams ( ) ; parameterSet . set ( "id" , username ) ; parameterSet . set ( "type" , "instagram_user" ) ; return this ; }
Add an instagram user to be crawled for content
6,467
private < T > T execute ( String url , Class < T > returnType , Object requestObject ) throws Exception { URLConnection connection = new URL ( url ) . openConnection ( ) ; if ( ! ( connection instanceof HttpURLConnection ) ) { throw new IllegalStateException ( "Not an http connection! " + connection ) ; } HttpURLConnection httpConnection = ( HttpURLConnection ) connection ; httpConnection . setUseCaches ( false ) ; httpConnection . setDefaultUseCaches ( false ) ; httpConnection . setDoInput ( true ) ; httpConnection . setInstanceFollowRedirects ( false ) ; try { if ( requestObject != null ) { httpConnection . setRequestMethod ( "POST" ) ; httpConnection . setDoOutput ( true ) ; httpConnection . setRequestProperty ( "Content-Type" , "application/octet-stream" ) ; } if ( requestObject != null ) { ObjectOutputStream ous = new ObjectOutputStream ( httpConnection . getOutputStream ( ) ) ; try { ous . writeObject ( requestObject ) ; } catch ( Exception e ) { throw new RuntimeException ( "Error sending request Object, " + requestObject , e ) ; } finally { ous . flush ( ) ; ous . close ( ) ; } } try { httpConnection . getResponseCode ( ) ; } catch ( ConnectException e ) { return null ; } if ( httpConnection . getResponseCode ( ) == HttpURLConnection . HTTP_OK ) { ObjectInputStream ois = new ObjectInputStream ( httpConnection . getInputStream ( ) ) ; Object o ; try { o = ois . readObject ( ) ; } finally { ois . close ( ) ; } if ( ! returnType . isInstance ( o ) ) { throw new IllegalStateException ( "Error reading results, expected a " + returnType . getName ( ) + " but got " + o ) ; } return returnType . cast ( o ) ; } else if ( httpConnection . getResponseCode ( ) == HttpURLConnection . HTTP_NO_CONTENT ) { return null ; } else if ( httpConnection . getResponseCode ( ) == HttpURLConnection . HTTP_MOVED_TEMP ) { String redirectUrl = httpConnection . getHeaderField ( "Location" ) ; return execute ( redirectUrl , returnType , requestObject ) ; } else if ( httpConnection . getResponseCode ( ) != HttpURLConnection . HTTP_NOT_FOUND ) { throw new IllegalStateException ( "Error launching test at " + url + ". " + "Got " + httpConnection . getResponseCode ( ) + " (" + httpConnection . getResponseMessage ( ) + ")" ) ; } } finally { httpConnection . disconnect ( ) ; } return null ; }
Executes the request to the remote url
6,468
private Grammar getEqualGrammar ( Grammar gr ) { for ( Grammar gx : this . grammars ) { if ( gr == gx ) { return gx ; } if ( isSameGrammarType ( gr , gx ) ) { if ( gr . getNumberOfEvents ( ) == gx . getNumberOfEvents ( ) ) { List < Grammar > handled = new ArrayList < Grammar > ( ) ; if ( isEqualGrammar ( gr , gx , handled ) ) { return gx ; } } } } return null ; }
! = null ... found equal grammar
6,469
private synchronized void compile ( Token tok ) { if ( this . operations != null ) return ; this . numberOfClosures = 0 ; this . operations = this . compile ( tok , null , false ) ; }
Compiles a token tree into an operation flow .
6,470
protected SchemaInformedFirstStartTagGrammar translateSimpleTypeDefinitionToFSA ( XSSimpleTypeDefinition std ) throws EXIException { Characters chSchemaValid = new Characters ( getDatatype ( std ) ) ; SchemaInformedGrammar simpleContentEnd = SIMPLE_END_ELEMENT_RULE ; SchemaInformedElement simpleContent = new SchemaInformedElement ( ) ; simpleContent . addProduction ( chSchemaValid , simpleContentEnd ) ; SchemaInformedFirstStartTagGrammar type_i = new SchemaInformedFirstStartTag ( handleAttributes ( simpleContent , simpleContent , null , null ) ) ; type_i . setTypeEmpty ( SIMPLE_END_ELEMENT_EMPTY_RULE ) ; return type_i ; }
protected SchemaInformedElement translateSimpleTypeDefinitionToFSA (
6,471
private void init_jorbis ( ) { oggSyncState_ = new SyncState ( ) ; oggStreamState_ = new StreamState ( ) ; oggPage_ = new Page ( ) ; oggPacket_ = new Packet ( ) ; vorbisInfo = new Info ( ) ; vorbisComment = new Comment ( ) ; vorbisDspState = new DspState ( ) ; vorbisBlock = new Block ( vorbisDspState ) ; buffer = null ; bytes = 0 ; currentBytes = 0L ; oggSyncState_ . init ( ) ; }
Initializes all the jOrbis and jOgg vars that are used for song playback .
6,472
private void outputSamples ( ) { int samples ; while ( ( samples = vorbisDspState . synthesis_pcmout ( _pcmf , _index ) ) > 0 ) { float [ ] [ ] pcmf = _pcmf [ 0 ] ; bout = ( samples < convsize ? samples : convsize ) ; for ( i = 0 ; i < vorbisInfo . channels ; i ++ ) { int pointer = i * 2 ; int mono = _index [ i ] ; for ( int j = 0 ; j < bout ; j ++ ) { double fVal = pcmf [ i ] [ mono + j ] * 32767. ; int val = ( int ) ( fVal ) ; if ( val > 32767 ) { val = 32767 ; } if ( val < - 32768 ) { val = - 32768 ; } if ( val < 0 ) { val = val | 0x8000 ; } convbuffer [ pointer ] = ( byte ) ( val ) ; convbuffer [ pointer + 1 ] = ( byte ) ( val >>> 8 ) ; pointer += 2 * ( vorbisInfo . channels ) ; } } LOG . log ( Level . FINE , "about to write: {0}" , 2 * vorbisInfo . channels * bout ) ; if ( getCircularBuffer ( ) . availableWrite ( ) < 2 * vorbisInfo . channels * bout ) { LOG . log ( Level . FINE , "Too much data in this data packet, better return, let the channel drain, and try again..." ) ; playState = playState_BufferFull ; return ; } getCircularBuffer ( ) . write ( convbuffer , 0 , 2 * vorbisInfo . channels * bout ) ; if ( bytes < bufferSize_ ) { LOG . log ( Level . FINE , "Finished with final buffer of music?" ) ; } if ( vorbisDspState . synthesis_read ( bout ) != 0 ) { LOG . log ( Level . FINE , "VorbisDspState.synthesis_read returned -1." ) ; } } playState = playState_ReadData ; }
This routine was extracted so that when the output buffer fills up we can break out of the loop let the music channel drain then continue from where we were .
6,473
public int getBeginning ( int index ) { if ( this . beginpos == null ) throw new IllegalStateException ( "A result is not set." ) ; if ( index < 0 || this . nofgroups <= index ) throw new IllegalArgumentException ( "The parameter must be less than " + this . nofgroups + ": " + index ) ; return this . beginpos [ index ] ; }
Return a start position in the target text matched to specified regular expression group .
6,474
public int getEnd ( int index ) { if ( this . endpos == null ) throw new IllegalStateException ( "A result is not set." ) ; if ( index < 0 || this . nofgroups <= index ) throw new IllegalArgumentException ( "The parameter must be less than " + this . nofgroups + ": " + index ) ; return this . endpos [ index ] ; }
Return an end position in the target text matched to specified regular expression group .
6,475
public String getCapturedText ( int index ) { if ( this . beginpos == null ) throw new IllegalStateException ( "match() has never been called." ) ; if ( index < 0 || this . nofgroups <= index ) throw new IllegalArgumentException ( "The parameter must be less than " + this . nofgroups + ": " + index ) ; String ret ; int begin = this . beginpos [ index ] , end = this . endpos [ index ] ; if ( begin < 0 || end < 0 ) return null ; if ( this . ciSource != null ) { ret = REUtil . substring ( this . ciSource , begin , end ) ; } else if ( this . strSource != null ) { ret = this . strSource . substring ( begin , end ) ; } else { ret = new String ( this . charSource , begin , end - begin ) ; } return ret ; }
Return an substring of the target text matched to specified regular expression group .
6,476
protected void addRange ( int start , int end ) { this . icaseCache = null ; int r1 , r2 ; if ( start <= end ) { r1 = start ; r2 = end ; } else { r1 = end ; r2 = start ; } int pos = 0 ; if ( this . ranges == null ) { this . ranges = new int [ 2 ] ; this . ranges [ 0 ] = r1 ; this . ranges [ 1 ] = r2 ; this . setSorted ( true ) ; } else { pos = this . ranges . length ; if ( this . ranges [ pos - 1 ] + 1 == r1 ) { this . ranges [ pos - 1 ] = r2 ; return ; } int [ ] temp = new int [ pos + 2 ] ; System . arraycopy ( this . ranges , 0 , temp , 0 , pos ) ; this . ranges = temp ; if ( this . ranges [ pos - 1 ] >= r1 ) this . setSorted ( false ) ; this . ranges [ pos ++ ] = r1 ; this . ranges [ pos ] = r2 ; if ( ! this . sorted ) this . sortRanges ( ) ; } }
for RANGE or NRANGE
6,477
public AudioFileFormat getAudioFileFormat ( File file ) throws UnsupportedAudioFileException , IOException { LOG . log ( Level . FINE , "getAudioFileFormat(File file)" ) ; try ( InputStream inputStream = new BufferedInputStream ( new FileInputStream ( file ) ) ) { inputStream . mark ( MARK_LIMIT ) ; getAudioFileFormat ( inputStream ) ; inputStream . reset ( ) ; VorbisFile vf = new VorbisFile ( file . getAbsolutePath ( ) ) ; return getAudioFileFormat ( inputStream , ( int ) file . length ( ) , ( int ) Math . round ( vf . time_total ( - 1 ) * 1000 ) ) ; } catch ( SoundException e ) { throw new IOException ( e . getMessage ( ) ) ; } }
Return the AudioFileFormat from the given file .
6,478
public AudioFileFormat getAudioFileFormat ( URL url ) throws UnsupportedAudioFileException , IOException { LOG . log ( Level . FINE , "getAudioFileFormat(URL url)" ) ; InputStream inputStream = url . openStream ( ) ; try { return getAudioFileFormat ( inputStream ) ; } finally { if ( inputStream != null ) { inputStream . close ( ) ; } } }
Return the AudioFileFormat from the given URL .
6,479
public AudioFileFormat getAudioFileFormat ( InputStream inputStream ) throws UnsupportedAudioFileException , IOException { LOG . log ( Level . FINE , "getAudioFileFormat(InputStream inputStream)" ) ; try { if ( ! inputStream . markSupported ( ) ) { inputStream = new BufferedInputStream ( inputStream ) ; } inputStream . mark ( MARK_LIMIT ) ; return getAudioFileFormat ( inputStream , AudioSystem . NOT_SPECIFIED , AudioSystem . NOT_SPECIFIED ) ; } finally { inputStream . reset ( ) ; } }
Return the AudioFileFormat from the given InputStream .
6,480
public AudioFileFormat getAudioFileFormat ( InputStream inputStream , long medialength ) throws UnsupportedAudioFileException , IOException { return getAudioFileFormat ( inputStream , ( int ) medialength , AudioSystem . NOT_SPECIFIED ) ; }
Return the AudioFileFormat from the given InputStream and length in bytes .
6,481
public AudioInputStream getAudioInputStream ( File file ) throws UnsupportedAudioFileException , IOException { LOG . log ( Level . FINE , "getAudioInputStream(File file)" ) ; InputStream inputStream = new FileInputStream ( file ) ; try { return getAudioInputStream ( inputStream ) ; } catch ( UnsupportedAudioFileException | IOException e ) { inputStream . close ( ) ; throw e ; } }
Return the AudioInputStream from the given File .
6,482
public AudioInputStream getAudioInputStream ( URL url ) throws UnsupportedAudioFileException , IOException { LOG . log ( Level . FINE , "getAudioInputStream(URL url)" ) ; InputStream inputStream = url . openStream ( ) ; try { return getAudioInputStream ( inputStream ) ; } catch ( UnsupportedAudioFileException | IOException e ) { if ( inputStream != null ) { inputStream . close ( ) ; } throw e ; } }
Return the AudioInputStream from the given URL .
6,483
void decode_clear ( ) { os . clear ( ) ; vd . clear ( ) ; vb . clear ( ) ; decode_ready = false ; bittrack = 0.f ; samptrack = 0.f ; }
clear out the current logical bitstream decoder
6,484
int process_packet ( int readp ) { Page og = new Page ( ) ; while ( true ) { if ( decode_ready ) { Packet op = new Packet ( ) ; int result = os . packetout ( op ) ; long granulepos ; if ( result > 0 ) { granulepos = op . granulepos ; if ( vb . synthesis ( op ) == 0 ) { { int oldsamples = vd . synthesis_pcmout ( null , null ) ; vd . synthesis_blockin ( vb ) ; samptrack += vd . synthesis_pcmout ( null , null ) - oldsamples ; bittrack += op . bytes * 8 ; } if ( granulepos != - 1 && op . e_o_s == 0 ) { int link = ( seekable ? current_link : 0 ) ; int samples ; samples = vd . synthesis_pcmout ( null , null ) ; granulepos -= samples ; for ( int i = 0 ; i < link ; i ++ ) { granulepos += pcmlengths [ i ] ; } pcm_offset = granulepos ; } return ( 1 ) ; } } } if ( readp == 0 ) { return ( 0 ) ; } if ( get_next_page ( og , - 1 ) < 0 ) { return ( 0 ) ; } bittrack += og . header_len * 8 ; if ( decode_ready ) { if ( current_serialno != og . serialno ( ) ) { decode_clear ( ) ; } } if ( ! decode_ready ) { int i ; if ( seekable ) { current_serialno = og . serialno ( ) ; for ( i = 0 ; i < links ; i ++ ) { if ( serialnos [ i ] == current_serialno ) { break ; } } if ( i == links ) { return ( - 1 ) ; } current_link = i ; os . init ( current_serialno ) ; os . reset ( ) ; } else { int foo [ ] = new int [ 1 ] ; int ret = fetch_headers ( vi [ 0 ] , vc [ 0 ] , foo , og ) ; current_serialno = foo [ 0 ] ; if ( ret != 0 ) { return ret ; } current_link ++ ; i = 0 ; } make_decode_ready ( ) ; } os . pagein ( og ) ; } }
1 ) got a packet
6,485
int clear ( ) { vb . clear ( ) ; vd . clear ( ) ; os . clear ( ) ; if ( vi != null && links != 0 ) { for ( int i = 0 ; i < links ; i ++ ) { vi [ i ] . clear ( ) ; vc [ i ] . clear ( ) ; } vi = null ; vc = null ; } if ( dataoffsets != null ) { dataoffsets = null ; } if ( pcmlengths != null ) { pcmlengths = null ; } if ( serialnos != null ) { serialnos = null ; } if ( offsets != null ) { offsets = null ; } oy . clear ( ) ; return ( 0 ) ; }
clear out the OggVorbis_File struct
6,486
public AudioInputStream getAudioInputStream ( AudioFormat targetFormat , AudioInputStream audioInputStream ) { if ( isConversionSupported ( targetFormat , audioInputStream . getFormat ( ) ) ) { return new DecodedVorbisAudioInputStream ( targetFormat , audioInputStream ) ; } else { throw new IllegalArgumentException ( "conversion not supported" ) ; } }
Returns converted AudioInputStream .
6,487
public static boolean matches ( AudioFormat format1 , AudioFormat format2 ) { return format1 . getEncoding ( ) . equals ( format2 . getEncoding ( ) ) && ( format2 . getSampleSizeInBits ( ) <= 8 || format1 . getSampleSizeInBits ( ) == AudioSystem . NOT_SPECIFIED || format2 . getSampleSizeInBits ( ) == AudioSystem . NOT_SPECIFIED || format1 . isBigEndian ( ) == format2 . isBigEndian ( ) ) && doMatch ( format1 . getChannels ( ) , format2 . getChannels ( ) ) && doMatch ( format1 . getSampleSizeInBits ( ) , format2 . getSampleSizeInBits ( ) ) && doMatch ( format1 . getFrameSize ( ) , format2 . getFrameSize ( ) ) && doMatch ( format1 . getSampleRate ( ) , format2 . getSampleRate ( ) ) && doMatch ( format1 . getFrameRate ( ) , format2 . getFrameRate ( ) ) ; }
and a AudioFormat . Encoding . matches method .
6,488
private void setupWizard ( ) { setupComponents ( ) ; layoutComponents ( ) ; setMinimumSize ( defaultminimumSize ) ; Dimension screenSize = Toolkit . getDefaultToolkit ( ) . getScreenSize ( ) ; int xPosition = ( screenSize . width / 2 ) - ( defaultminimumSize . width / 2 ) ; int yPosition = ( screenSize . height / 2 ) - ( defaultminimumSize . height / 2 ) ; setLocation ( xPosition , yPosition ) ; setDefaultCloseOperation ( JFrame . DISPOSE_ON_CLOSE ) ; }
Sets up wizard upon construction .
6,489
private void setupComponents ( ) { cancelButton . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent e ) { dispose ( ) ; } } ) ; finishButton . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent e ) { JOptionPane . showMessageDialog ( getContentPane ( ) , "Wizard finished!" ) ; dispose ( ) ; } } ) ; cancelButton . setMnemonic ( KeyEvent . VK_C ) ; previousButton . setMnemonic ( KeyEvent . VK_P ) ; nextButton . setMnemonic ( KeyEvent . VK_N ) ; finishButton . setMnemonic ( KeyEvent . VK_F ) ; wizardPageContainer . addContainerListener ( new MinimumSizeAdjuster ( ) ) ; }
Sets up the components of the wizard with listeners and mnemonics .
6,490
private void layoutComponents ( ) { GridBagLayout layout = new GridBagLayout ( ) ; layout . rowWeights = new double [ ] { 1.0 , 0.0 , 0.0 } ; layout . columnWeights = new double [ ] { 1.0 , 0.0 , 0.0 , 0.0 , 0.0 } ; layout . rowHeights = new int [ ] { 0 , 0 , 0 } ; layout . columnWidths = new int [ ] { 0 , 0 , 0 , 0 , 0 } ; getContentPane ( ) . setLayout ( layout ) ; GridBagConstraints wizardPageContainerConstraint = new GridBagConstraints ( ) ; wizardPageContainerConstraint . gridwidth = 5 ; wizardPageContainerConstraint . fill = GridBagConstraints . BOTH ; wizardPageContainerConstraint . gridx = 0 ; wizardPageContainerConstraint . gridy = 0 ; wizardPageContainerConstraint . insets = new Insets ( 5 , 5 , 5 , 5 ) ; getContentPane ( ) . add ( wizardPageContainer , wizardPageContainerConstraint ) ; GridBagConstraints separatorConstraints = new GridBagConstraints ( ) ; separatorConstraints . gridwidth = 5 ; separatorConstraints . fill = GridBagConstraints . HORIZONTAL ; separatorConstraints . gridx = 0 ; separatorConstraints . gridy = 1 ; separatorConstraints . insets = new Insets ( 5 , 5 , 5 , 5 ) ; getContentPane ( ) . add ( new JSeparator ( ) , separatorConstraints ) ; GridBagConstraints cancelButtonConstraints = new GridBagConstraints ( ) ; cancelButtonConstraints . gridx = 1 ; cancelButtonConstraints . gridy = 2 ; cancelButtonConstraints . insets = new Insets ( 5 , 5 , 5 , 0 ) ; getContentPane ( ) . add ( cancelButton , cancelButtonConstraints ) ; GridBagConstraints previousButtonConstraints = new GridBagConstraints ( ) ; previousButtonConstraints . gridx = 2 ; previousButtonConstraints . gridy = 2 ; previousButtonConstraints . insets = new Insets ( 5 , 5 , 5 , 0 ) ; getContentPane ( ) . add ( previousButton , previousButtonConstraints ) ; GridBagConstraints nextButtonConstraints = new GridBagConstraints ( ) ; nextButtonConstraints . gridx = 3 ; nextButtonConstraints . gridy = 2 ; nextButtonConstraints . insets = new Insets ( 5 , 5 , 5 , 0 ) ; getContentPane ( ) . add ( nextButton , nextButtonConstraints ) ; GridBagConstraints finishButtonConstraints = new GridBagConstraints ( ) ; finishButtonConstraints . gridx = 4 ; finishButtonConstraints . gridy = 2 ; finishButtonConstraints . insets = new Insets ( 5 , 5 , 5 , 5 ) ; getContentPane ( ) . add ( finishButton , finishButtonConstraints ) ; }
Lays out the components in the wizards content pane .
6,491
public Grammars createXSDTypesOnlyGrammars ( ) throws EXIException { grammarBuilder . loadXSDTypesOnlyGrammars ( ) ; SchemaInformedGrammars g = grammarBuilder . toGrammars ( ) ; g . setBuiltInXMLSchemaTypesOnly ( true ) ; return g ; }
No user defined schema information is generated for processing the EXI body ; however the built - in XML schema types are available for use in the EXI body .
6,492
public AudioFormat . Encoding [ ] getTargetEncodings ( AudioFormat sourceFormat ) { if ( isAllowedSourceFormat ( sourceFormat ) ) { return getTargetEncodings ( ) ; } else { return EMPTY_ENCODING_ARRAY ; } }
This implementation assumes that the converter can convert from each of its source encodings to each of its target encodings . If this is not the case the converter has to override this method .
6,493
public AudioFormat [ ] getTargetFormats ( AudioFormat . Encoding targetEncoding , AudioFormat sourceFormat ) { if ( isConversionSupported ( targetEncoding , sourceFormat ) ) { return m_targetFormats . toArray ( EMPTY_FORMAT_ARRAY ) ; } else { return EMPTY_FORMAT_ARRAY ; } }
This implementation assumes that the converter can convert from each of its source formats to each of its target formats . If this is not the case the converter has to override this method .
6,494
final int getMinLength ( ) { switch ( this . type ) { case CONCAT : int sum = 0 ; for ( int i = 0 ; i < this . size ( ) ; i ++ ) sum += this . getChild ( i ) . getMinLength ( ) ; return sum ; case CONDITION : case UNION : if ( this . size ( ) == 0 ) return 0 ; int ret = this . getChild ( 0 ) . getMinLength ( ) ; for ( int i = 1 ; i < this . size ( ) ; i ++ ) { int min = this . getChild ( i ) . getMinLength ( ) ; if ( min < ret ) ret = min ; } return ret ; case CLOSURE : case NONGREEDYCLOSURE : if ( this . getMin ( ) >= 0 ) return this . getMin ( ) * this . getChild ( 0 ) . getMinLength ( ) ; return 0 ; case EMPTY : case ANCHOR : return 0 ; case DOT : case CHAR : case RANGE : case NRANGE : return 1 ; case INDEPENDENT : case PAREN : case MODIFIERGROUP : return this . getChild ( 0 ) . getMinLength ( ) ; case BACKREFERENCE : return 0 ; case STRING : return this . getString ( ) . length ( ) ; case LOOKAHEAD : case NEGATIVELOOKAHEAD : case LOOKBEHIND : case NEGATIVELOOKBEHIND : return 0 ; default : throw new RuntimeException ( "Token#getMinLength(): Invalid Type: " + this . type ) ; } }
How many characters are needed?
6,495
public boolean showNextPage ( AbstractWizardPage nextPage ) { if ( nextPage == null ) { updateButtons ( ) ; return false ; } if ( currentPage != null ) { pageHistory . push ( currentPage ) ; } setPage ( nextPage ) ; return true ; }
Sets the current page of this wizard to the specified page and adds the previous current page to the history .
6,496
int encode ( int a , Buffer b ) { b . write ( codelist [ a ] , c . lengthlist [ a ] ) ; return ( c . lengthlist [ a ] ) ; }
returns the number of bits
6,497
synchronized int decodevs_add ( float [ ] a , int offset , Buffer b , int n ) { int step = n / dim ; int entry ; int i , j , o ; if ( t . length < step ) { t = new int [ step ] ; } for ( i = 0 ; i < step ; i ++ ) { entry = decode ( b ) ; if ( entry == - 1 ) { return ( - 1 ) ; } t [ i ] = entry * dim ; } for ( i = 0 , o = 0 ; i < dim ; i ++ , o += step ) { for ( j = 0 ; j < step ; j ++ ) { a [ offset + o + j ] += valuelist [ t [ j ] + i ] ; } } return ( 0 ) ; }
decodevs_add is synchronized for re - using t .
6,498
private int maptype1_quantvals ( ) { int vals = ( int ) ( Math . floor ( Math . pow ( entries , 1. / dim ) ) ) ; while ( true ) { int acc = 1 ; int acc1 = 1 ; for ( int i = 0 ; i < dim ; i ++ ) { acc *= vals ; acc1 *= vals + 1 ; } if ( acc <= entries && acc1 > entries ) { return ( vals ) ; } else { if ( acc > entries ) { vals -- ; } else { vals ++ ; } } } }
thought of it . Therefore we opt on the side of caution
6,499
public void setBundleId ( String bundleId ) { if ( JawrRequestHandler . CLIENTSIDE_HANDLER_REQ_PATH . equals ( bundleId ) ) throw new IllegalArgumentException ( "The provided id [" + JawrRequestHandler . CLIENTSIDE_HANDLER_REQ_PATH + "] can't be used since it's the same as the clientside handler path. Please change this id (or the name of the script)" ) ; this . bundleId = bundleId ; }
Sets the bundle ID