idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
8,700
private IModel < List < SiteUrl > > newListModel ( ) { return new LoadableDetachableModel < List < SiteUrl > > ( ) { private static final long serialVersionUID = 1L ; protected List < SiteUrl > load ( ) { final List < SiteUrl > list = new ArrayList < > ( ) ; for ( final Class < ? extends WebPage > type : getAllPageClasses ( ) ) { String loc = PATTERN . matcher ( AbstractSiteMapPage . this . urlFor ( type , null ) ) . replaceFirst ( getBaseUrl ( ) ) ; if ( loc . endsWith ( "/." ) ) { loc = loc . replace ( "/." , "" ) ; } list . add ( new SiteUrl ( loc ) ) ; } return list ; } } ; }
New list model .
8,701
@ SuppressWarnings ( "rawtypes" ) public static Map < String , ArtifactSerializer > createArtifactSerializers ( ) { final Map < String , ArtifactSerializer > serializers = BaseModel . createArtifactSerializers ( ) ; serializers . put ( "featuregen" , new ByteArraySerializer ( ) ) ; return serializers ; }
Create the artifact serializers . The DefaultTrainer deals with any other Custom serializers .
8,702
public static boolean getBoolean ( Cursor cursor , String columnName ) { return cursor != null && cursor . getInt ( cursor . getColumnIndex ( columnName ) ) == TRUE ; }
Read the boolean data for the column .
8,703
public static int getInt ( Cursor cursor , String columnName ) { if ( cursor == null ) { return - 1 ; } return cursor . getInt ( cursor . getColumnIndex ( columnName ) ) ; }
Read the int data for the column .
8,704
public static String getString ( Cursor cursor , String columnName ) { if ( cursor == null ) { return null ; } return cursor . getString ( cursor . getColumnIndex ( columnName ) ) ; }
Read the String data for the column .
8,705
public static short getShort ( Cursor cursor , String columnName ) { if ( cursor == null ) { return - 1 ; } return cursor . getShort ( cursor . getColumnIndex ( columnName ) ) ; }
Read the short data for the column .
8,706
public static long getLong ( Cursor cursor , String columnName ) { if ( cursor == null ) { return - 1 ; } return cursor . getLong ( cursor . getColumnIndex ( columnName ) ) ; }
Read the long data for the column .
8,707
public static double getDouble ( Cursor cursor , String columnName ) { if ( cursor == null ) { return - 1 ; } return cursor . getDouble ( cursor . getColumnIndex ( columnName ) ) ; }
Read the double data for the column .
8,708
public static float getFloat ( Cursor cursor , String columnName ) { if ( cursor == null ) { return - 1 ; } return cursor . getFloat ( cursor . getColumnIndex ( columnName ) ) ; }
Read the float data for the column .
8,709
public static byte [ ] getBlob ( Cursor cursor , String columnName ) { if ( cursor == null ) { return null ; } return cursor . getBlob ( cursor . getColumnIndex ( columnName ) ) ; }
Read the blob data for the column .
8,710
@ TargetApi ( Build . VERSION_CODES . HONEYCOMB ) public static int getType ( Cursor cursor , String columnName ) { if ( cursor == null ) { return Cursor . FIELD_TYPE_NULL ; } return cursor . getType ( cursor . getColumnIndex ( columnName ) ) ; }
Checks the type of the column .
8,711
public static boolean isNull ( Cursor cursor , String columnName ) { return cursor != null && cursor . isNull ( cursor . getColumnIndex ( columnName ) ) ; }
Checks if the column value is null or not .
8,712
public static Component findParent ( final Component childComponent , final Class < ? extends Component > parentClass , final boolean byClassname ) { Component parent = childComponent . getParent ( ) ; while ( parent != null ) { if ( parent . getClass ( ) . equals ( parentClass ) ) { break ; } parent = parent . getParent ( ) ; } if ( ( parent == null ) && byClassname ) { return findParentByClassname ( childComponent , parentClass ) ; } return parent ; }
Finds the first parent of the given childComponent from the given parentClass and a flag if the search shell be continued with the class name if the search with the given parentClass returns null .
8,713
public static Component findParentForm ( final Component childComponent ) { final Component parent = findParent ( childComponent , Form . class ) ; if ( ( parent != null ) && parent . getClass ( ) . equals ( Form . class ) ) { return parent ; } return null ; }
Finds the parent form of the given childComponent .
8,714
public static Page getCurrentPage ( ) { final IRequestHandler requestHandler = RequestCycle . get ( ) . getActiveRequestHandler ( ) ; final Page page = getPage ( requestHandler ) ; if ( page != null ) { return page ; } if ( requestHandler instanceof RequestSettingRequestHandler ) { final RequestSettingRequestHandler requestSettingRequestHandler = ( RequestSettingRequestHandler ) requestHandler ; return getPage ( requestSettingRequestHandler . getDelegateHandler ( ) ) ; } return null ; }
Gets the current page .
8,715
public static Page getPage ( final IRequestHandler requestHandler ) { if ( requestHandler instanceof IPageRequestHandler ) { final IPageRequestHandler pageRequestHandler = ( IPageRequestHandler ) requestHandler ; return ( Page ) pageRequestHandler . getPage ( ) ; } return null ; }
Gets the page if the request handler is instance of IPageRequestHandler .
8,716
@ SuppressWarnings ( "javadoc" ) public static AjaxRequestTarget newAjaxRequestTarget ( final WebApplication application , final Page page ) { return application . newAjaxRequestTarget ( page ) ; }
Creates a new ajax request target from the given Page .
8,717
public List < SequenceLabel > getNumericNames ( ) { final List < SequenceLabel > result = new ArrayList < SequenceLabel > ( ) ; while ( hasNextToken ( ) ) { result . add ( getNextToken ( ) ) ; } return result ; }
Returns found expressions as a List of names .
8,718
public double getAverageKamNodeDegree ( String kamName ) { final int nodes = getKamNodeCount ( kamName ) ; return ( nodes != 0 ? ( ( double ) 2 * getKamEdgeCount ( kamName ) ) / nodes : 0.0 ) ; }
Returns the average KAM node degree .
8,719
public double getAverageKamNodeInDegree ( String kamName ) { final int nodes = getKamNodeCount ( kamName ) ; return ( nodes != 0 ? ( ( double ) getKamEdgeCount ( kamName ) ) / nodes : 0.0 ) ; }
Returns the average KAM node in degree .
8,720
public double getAverageKamNodeOutDegree ( String kamName ) { final int nodes = getKamNodeCount ( kamName ) ; return ( nodes != 0 ? ( ( double ) getKamEdgeCount ( kamName ) ) / nodes : 0.0 ) ; }
Returns the average KAM node out degree .
8,721
public static void addFilePatternsToPackageResourceGuard ( final Application application , final String ... patterns ) { final IPackageResourceGuard packageResourceGuard = application . getResourceSettings ( ) . getPackageResourceGuard ( ) ; if ( packageResourceGuard instanceof SecurePackageResourceGuard ) { final SecurePackageResourceGuard guard = ( SecurePackageResourceGuard ) packageResourceGuard ; for ( final String pattern : patterns ) { guard . addPattern ( pattern ) ; } } }
Adds the given file patterns to package resource guard from the given application .
8,722
public static void addResourceFinder ( final WebApplication application , final String resourcePath ) { application . getResourceSettings ( ) . getResourceFinders ( ) . add ( new WebApplicationPath ( application . getServletContext ( ) , resourcePath ) ) ; }
Adds the given resourcePath to the resource finder from the given application .
8,723
public static void replaceJQueryReference ( final WebApplication application , final String cdnjsUrl ) { application . getJavaScriptLibrarySettings ( ) . setJQueryReference ( new UrlResourceReference ( Url . parse ( cdnjsUrl ) ) ) ; }
Replace the default jquery resource reference from the given application with the given cdn url .
8,724
public static void setDebugSettingsForDevelopment ( final Application application ) { application . getDebugSettings ( ) . setComponentUseCheck ( true ) ; application . getDebugSettings ( ) . setOutputMarkupContainerClassName ( true ) ; application . getDebugSettings ( ) . setLinePreciseReportingOnAddComponentEnabled ( true ) ; application . getDebugSettings ( ) . setLinePreciseReportingOnNewComponentEnabled ( true ) ; application . getDebugSettings ( ) . setAjaxDebugModeEnabled ( true ) ; application . getDebugSettings ( ) . setDevelopmentUtilitiesEnabled ( true ) ; }
Sets the debug settings for development mode for the given application .
8,725
public static void setDefaultDebugSettingsForDevelopment ( final WebApplication application ) { ApplicationExtensions . setHtmlHotDeploy ( application ) ; ApplicationExtensions . setDebugSettingsForDevelopment ( application ) ; ApplicationExtensions . setExceptionSettingsForDevelopment ( application ) ; application . getResourceSettings ( ) . setThrowExceptionOnMissingResource ( true ) ; }
Sets a set of default development settings for development mode for the given application .
8,726
public static void setDefaultDeploymentModeConfiguration ( final Application application , final AbstractRequestCycleListener applicationRequestCycleListener ) { if ( applicationRequestCycleListener != null ) { ApplicationExtensions . setExceptionSettingsForDeployment ( application , applicationRequestCycleListener ) ; } ApplicationExtensions . setDeploymentModeConfiguration ( application ) ; }
Sets a set of default deployment settings for deployment mode for the given application .
8,727
public static void setDeploymentModeConfiguration ( final Application application ) { application . getMarkupSettings ( ) . setStripComments ( true ) ; application . getResourceSettings ( ) . setResourcePollFrequency ( null ) ; application . getResourceSettings ( ) . setJavaScriptCompressor ( new DefaultJavaScriptCompressor ( ) ) ; application . getResourceSettings ( ) . setThrowExceptionOnMissingResource ( false ) ; application . getDebugSettings ( ) . setComponentUseCheck ( false ) ; application . getDebugSettings ( ) . setAjaxDebugModeEnabled ( false ) ; application . getDebugSettings ( ) . setDevelopmentUtilitiesEnabled ( false ) ; application . getDebugSettings ( ) . setOutputMarkupContainerClassName ( false ) ; application . getDebugSettings ( ) . setLinePreciseReportingOnAddComponentEnabled ( false ) ; application . getDebugSettings ( ) . setLinePreciseReportingOnNewComponentEnabled ( false ) ; }
Sets the deployment settings for deployment mode for the given application .
8,728
public static void setExceptionSettingsForDeployment ( final Application application , final AbstractRequestCycleListener applicationRequestCycleListener ) { application . getExceptionSettings ( ) . setUnexpectedExceptionDisplay ( ExceptionSettings . SHOW_INTERNAL_ERROR_PAGE ) ; application . getRequestCycleListeners ( ) . add ( applicationRequestCycleListener ) ; }
Sets the deployment exception settings for the given application .
8,729
public static void setGlobalSettings ( final WebApplication application , final int httpPort , final int httpsPort , final String footerFilterName , final String encoding , final String ... patterns ) { application . getMarkupSettings ( ) . setDefaultMarkupEncoding ( encoding ) ; application . getRequestCycleSettings ( ) . setResponseRequestEncoding ( encoding ) ; ApplicationExtensions . setHeaderResponseDecorator ( application , footerFilterName ) ; ApplicationExtensions . setRootRequestMapper ( application , httpPort , httpsPort ) ; ApplicationExtensions . addFilePatternsToPackageResourceGuard ( application , patterns ) ; application . getMarkupSettings ( ) . setStripWicketTags ( true ) ; }
Can be used to set the global settings for development and deployment mode for the given application .
8,730
public static void setHtmlHotDeploy ( final WebApplication application ) { application . getResourceSettings ( ) . setResourcePollFrequency ( Duration . ONE_SECOND ) ; final String slash = "/" ; String realPath = application . getServletContext ( ) . getRealPath ( slash ) ; if ( ( realPath != null ) && ! realPath . endsWith ( slash ) ) { realPath += slash ; } final String javaSourcePath = realPath + "../java" ; final String resourcesPath = realPath + "../resources" ; addResourceFinder ( application , javaSourcePath ) ; addResourceFinder ( application , resourcesPath ) ; }
Use this method to enable hot deploy of your html templates on development . Works only with jetty . Only for
8,731
public static IRequestMapper setRootRequestMapper ( final Application application , final int httpPort , final int httpsPort ) { final IRequestMapper httpsMapper = new HttpsMapper ( application . getRootRequestMapper ( ) , new HttpsConfig ( httpPort , httpsPort ) ) ; application . setRootRequestMapper ( httpsMapper ) ; return httpsMapper ; }
Sets the root request mapper for the given application from the given httpPort and httpsPort .
8,732
public CMFolder addChild ( String id , String name ) { CMFolder childFolder = new CMFolder ( id , name ) ; childFolder . parent = this ; this . children . put ( name , childFolder ) ; return childFolder ; }
Adds a child folder
8,733
public CMFolder getFolder ( CPath path ) { List < String > baseNames = path . split ( ) ; if ( path . isRoot ( ) ) { return this ; } CMFolder currentFolder = this ; CMFolder subFolder = null ; for ( String baseName : baseNames ) { subFolder = currentFolder . getChildByName ( baseName ) ; if ( subFolder == null ) { return null ; } currentFolder = subFolder ; } return subFolder ; }
Gets the CloudMe folder corresponding to a given CPath Returns null if the folder does not exist
8,734
public CPath getCPath ( ) { if ( parent == null ) { return CPath . ROOT ; } CMFolder currentFolder = this ; StringBuilder path = new StringBuilder ( ) ; while ( currentFolder . parent != null ) { path . insert ( 0 , currentFolder . name ) ; path . insert ( 0 , '/' ) ; currentFolder = currentFolder . parent ; } return new CPath ( path . toString ( ) ) ; }
Gets the CPath corresponding to this folder
8,735
@ TargetApi ( Build . VERSION_CODES . FROYO ) public static File getExternalFilesDirForMusic ( Context context ) { return context . getExternalFilesDir ( Environment . DIRECTORY_MUSIC ) ; }
Get the file points to an external music directory .
8,736
@ TargetApi ( Build . VERSION_CODES . FROYO ) public static File getExternalFilesDirForMovies ( Context context ) { return context . getExternalFilesDir ( Environment . DIRECTORY_MOVIES ) ; }
Get the file points to an external movies directory .
8,737
@ TargetApi ( Build . VERSION_CODES . FROYO ) public static File getExternalFilesDirForAlarms ( Context context ) { return context . getExternalFilesDir ( Environment . DIRECTORY_ALARMS ) ; }
Get the file points to an external alarms directory .
8,738
@ TargetApi ( Build . VERSION_CODES . FROYO ) public static File getExternalFilesDirForDcim ( Context context ) { return context . getExternalFilesDir ( Environment . DIRECTORY_DCIM ) ; }
Get the file points to an external dcim directory .
8,739
@ TargetApi ( Build . VERSION_CODES . FROYO ) public static File getExternalFilesDirForNotifications ( Context context ) { return context . getExternalFilesDir ( Environment . DIRECTORY_NOTIFICATIONS ) ; }
Get the file points to an external notifications directory .
8,740
@ TargetApi ( Build . VERSION_CODES . FROYO ) public static File getExternalFilesDirForDownloads ( Context context ) { return context . getExternalFilesDir ( Environment . DIRECTORY_DOWNLOADS ) ; }
Get the file points to an external downloads directory .
8,741
@ TargetApi ( Build . VERSION_CODES . FROYO ) public static File getExternalFilesDirForRingtones ( Context context ) { return context . getExternalFilesDir ( Environment . DIRECTORY_RINGTONES ) ; }
Get the file points to an external ringtones directory .
8,742
static ExecutorService newExecutor ( ) { ThreadPoolExecutor tpe = new ThreadPoolExecutor ( 0 , 1 , 10 , TimeUnit . SECONDS , new SynchronousQueue < Runnable > ( ) ) ; tpe . allowCoreThreadTimeOut ( true ) ; return tpe ; }
Creates an executor service with one thread that is removed automatically after 10 second idle time . The pool is therefore garbage collected and shutdown automatically .
8,743
private boolean getSchemaManagementStatus ( DBConnection dbc ) { boolean createSchemas = false ; if ( dbc . isDerby ( ) ) { createSchemas = true ; } else if ( dbc . isMysql ( ) || dbc . isPostgresql ( ) ) { createSchemas = getSystemConfiguration ( ) . getSystemManagedSchemas ( ) ; } return createSchemas ; }
Check to see if the system is managing the KAMStore schemas . The system manages Derby schemas by default . Oracle is only DBA managed and MySQL can be either although the default is to enable system managed
8,744
public static Option [ ] combine ( final Option [ ] options1 , final Option ... options2 ) { int size1 = 0 ; if ( options1 != null && options1 . length > 0 ) { size1 += options1 . length ; } int size2 = 0 ; if ( options2 != null && options2 . length > 0 ) { size2 += options2 . length ; } final Option [ ] combined = new Option [ size1 + size2 ] ; if ( size1 > 0 ) { System . arraycopy ( options1 , 0 , combined , 0 , size1 ) ; } if ( size2 > 0 ) { System . arraycopy ( options2 , 0 , combined , size1 , size2 ) ; } return combined ; }
Combines two arrays of options in one array containing both provided arrays in order they are provided .
8,745
public static Option [ ] remove ( final Class < ? extends Option > optionType , final Option ... options ) { final List < Option > filtered = new ArrayList < Option > ( ) ; for ( Option option : expand ( options ) ) { if ( ! optionType . isAssignableFrom ( option . getClass ( ) ) ) { filtered . add ( option ) ; } } return filtered . toArray ( new Option [ filtered . size ( ) ] ) ; }
Removes from the provided options all options that are instance of the provided class returning the remaining options .
8,746
private String createSpan ( final List < String > lemmas , final int from , final int to ) { String lemmaSpan = "" ; for ( int i = from ; i < to ; i ++ ) { lemmaSpan += lemmas . get ( i ) + "_" ; } lemmaSpan += lemmas . get ( to ) ; return lemmaSpan ; }
Create lemma span for search of multiwords in MFS dictionary .
8,747
public TreeMultimap < Integer , String > getMFSRanking ( final String lemmaPOSClass , final Integer rankSize ) { final TreeMultimap < Integer , String > mfsResultsMap = getOrderedMap ( lemmaPOSClass ) ; final TreeMultimap < Integer , String > mfsRankMap = TreeMultimap . create ( Ordering . natural ( ) . reverse ( ) , Ordering . natural ( ) ) ; for ( final Map . Entry < Integer , String > freqSenseEntry : Iterables . limit ( mfsResultsMap . entries ( ) , rankSize ) ) { mfsRankMap . put ( freqSenseEntry . getKey ( ) , freqSenseEntry . getValue ( ) ) ; } return mfsRankMap ; }
Get a rank of senses ordered by MFS .
8,748
public void serialize ( final OutputStream out ) throws IOException { final Writer writer = new BufferedWriter ( new OutputStreamWriter ( out ) ) ; for ( final Map . Entry < String , String > entry : this . multiMap . entries ( ) ) { writer . write ( entry . getKey ( ) + IOUtils . TAB_DELIMITER + entry . getValue ( ) + "\n" ) ; } writer . flush ( ) ; }
Serialize the lexicon in the original format .
8,749
public synchronized ID replaceSessionId ( final USER user , final ID oldSessionId , final ID newSessionId , final SESSION newSession ) { remove ( oldSessionId ) ; return addOnline ( user , newSessionId , newSession ) ; }
Replace the given old session id with the new one .
8,750
public static String buildKey ( Class < ? > clazz , String name ) { return new StringBuilder ( ) . append ( clazz . getCanonicalName ( ) ) . append ( "." ) . append ( name ) . toString ( ) ; }
Build a custom bundle key name to avoid conflict the bundle key name among the activities . This is also useful to build a intent extra key name .
8,751
public synchronized void open ( ) throws IOException { if ( tmap != null ) { return ; } final RecordManager rm = createRecordManager ( indexPath ) ; if ( valueSerializer == null ) { tmap = rm . treeMap ( IndexerConstants . INDEX_TREE_KEY ) ; } else { tmap = rm . treeMap ( IndexerConstants . INDEX_TREE_KEY , valueSerializer ) ; } if ( tmap . isEmpty ( ) ) { rm . close ( ) ; throw new IOException ( "tree map is empty" ) ; } invTmap = tmap . inverseHashView ( IndexerConstants . INVERSE_KEY ) ; }
Opens the index for subsequent lookups .
8,752
public synchronized void close ( ) throws IOException { if ( tmap == null ) { throw new IllegalStateException ( "not open" ) ; } final RecordManager rm = tmap . getRecordManager ( ) ; rm . close ( ) ; tmap = null ; }
Closes the index .
8,753
private void doWait ( int currentTries , long optDuration_ms ) { if ( optDuration_ms < 0 ) { optDuration_ms = ( long ) ( firstSleep_ms * ( Math . random ( ) + 0.5 ) * ( 1L << ( currentTries - 1 ) ) ) ; } LOGGER . debug ( "Will retry request after {} millis" , optDuration_ms ) ; try { Thread . sleep ( optDuration_ms ) ; } catch ( InterruptedException ex ) { throw new CStorageException ( "Retry waiting interrupted" , ex ) ; } }
Sleeps before retry ; default implementation is exponential back - off or the specified duration
8,754
private boolean endOfBranch ( final SetStack < KamEdge > edgeStack , KamEdge edge , int edgeCount ) { if ( edgeStack . contains ( edge ) && edgeCount == 1 ) { return true ; } return false ; }
Determines whether the end of a branch was found . This can indicate that a path should be captures up to the leaf node .
8,755
public static List < Element > getDescriptorElements ( InputStream xmlDescriptorIn ) throws IOException { List < Element > elements = new ArrayList < > ( ) ; org . w3c . dom . Document xmlDescriptorDOM = createDOM ( xmlDescriptorIn ) ; XPath xPath = XPathFactory . newInstance ( ) . newXPath ( ) ; NodeList allElements ; try { XPathExpression exp = xPath . compile ( "//*" ) ; allElements = ( NodeList ) exp . evaluate ( xmlDescriptorDOM . getDocumentElement ( ) , XPathConstants . NODESET ) ; } catch ( XPathExpressionException e ) { throw new IllegalStateException ( "The hard coded XPath expression should always be valid!" ) ; } for ( int i = 0 ; i < allElements . getLength ( ) ; i ++ ) { if ( allElements . item ( i ) instanceof Element ) { Element customElement = ( Element ) allElements . item ( i ) ; elements . add ( customElement ) ; } } return elements ; }
Provides a list with all the elements in the xml feature descriptor .
8,756
public static String getContextPath ( final WebApplication application ) { final String contextPath = application . getServletContext ( ) . getContextPath ( ) ; if ( ( null != contextPath ) && ! contextPath . isEmpty ( ) ) { return contextPath ; } return "" ; }
Gets the context path from the given WebApplication .
8,757
public static Behavior getHeaderContributorForFavicon ( ) { return new Behavior ( ) { private static final long serialVersionUID = 1L ; public void renderHead ( final Component component , final IHeaderResponse response ) { super . renderHead ( component , response ) ; response . render ( new StringHeaderItem ( "<link type=\"image/x-icon\" rel=\"shortcut icon\" href=\"favicon.ico\" />" ) ) ; } } ; }
Gets the header contributor for favicon .
8,758
public static HttpServletRequest getHttpServletRequest ( final Request request ) { final WebRequest webRequest = ( WebRequest ) request ; final HttpServletRequest httpServletRequest = ( HttpServletRequest ) webRequest . getContainerRequest ( ) ; return httpServletRequest ; }
Gets the http servlet request .
8,759
public static HttpServletResponse getHttpServletResponse ( final Response response ) { final WebResponse webResponse = ( WebResponse ) response ; final HttpServletResponse httpServletResponse = ( HttpServletResponse ) webResponse . getContainerResponse ( ) ; return httpServletResponse ; }
Gets the http servlet response .
8,760
public static void setDefaultSecurityHeaders ( final WebResponse response ) { WicketComponentExtensions . setSecurityFramingHeaders ( response ) ; WicketComponentExtensions . setSecurityTransportHeaders ( response ) ; WicketComponentExtensions . setSecurityXSSHeaders ( response ) ; WicketComponentExtensions . setSecurityCachingHeaders ( response ) ; }
Sets the security headers . You can check your setting on on the link below .
8,761
public static String toAbsolutePath ( final String relativePagePath ) { final HttpServletRequest req = ( HttpServletRequest ) ( ( WebRequest ) RequestCycle . get ( ) . getRequest ( ) ) . getContainerRequest ( ) ; return RequestUtils . toAbsolutePath ( req . getRequestURL ( ) . toString ( ) , relativePagePath ) ; }
Helper method for the migration from wicket - version 1 . 5 . x to 6 . x .
8,762
public void serialize ( final OutputStream out ) throws IOException { final Writer writer = new BufferedWriter ( new OutputStreamWriter ( out ) ) ; for ( final List < String > entry : this . predContexts ) { writer . write ( entry . get ( 0 ) + "\t" + entry . get ( 1 ) + "\t" + entry . get ( 2 ) + "\n" ) ; } writer . flush ( ) ; }
Serialize the dictionary to original corpus format
8,763
@ SuppressWarnings ( "unchecked" ) public < T > T getHint ( Hint < T > hint ) { return ( T ) hintValues . get ( hint ) ; }
Get a hint value .
8,764
private HttpSession doGetSession ( boolean create ) { if ( session == null ) { Cookie cookie = WebUtil . findCookie ( this , getSessionCookieName ( ) ) ; if ( cookie != null ) { String value = cookie . getValue ( ) ; log . debug ( "discovery session id from cookie: {}" , value ) ; session = buildSession ( value , false ) ; } else { session = buildSession ( create ) ; } } else { log . debug ( "Session[{}] was existed." , session . getId ( ) ) ; } return session ; }
get session from session cookie name
8,765
private HttpSession2 buildSession ( String id , boolean refresh ) { HttpSession2 session = new HttpSession2 ( id , sessionManager , request . getServletContext ( ) ) ; session . setMaxInactiveInterval ( maxInactiveInterval ) ; if ( refresh ) { WebUtil . addCookie ( this , response , getSessionCookieName ( ) , id , getCookieDomain ( ) , getCookieContextPath ( ) , cookieMaxAge , true ) ; } return session ; }
build a new session from session id
8,766
private HttpSession2 buildSession ( boolean create ) { if ( create ) { session = buildSession ( sessionManager . getSessionIdGenerator ( ) . generate ( request ) , true ) ; log . debug ( "Build new session[{}]." , session . getId ( ) ) ; return session ; } else { return null ; } }
build a new session
8,767
protected String newJavaScript ( final Component component ) { final StringBuilder sb = new StringBuilder ( ) ; sb . append ( "setTimeout(" + "function() {" + "var component = document.getElementById(\"" ) . append ( component . getMarkupId ( ) ) . append ( "\");" ) ; if ( clearValue ) { sb . append ( "component.value = \"\";" ) ; } sb . append ( "component.focus();" ) ; sb . append ( "}, " + this . delay + ")" ) ; return sb . toString ( ) ; }
Factory method that creates the java script code for request focus .
8,768
public static < C extends Page > String absoluteUrlFor ( final Class < C > page ) { return absoluteUrlFor ( page , null , false ) ; }
Returns the absolute url for the given page without the server port .
8,769
public static < C extends Page > String absoluteUrlFor ( final Class < C > page , final boolean withServerPort ) { return absoluteUrlFor ( page , null , withServerPort ) ; }
Returns the absolute url for the given page and optionally with the server port .
8,770
public static < C extends Page > String absoluteUrlFor ( final Class < C > page , final PageParameters parameters , final boolean withServerPort ) { final StringBuilder url = new StringBuilder ( ) ; url . append ( WicketUrlExtensions . getDomainUrl ( withServerPort ) ) ; url . append ( WicketUrlExtensions . getBaseUrl ( page , parameters ) . canonical ( ) . toString ( ) ) ; return url . toString ( ) ; }
Returns the absolute url for the given page with the parameters and optionally with the server port .
8,771
public static Url getBaseUrl ( final Class < ? extends Page > pageClass , final PageParameters parameters ) { return RequestCycle . get ( ) . mapUrlFor ( pageClass , parameters ) ; }
Gets the base url .
8,772
public static String getDomainUrl ( final boolean ssl , final boolean withServerPort , final boolean withSlashAtTheEnd ) { return newDomainUrl ( ssl ? Scheme . HTTPS . urlName ( ) : Scheme . HTTP . urlName ( ) , WicketUrlExtensions . getServerName ( ) , WicketComponentExtensions . getHttpServletRequest ( ) . getServerPort ( ) , withServerPort , withSlashAtTheEnd ) ; }
Gets the domain url .
8,773
public static String getUrlAsString ( final Class < ? extends Page > pageClass ) { final Url pageUrl = getPageUrl ( pageClass ) ; final Url url = getBaseUrl ( pageClass ) ; url . resolveRelative ( pageUrl ) ; final String contextPath = getContextPath ( ) ; return String . format ( "%s/%s" , contextPath , url ) ; }
Gets the url as string from the given WebPage class object .
8,774
public static String newDomainUrl ( final String scheme , final String domainName , final int port , final boolean withServerPort , final boolean withSlashAtTheEnd ) { final StringBuilder domainUrl = new StringBuilder ( ) ; domainUrl . append ( scheme ) ; domainUrl . append ( "://" ) ; domainUrl . append ( domainName ) ; if ( withServerPort ) { domainUrl . append ( ":" ) ; domainUrl . append ( port ) ; } if ( withSlashAtTheEnd ) { domainUrl . append ( "/" ) ; } return domainUrl . toString ( ) ; }
Creates a new domain url from the given parameters .
8,775
public static String toBaseUrl ( final Class < ? extends Page > pageClass , final PageParameters parameters ) { return getBaseUrl ( pageClass , parameters ) . canonical ( ) . toString ( ) ; }
Gets the base ur as String .
8,776
public MockitoBundlesOption version ( final String version ) { ( ( MavenArtifactUrlReference ) ( ( WrappedUrlProvisionOption ) getDelegate ( ) ) . getUrlReference ( ) ) . version ( version ) ; return this ; }
Sets the Mockito version .
8,777
public static void main ( String [ ] args ) throws Exception { KamManager app = new KamManager ( args ) ; app . run ( ) ; }
Static main method to launch the KAM Manager tool .
8,778
private void determineCommand ( ) { command = null ; commandStr = null ; boolean tooManyCommands = false ; for ( Command c : Command . values ( ) ) { final String alias = c . getAlias ( ) ; if ( hasOption ( alias ) ) { if ( c == Command . HELP ) { help = true ; } else if ( command == null ) { command = c ; commandStr = alias ; } else { tooManyCommands = true ; } } } if ( tooManyCommands ) { command = null ; commandStr = null ; if ( ! help ) { reportable . error ( format ( "You must specify only one command (%s).%n" , showCommandAliases ( ) ) ) ; printHelp ( true ) ; } } if ( help && command == null ) { command = Command . HELP ; commandStr = command . getAlias ( ) ; } else if ( command == null ) { printUsage ( ) ; reportable . error ( "\n" ) ; reportable . error ( "No command option given. Please specify one of: " + showCommandAliases ( ) ) ; end ( ) ; } }
Initializes the member variables command commandStr and help according to the command option specified by the user in the command line .
8,779
private void checkHover ( HumanInputEvent < ? > event ) { if ( service . getEditingState ( ) == GeometryEditState . DRAGGING && ! service . getIndexStateService ( ) . isSelected ( index ) && service . getIndexStateService ( ) . getSelection ( ) . size ( ) == 1 ) { GeometryIndex selected = service . getIndexStateService ( ) . getSelection ( ) . get ( 0 ) ; if ( service . getIndexService ( ) . getType ( index ) == service . getIndexService ( ) . getType ( selected ) ) { int siblingCount = service . getIndexService ( ) . getSiblingCount ( service . getGeometry ( ) , index ) ; try { String geometryType = service . getIndexService ( ) . getGeometryType ( service . getGeometry ( ) , index ) ; if ( geometryType . equals ( Geometry . LINE_STRING ) ) { if ( siblingCount < 3 ) { return ; } } else if ( geometryType . equals ( Geometry . LINEAR_RING ) ) { if ( siblingCount < 5 ) { return ; } } else { throw new IllegalStateException ( "Illegal type of geometry found." ) ; } } catch ( GeometryIndexNotFoundException e ) { throw new IllegalStateException ( e ) ; } if ( ! allowMoreThanNeighbours && ! ( service . getIndexService ( ) . isAdjacent ( service . getGeometry ( ) , index , selected ) ) ) { return ; } indexToDelete = selected ; if ( ! service . getIndexStateService ( ) . isMarkedForDeletion ( index ) ) { service . getIndexStateService ( ) . markForDeletionBegin ( Collections . singletonList ( index ) ) ; } if ( service . getIndexService ( ) . getType ( index ) == GeometryIndexType . TYPE_VERTEX ) { try { Coordinate location = service . getIndexService ( ) . getVertex ( service . getGeometry ( ) , index ) ; service . move ( Collections . singletonList ( selected ) , Collections . singletonList ( Collections . singletonList ( location ) ) ) ; event . stopPropagation ( ) ; } catch ( GeometryIndexNotFoundException e ) { logger . log ( Level . WARNING , "Index not found" , e ) ; } catch ( GeometryOperationFailedException e ) { logger . log ( Level . WARNING , "Operation failed" , e ) ; } } } } }
Supports only vertices for now .
8,780
public MenuItem setMenuItems ( final List < MenuItem > menuItems ) { this . children . clear ( ) ; this . children . addAll ( menuItems ) ; return this ; }
Add all menus at once .
8,781
private String [ ] getTokens ( String line ) { line = line . trim ( ) ; line = doubleSpaces . matcher ( line ) . replaceAll ( " " ) ; line = asciiHex . matcher ( line ) . replaceAll ( " " ) ; line = generalBlankPunctuation . matcher ( line ) . replaceAll ( " " ) ; line = qexc . matcher ( line ) . replaceAll ( " $1 " ) ; line = spaceDashSpace . matcher ( line ) . replaceAll ( " $1 " ) ; line = specials . matcher ( line ) . replaceAll ( " $1 " ) ; line = generateMultidots ( line ) ; line = noDigitComma . matcher ( line ) . replaceAll ( "$1 $2" ) ; line = commaNoDigit . matcher ( line ) . replaceAll ( "$1 $2" ) ; line = digitCommaNoDigit . matcher ( line ) . replaceAll ( "$1 $2 $3" ) ; line = noDigitCommaDigit . matcher ( line ) . replaceAll ( "$1 $2 $3" ) ; line = treatContractions ( line ) ; line = this . nonBreaker . TokenizerNonBreaker ( line ) ; line = restoreMultidots ( line ) ; line = detokenizeURLs ( line ) ; line = beginLink . matcher ( line ) . replaceAll ( "$1://" ) ; line = endLink . matcher ( line ) . replaceAll ( "$1$2" ) ; line = line . trim ( ) ; line = doubleSpaces . matcher ( line ) . replaceAll ( " " ) ; line = detokenParagraphs . matcher ( line ) . replaceAll ( "$1$2" ) ; if ( DEBUG ) { System . out . println ( "->Tokens:" + line ) ; } final String [ ] tokens = line . split ( " " ) ; return tokens ; }
Actual tokenization function .
8,782
private String restoreMultidots ( String line ) { while ( line . contains ( "DOTDOTMULTI" ) ) { line = line . replaceAll ( "DOTDOTMULTI" , "DOTMULTI." ) ; } line = line . replaceAll ( "DOTMULTI" , "." ) ; return line ; }
Restores the normalized multidots to its original state and it tokenizes them .
8,783
private String detokenizeURLs ( String line ) { final Matcher linkMatcher = wrongLink . matcher ( line ) ; final StringBuffer sb = new StringBuffer ( ) ; while ( linkMatcher . find ( ) ) { linkMatcher . appendReplacement ( sb , linkMatcher . group ( ) . replaceAll ( "\\s" , "" ) ) ; } linkMatcher . appendTail ( sb ) ; line = sb . toString ( ) ; return line ; }
De - tokenize wrongly tokenized URLs .
8,784
private void printUntokenizable ( final Properties properties ) { final String untokenizable = properties . getProperty ( "untokenizable" ) ; if ( untokenizable . equalsIgnoreCase ( "yes" ) ) { this . unTokenizable = true ; } else { this . unTokenizable = false ; } }
Process the untokenizable CLI option .
8,785
private void addTokens ( final Token curToken , final List < Token > tokens ) { if ( curToken . tokenLength ( ) != 0 ) { if ( this . unTokenizable ) { tokens . add ( curToken ) ; } else if ( ! this . unTokenizable ) { if ( ! replacement . matcher ( curToken . getTokenValue ( ) ) . matches ( ) ) { tokens . add ( curToken ) ; } } } }
Add tokens if certain conditions are met .
8,786
public String getUrl ( TileCode tileCode ) { int y = isYAxisInverted ( ) ? invertedY ( tileCode ) : tileCode . getY ( ) ; return fillPlaceHolders ( getNextUrl ( ) , tileCode . getX ( ) , y , tileCode . getTileLevel ( ) ) ; }
Get the URL that points to the image representing the given tile code .
8,787
protected String getNextUrl ( ) { String url = urls . get ( currentIndex ) ; currentIndex = ( currentIndex + 1 ) % urls . size ( ) ; return url ; }
We use Round - Robin to determine the next URL to fetch tiles from .
8,788
public static String buildAction ( Class < ? > clazz , String action ) { return new StringBuilder ( ) . append ( clazz . getCanonicalName ( ) ) . append ( "." ) . append ( action ) . toString ( ) ; }
Build a custom intent action name like jp . co . nohana . amalgam . Sample . ACTION_SAMPLE .
8,789
public static JSONObject getChild ( JSONObject jsonObject , String key ) throws JSONException { checkArguments ( jsonObject , key ) ; JSONValue value = jsonObject . get ( key ) ; if ( value != null ) { if ( value . isObject ( ) != null ) { return value . isObject ( ) ; } else if ( value . isNull ( ) != null ) { return null ; } throw new JSONException ( "Child is not a JSONObject, but a: " + value . getClass ( ) ) ; } return null ; }
Get a child JSON object from a parent JSON object .
8,790
public static JSONArray getChildArray ( JSONObject jsonObject , String key ) throws JSONException { checkArguments ( jsonObject , key ) ; JSONValue value = jsonObject . get ( key ) ; if ( value != null ) { if ( value . isArray ( ) != null ) { return value . isArray ( ) ; } else if ( value . isNull ( ) != null ) { return null ; } throw new JSONException ( "Child is not a JSONArray, but a: " + value . getClass ( ) ) ; } return null ; }
Get a child JSON array from a parent JSON object .
8,791
public static void addToJson ( JSONObject jsonObject , String key , Object value ) throws JSONException { if ( jsonObject == null ) { throw new JSONException ( "Can't add key '" + key + "' to a null object." ) ; } if ( key == null ) { throw new JSONException ( "Can't add null key." ) ; } JSONValue jsonValue = null ; if ( value != null ) { if ( value instanceof Date ) { jsonValue = new JSONString ( JsonService . format ( ( Date ) value ) ) ; } else if ( value instanceof JSONValue ) { jsonValue = ( JSONValue ) value ; } else { jsonValue = new JSONString ( value . toString ( ) ) ; } } jsonObject . put ( key , jsonValue ) ; }
Add a certain object value to the given JSON object .
8,792
public static boolean isNullObject ( JSONObject jsonObject , String key ) throws JSONException { checkArguments ( jsonObject , key ) ; JSONValue value = jsonObject . get ( key ) ; boolean isNull = false ; if ( value == null || value . isNull ( ) != null ) { isNull = true ; } return isNull ; }
checks if a certain object value is null .
8,793
public static < A , B > BaseListCommand < A , B > and ( Iterable < ? extends Command < A , B > > commands ) { return new AndCommand < > ( commands ) ; }
Returns a task that executes all tasks sequentially applying the same argument to each . The result of the execution is an ArrayList containing one element per command in the order the commands were specified here .
8,794
protected Label newActionLinkLabel ( final String id , final IModel < String > model ) { final Label label = ComponentFactory . newLabel ( id , model ) ; return label ; }
Factory method for creating the new Label . This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a new Label .
8,795
public static int getVersionCode ( Context context , int fallback ) { try { PackageManager manager = context . getPackageManager ( ) ; PackageInfo info = manager . getPackageInfo ( context . getPackageName ( ) , 0 ) ; return info . versionCode ; } catch ( NameNotFoundException e ) { Log . e ( TAG , "no such package installed on the device: " , e ) ; } return fallback ; }
Read version code from the manifest of the context .
8,796
public static String getVersionName ( Context context ) { try { PackageManager manager = context . getPackageManager ( ) ; PackageInfo info = manager . getPackageInfo ( context . getPackageName ( ) , 0 ) ; return info . versionName ; } catch ( NameNotFoundException e ) { throw new IllegalStateException ( "no such package installed on the device: " , e ) ; } }
Read version name from the manifest of the context .
8,797
public static boolean isPackageInstalled ( Context context , String targetPackage ) { PackageManager manager = context . getPackageManager ( ) ; Intent intent = new Intent ( ) ; intent . setPackage ( targetPackage ) ; return manager . resolveActivity ( intent , 0 ) != null ; }
Checks if the target package is installed on this device .
8,798
public void onLoadingDone ( Callback < String , String > onLoadingDone , int nrRetries ) { ImageReloader reloader = new ImageReloader ( getSrc ( ) , onLoadingDone , nrRetries ) ; asImage ( ) . addLoadHandler ( reloader ) ; asImage ( ) . addErrorHandler ( reloader ) ; }
Apply a call - back that is executed when the image is done loading . This image is done loading when it has either loaded successfully or when 5 attempts have failed . In any case the callback s execute method will be invoked thereby indicating success or failure .
8,799
private void printLine ( int size ) { for ( int i = 0 ; i < size ; i ++ ) { printStream . append ( "-" ) ; } printStream . append ( "\n" ) ; }
Auxiliary method that prints a horizontal line of a given size