signature:
public class Slf4jUtils { /** * Similar to { @ link # isEnabled } method except that the marker data is also taken into account .
 * @ param marker The marker data to take into consideration
 * @ return < code > true < / code > if this Logger is enabled for the given < code > level < / code > , < code > false < / code > otherwise . */
public static boolean isEnabled ( @ Nonnull Logger logger , @ Nonnull LogLevel level , @ Nonnull Marker marker ) { } }

implementation: final boolean result ; if ( trace . equals ( level ) ) { result = logger . isTraceEnabled ( marker ) ; } else if ( debug . equals ( level ) ) { result = logger . isDebugEnabled ( marker ) ; } else if ( info . equals ( level ) ) { result = logger . isInfoEnabled ( marker ) ; } else if ( warning . equals ( level ) ) { result = logger . isWarnEnabled ( marker ) ; } else if ( error . equals ( level ) || fatal . equals ( level ) ) { result = logger . isErrorEnabled ( marker ) ; } else { result = isEnabled ( logger , normalize ( level ) , marker ) ; } return result ;


signature:
public class Slf4jUtils { /** * Log a message with the specific Marker at the given < code > level < / code > .
 * @ param marker the marker data specific to this log statement
 * @ param msg the message string to be logged */
public static void log ( @ Nonnull Logger logger , @ Nonnull LogLevel level , @ Nonnull Marker marker , @ Nullable String msg ) { } }

implementation: if ( logger instanceof LocationAwareLogger ) { log ( ( LocationAwareLogger ) logger , level , FQCN , marker , msg , null , null ) ; } else if ( trace . equals ( level ) ) { logger . trace ( marker , msg ) ; } else if ( debug . equals ( level ) ) { logger . debug ( marker , msg ) ; } else if ( info . equals ( level ) ) { logger . info ( marker , msg ) ; } else if ( warning . equals ( level ) ) { logger . warn ( marker , msg ) ; } else if ( error . equals ( level ) || fatal . equals ( level ) ) { logger . error ( marker , msg ) ; } else { log ( logger , normalize ( level ) , marker , msg ) ; }


signature:
public class Google2Provider { /** * Returns the user ' s profile using the attributes that Eureka ! Clinical
 * expects .
 * @ param body the JSON response from the user profile request .
 * @ return the user ' s profile . */
@ Override protected UserProfile extractUserProfile ( final String body ) { } }

implementation: final GoogleProfile profile = new GoogleProfile ( ) ; final JsonNode json = JsonHelper . getFirstNode ( body ) ; if ( json != null ) { profile . setId ( JsonHelper . get ( json , "id" ) ) ; profile . addAttribute ( EurekaAttributesDefinition . USERNAME , JsonHelper . get ( json , Google2AttributesDefinition . EMAIL ) ) ; profile . addAttribute ( EurekaAttributesDefinition . FIRSTNAME , JsonHelper . get ( json , Google2AttributesDefinition . GIVEN_NAME ) ) ; profile . addAttribute ( EurekaAttributesDefinition . LASTNAME , JsonHelper . get ( json , Google2AttributesDefinition . FAMILY_NAME ) ) ; profile . addAttribute ( EurekaAttributesDefinition . FULLNAME , JsonHelper . get ( json , Google2AttributesDefinition . NAME ) ) ; profile . addAttribute ( EurekaAttributesDefinition . EMAIL , JsonHelper . get ( json , Google2AttributesDefinition . EMAIL ) ) ; } return profile ;


signature:
public class GlobusOAuth20ServiceImpl { /** * Makes the call to request an access token for an authorized user .
 * @ param requestToken not used .
 * @ param verifier the code query parameter that Globus included in the
 * redirect after the authorization call .
 * @ return the access token . */
@ Override public Token getAccessToken ( Token requestToken , Verifier verifier ) { } }

implementation: OAuthRequest request = new ProxyOAuthRequest ( this . api . getAccessTokenVerb ( ) , this . api . getAccessTokenEndpoint ( ) , this . proxyHost , this . proxyPort ) ; String userpass = this . config . getApiKey ( ) + ":" + this . config . getApiSecret ( ) ; String basicAuth = "Basic " + javax . xml . bind . DatatypeConverter . printBase64Binary ( userpass . getBytes ( ) ) ; request . addHeader ( "Authorization" , basicAuth ) ; request . addBodyParameter ( "grant_type" , "authorization_code" ) ; request . addBodyParameter ( "code" , verifier . getValue ( ) ) ; request . addBodyParameter ( "redirect_uri" , config . getCallback ( ) ) ; Response response = request . send ( ) ; String body = response . getBody ( ) ; JsonNode json = JsonHelper . getFirstNode ( body ) ; if ( json != null ) { return new Token ( ( String ) JsonHelper . get ( json , "access_token" ) , "" , body ) ; } else { return null ; }


signature:
public class GlobusOAuth20ServiceImpl { /** * Adds an authorization header containing the bearer token to a request .
 * It is intended for use in API calls after getting the access token , such
 * as requesting the user ' s profile .
 * @ param accessToken the user ' s access token .
 * @ param request the requests . */
@ Override public void signRequest ( Token accessToken , OAuthRequest request ) { } }

implementation: request . addHeader ( "Authorization" , "Bearer " + accessToken . getToken ( ) ) ;


signature:
public class GlobusProvider { /** * Initializes the signing of Globus API calls with an access token . A
 * superclass that overrides this method must call this method in the
 * overridden version , or you must override { @ link # sendRequestForData ( org . scribe . model . Token , java . lang . String ) }
 * with a new implementation . */
@ Override protected void internalInit ( ) { } }

implementation: this . service = new GlobusOAuth20ServiceImpl ( new GlobusApi ( ) , new OAuthConfig ( this . key , this . secret , this . callbackUrl , SignatureType . Header , "user" , null ) , this . proxyHost , this . proxyPort ) ;


signature:
public class GlobusProvider { /** * Calls any Globus endpoint that requires already being authenticated .
 * Relies on { @ link # internalInit ( ) } to setup request signing .
 * @ param accessToken the access token to use when signing the request .
 * @ param dataUrl the endpoint to call .
 * @ return the response body .
 * @ throws HttpException if an error occurred calling the endpoint . */
@ Override protected String sendRequestForData ( Token accessToken , String dataUrl ) throws HttpException { } }

implementation: final ProxyOAuthRequest request = new ProxyOAuthRequest ( Verb . GET , dataUrl , this . proxyHost , this . proxyPort ) ; if ( this . connectTimeout != 0 ) { request . setConnectTimeout ( this . connectTimeout , TimeUnit . MILLISECONDS ) ; } if ( this . readTimeout != 0 ) { request . setReadTimeout ( this . readTimeout , TimeUnit . MILLISECONDS ) ; } this . service . signRequest ( accessToken , request ) ; request . addHeader ( "Content-Type" , "application/json" ) ; final Response response = request . send ( ) ; final int code = response . getCode ( ) ; final String body = response . getBody ( ) ; if ( code != 200 ) { throw new HttpException ( code , body ) ; } return body ;


signature:
public class GlobusProvider { /** * Returns the user ' s profile using the attributes that Eureka ! Clinical
 * expects . If the system property
 * < code > scribeupext . globus . legacyUsernames < / code > is set and has value
 * < code > true < / code > ( case - insensitive ) , this method will omit the
 * < code > @ globusid . org < / code > suffix when extracting the user ' s username .
 * @ param body the JSON response from the user profile request .
 * @ return the user ' s profile . */
@ Override protected UserProfile extractUserProfile ( final String body ) { } }

implementation: GlobusProfile profile = new GlobusProfile ( ) ; JsonNode json = JsonHelper . getFirstNode ( body ) ; if ( json != null ) { String username = JsonHelper . get ( json , GlobusAttributesDefinition . USERNAME ) . toString ( ) ; if ( LEGACY_USERNAMES ) { username = username . split ( "@" ) [ 0 ] ; } profile . setId ( username ) ; profile . addAttribute ( EurekaAttributesDefinition . USERNAME , username ) ; profile . addAttribute ( EurekaAttributesDefinition . FULLNAME , JsonHelper . get ( json , GlobusAttributesDefinition . FULLNAME ) ) ; profile . addAttribute ( EurekaAttributesDefinition . EMAIL , JsonHelper . get ( json , GlobusAttributesDefinition . EMAIL ) ) ; } return profile ;


signature:
public class GitHubProvider { /** * Returns the user ' s profile using the attributes that Eureka ! Clinical
 * expects .
 * @ param body the JSON response from the user profile request .
 * @ return the user ' s profile . */
@ Override protected UserProfile extractUserProfile ( String body ) { } }

implementation: final GitHubProfile profile = new GitHubProfile ( ) ; final JsonNode json = JsonHelper . getFirstNode ( body ) ; if ( json != null ) { profile . setId ( JsonHelper . get ( json , "id" ) ) ; profile . addAttribute ( EurekaAttributesDefinition . USERNAME , JsonHelper . get ( json , GitHubAttributesDefinition . LOGIN ) ) ; profile . addAttribute ( EurekaAttributesDefinition . FULLNAME , JsonHelper . get ( json , GitHubAttributesDefinition . NAME ) ) ; profile . addAttribute ( EurekaAttributesDefinition . EMAIL , JsonHelper . get ( json , GitHubAttributesDefinition . EMAIL ) ) ; profile . addAttribute ( EurekaAttributesDefinition . ORGANIZATION , JsonHelper . get ( json , GitHubAttributesDefinition . COMPANY ) ) ; } return profile ;


signature:
public class SSLTwitterProvider { /** * Returns the user ' s profile using the attributes that Eureka ! Clinical
 * expects .
 * @ param body the JSON response from the user profile request .
 * @ return the user ' s profile . */
@ Override protected UserProfile extractUserProfile ( final String body ) { } }

implementation: final TwitterProfile profile = new TwitterProfile ( ) ; final JsonNode json = JsonHelper . getFirstNode ( body ) ; if ( json != null ) { profile . setId ( JsonHelper . get ( json , "id" ) ) ; profile . addAttribute ( EurekaAttributesDefinition . USERNAME , JsonHelper . get ( json , TwitterAttributesDefinition . SCREEN_NAME ) ) ; profile . addAttribute ( EurekaAttributesDefinition . FULLNAME , JsonHelper . get ( json , TwitterAttributesDefinition . NAME ) ) ; } return profile ;


signature:
public class GlobusApi { /** * Returns the URL for authorizing the user .
 * @ param config query parameters to add to the base URL .
 * @ return the URL for authorizing the user . */
@ Override public String getAuthorizationUrl ( OAuthConfig config ) { } }

implementation: Preconditions . checkValidUrl ( config . getCallback ( ) , "Must provide a valid url as callback." ) ; return String . format ( AUTHORIZE_URL , config . getApiKey ( ) , OAuthEncoder . encode ( config . getCallback ( ) ) , SCOPES ) ;


signature:
public class Projections { /** * Creates a " count distinct " projection for the specified relative path .
 * Calling the method is the same as manually chaining calls to { @ link # count ( Projection ) } ,
 * { @ link # distinct ( Projection ) } and { @ link # relativePath ( String ) } .
 * The result of the query will always be a { @ link Long } .
 * @ param relativePath relative path
 * @ return new projection instance */
public static CountProjection countDistinct ( String relativePath ) { } }

implementation: return new CountProjection ( new DistinctProjection ( new PathProjection ( relativePath , false , false ) ) ) ;


signature:
public class ProjectWizard { /** * This method is called when ' Finish ' button is pressed in the wizard . We
 * will create an operation and run it using wizard as execution context . */
public boolean performFinish ( ) { } }

implementation: final String containerName = getProjectName ( ) ; final IPath location = projectPage . useDefaults ( ) ? null : projectPage . getLocationPath ( ) ; IRunnableWithProgress op = new IRunnableWithProgress ( ) { public void run ( IProgressMonitor monitor ) throws InvocationTargetException { try { doFinish ( containerName , location , monitor ) ; } catch ( CoreException e ) { throw new InvocationTargetException ( e ) ; } finally { monitor . done ( ) ; } } } ; try { getContainer ( ) . run ( true , false , op ) ; } catch ( InterruptedException e ) { return false ; } catch ( InvocationTargetException e ) { Throwable realException = e . getTargetException ( ) ; MessageDialog . openError ( getShell ( ) , "Error" , realException . getMessage ( ) ) ; return false ; } return true ;


signature:
public class ProjectWizard { /** * The worker method . It will find the container , create the file if missing
 * or just replace its contents , and open the editor on the newly created
 * file . */
private void doFinish ( String containerName , IPath location , IProgressMonitor monitor ) throws CoreException { } }

implementation:
// create a sample file
monitor . beginTask ( "Creating " + containerName , 2 ) ; monitor . worked ( 1 ) ; final Archetype archetype = new Archetype ( ) ; archetype . setGroupId ( "org.glassmaker" ) ; archetype . setArtifactId ( "org.glassmaker.archetype.basic" ) ; archetype . setVersion ( "0.0.1" ) ; ProjectParameters params = parametersPage . getParams ( ) ; final String groupId = params . getGroupId ( ) ; final String artifactId = params . getArtifactId ( ) ; final String version = params . getVersion ( ) ; final String javaPackage = params . getPackageName ( ) ; final Properties properties = params . getProperties ( ) ; properties . setProperty ( "oauth2callbackurl" , properties . getProperty ( ProjectWizardParametersPage . O_AUTH_CALLBACK ) ) ; properties . setProperty ( "clientid" , properties . getProperty ( ProjectWizardParametersPage . CLIENT_ID ) ) ; properties . setProperty ( "clientsecret" , properties . getProperty ( ProjectWizardParametersPage . CLIENT_SECRET ) ) ; List < IProject > projects = MavenPlugin . getProjectConfigurationManager ( ) . createArchetypeProjects ( location , archetype , groupId , artifactId , version , javaPackage , properties , importConfiguration , monitor ) ;


signature:
public class CBImage { /** * 在图片上写字
 * @ param text 字符串
 * @ param fontSize 字体大小
 * @ param color 字体颜色
 * @ return 图片 */
public BufferedImage drawText ( String text , int fontSize , Color color ) { } }

implementation: Graphics g = image . getGraphics ( ) ; g . setColor ( color ) ; Font f = new Font ( "宋体" , Font . BOLD , fontSize ) ; g . setFont ( f ) ; int len = text . length ( ) ; g . drawString ( text , ( width - fontSize * len ) / 2 , ( height + ( int ) ( fontSize / 1.5 ) ) / 2 ) ; g . dispose ( ) ; return image ;


signature:
public class CBImage { /** * 缩放图片
 * @ param scaleW 水平缩放比例
 * @ param scaleH 垂直缩放比例
 * @ return bufferedImage */
public BufferedImage scale ( double scaleW , double scaleH ) { } }

implementation: width = ( int ) ( width * scaleW ) ; height = ( int ) ( height * scaleH ) ; BufferedImage newImage = new BufferedImage ( width , height , image . getType ( ) ) ; Graphics g = newImage . getGraphics ( ) ; g . drawImage ( image , 0 , 0 , width , height , null ) ; g . dispose ( ) ; image = newImage ; return image ;


signature:
public class CBImage { /** * 旋转90度旋转
 * @ return 对应图片 */
public BufferedImage rotate ( ) { } }

implementation: BufferedImage dest = new BufferedImage ( height , width , BufferedImage . TYPE_INT_ARGB ) ; for ( int i = 0 ; i < width ; i ++ ) for ( int j = 0 ; j < height ; j ++ ) { dest . setRGB ( height - j - 1 , i , image . getRGB ( i , j ) ) ; } image = dest ; return image ;


signature:
public class CBImage { /** * 保存图片
 * @ param file 图片文件 */
public void save ( File file ) { } }

implementation: try { ImageIO . write ( image , "png" , file ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; }


signature:
public class JodaLocalDateTimeDeserializer { /** * ( non - Javadoc )
 * @ see org . codehaus . jackson . map . JsonDeserializer # deserialize ( org . codehaus
 * . jackson . JsonParser , org . codehaus . jackson . map . DeserializationContext ) */
@ Override public LocalDateTime deserialize ( final JsonParser parser , final DeserializationContext context ) throws IOException , JsonProcessingException { } }

implementation: return formatter . parseLocalDateTime ( parser . getText ( ) ) ;


signature:
public class ProjectWizardParametersPage { /** * Creates page controls . */
public void createControl ( Composite parent ) { } }

implementation: Composite composite = new Composite ( parent , SWT . NULL ) ; composite . setLayout ( new GridLayout ( 3 , false ) ) ; createArtifactGroup ( composite ) ; createPropertiesGroup ( composite ) ; setArchetype ( ) ; validate ( ) ; setControl ( composite ) ;


signature:
public class ProjectWizardParametersPage { /** * Validates the contents of this wizard page .
 * Feedback about the validation is given to the user by displaying error
 * messages or informative messages on the wizard page . Depending on the
 * provided user input , the wizard page is marked as being complete or not .
 * If some error or missing input is detected in the user input , an error
 * message or informative message , respectively , is displayed to the user .
 * If the user input is complete and correct , the wizard page is marked as
 * begin complete to allow the wizard to proceed . To that end , the following
 * conditions must be met :
 * < ul >
 * < li > The user must have provided a valid group ID . < / li >
 * < li > The user must have provided a valid artifact ID . < / li >
 * < li > The user must have provided a version for the artifact . < / li >
 * < / ul >
 * @ see org . eclipse . jface . dialogs . DialogPage # setMessage ( java . lang . String )
 * @ see org . eclipse . jface . wizard . WizardPage # setErrorMessage ( java . lang . String )
 * @ see org . eclipse . jface . wizard . WizardPage # setPageComplete ( boolean ) */
void validate ( ) { } }

implementation: if ( isVisible ( ) ) { String error = validateInput ( ) ; setErrorMessage ( error ) ; setPageComplete ( error == null ) ; }


signature:
public class ProjectWizardParametersPage { /** * Updates the properties when a project name is set on the first page of
 * the wizard . */
public void setProjectName ( String projectName ) { } }

implementation:
if ( artifactIdCombo . getText ( ) . equals ( groupIdCombo . getText ( ) ) ) { groupIdCombo . setText ( projectName ) ; } artifactIdCombo . setText ( projectName ) ; packageCombo . setText ( "org." + projectName . replace ( '-' , '.' ) ) ; // $ NON - NLS - 1 $
validate ( ) ;


signature:
public class ProjectWizardParametersPage { /** * Updates the properties when a project name is set on the first page of
 * the wizard . */
public void setParentProject ( String groupId , String artifactId , String version ) { } }

implementation: groupIdCombo . setText ( groupId ) ; versionCombo . setText ( version ) ; validate ( ) ;


signature:
public class ProjectWizardParametersPage { /** * Returns the default package name . */
protected String getDefaultJavaPackage ( ) { } }

implementation: return ProjectWizardParametersPage . getDefaultJavaPackage ( groupIdCombo . getText ( ) . trim ( ) , artifactIdCombo . getText ( ) . trim ( ) ) ;


signature:
public class ProjectWizardParametersPage { /** * Loads the group value when the page is displayed . */
public void setVisible ( boolean visible ) { } }

implementation: super . setVisible ( visible ) ; boolean shouldValidate = false ; if ( visible ) { if ( groupIdCombo . getText ( ) . length ( ) == 0 && groupIdCombo . getItemCount ( ) > 0 ) { groupIdCombo . setText ( groupIdCombo . getItem ( 0 ) ) ; packageCombo . setText ( getDefaultJavaPackage ( ) ) ; packageCustomized = false ; } if ( shouldValidate ) { validate ( ) ; } }


signature:
public class NotExpression { /** * @ see org . criteria4jpa . criterion . Criterion # toQueryString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toQueryString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation: return "NOT " + criterion . toQueryString ( criteria , queryBuilder ) ;


signature:
public class CriteriaImpl { /** * internal */
public void addOrder ( Criteria criteria , Order order ) { } }

implementation: this . orderList . add ( new MetaEntry < Order > ( criteria , order ) ) ;


signature:
public class OAuth2EntryPoint { /** * Performs the redirect ( or forward ) to the login form URL . */
public void commence ( HttpServletRequest req , HttpServletResponse resp , AuthenticationException authException ) throws IOException , ServletException { } }

implementation: String redirectUrl = null ; logger . debug ( "No auth context found. Kicking off a new auth flow." ) ; AuthorizationCodeFlow flow = oAuth2Util . newAuthorizationCodeFlow ( ) ; GenericUrl url = flow . newAuthorizationUrl ( ) . setRedirectUri ( getCallbackUrl ( ) ) ; url . set ( "approval_prompt" , "force" ) ; redirectUrl = url . build ( ) ; redirectStrategy . sendRedirect ( req , resp , redirectUrl ) ;


signature:
public class CriteriaQueryBuilder { /** * Creates a human - readable representation of the query that will be created
 * from this builder */
public String createQueryDebugString ( ) { } }

implementation:
// create query
String queryString = createQueryString ( ) ; // create list of parameters
List < Object > parameterValues = getQueryParametersAsList ( ) ; // create debug string
return QueryLogHelper . createQueryLogMessage ( queryString , parameterValues ) ;


signature:
public class CriteriaQueryBuilder { /** * Creates an ordered list of all parameter values registered at
 * the root criteria .
 * @ return list of parameter values */
private List < Object > getQueryParametersAsList ( ) { } }

implementation:
// iterate over all restrictions of this criteria
Iterator < MetaEntry < Criterion > > iter = rootCriteria . getCriterionList ( ) . iterator ( ) ; // result list
List < Object > result = new ArrayList < Object > ( ) ; // loop over all criterion
while ( iter . hasNext ( ) ) { // the current criterion
Criterion criterion = iter . next ( ) . getEntry ( ) ; // get the values to set
Object [ ] parameterValues = criterion . getParameterValues ( ) ; // null should be ignores
if ( parameterValues == null ) { continue ; } // set all parameters
for ( Object value : parameterValues ) { result . add ( value ) ; } } return result ;


signature:
public class PreferenceInitializer { /** * ( non - Javadoc )
 * @ see org . eclipse . core . runtime . preferences . AbstractPreferenceInitializer # initializeDefaultPreferences ( ) */
public void initializeDefaultPreferences ( ) { } }

implementation: IPreferenceStore store = GlassmakerUIPlugin . getDefault ( ) . getPreferenceStore ( ) ; store . setDefault ( PreferenceConstants . CLIENT_ID , "YOU_MUST_PROVIDE_A_CLIENT_ID" ) ; store . setDefault ( PreferenceConstants . CLIENT_SECRET , "YOU_MUST_PROVIDE_A_CLIENT_SECRET" ) ;


signature:
public class ResponseInitializer { /** * Configures each request . This does 3 things :
 * < ul >
 * < li > Adds the authorization token to each request < / li >
 * < li > Adds the JSON factory to the request < / li >
 * < li > Adds exponential back off capability < / li >
 * < / ul >
 * @ param request
 * is the request to configure */
protected void configure ( final HttpRequest request ) { } }

implementation: request . getHeaders ( ) . setAuthorization ( String . format ( "OAuth %s" , token ) ) ; request . setParser ( new JsonObjectParser ( jsonFactory ) ) ; final ExponentialBackOff backoff = new ExponentialBackOff . Builder ( ) . setInitialIntervalMillis ( 500 ) . setMaxElapsedTimeMillis ( 60000 ) . setMaxIntervalMillis ( 30000 ) . setMultiplier ( 1.5 ) . setRandomizationFactor ( 0.5 ) . build ( ) ; request . setUnsuccessfulResponseHandler ( new HttpBackOffUnsuccessfulResponseHandler ( backoff ) ) ;


signature:
public class ResponseInitializer { /** * ( non - Javadoc )
 * @ see
 * com . google . api . client . http . HttpUnsuccessfulResponseHandler # handleResponse
 * ( com . google . api . client . http . HttpRequest ,
 * com . google . api . client . http . HttpResponse , boolean ) */
@ Override public boolean handleResponse ( final HttpRequest request , final HttpResponse response , final boolean supportsRetry ) throws IOException { } }

implementation: log . trace ( "HTTP request {} resulted in {} with response {} and headers {}" , request . getUrl ( ) . toString ( ) , response . getStatusCode ( ) , response . getStatusMessage ( ) , response . getHeaders ( ) . toString ( ) ) ; throw new HTTPException ( response . getStatusCode ( ) , response . getStatusMessage ( ) ) ;


signature:
public class CBStringUtil { /** * 一些列字符串是否为null或者长度为0
 * @ param ins 输入字符串
 * @ return 是否为空或长度为0 */
public static boolean isEmptyOrNull ( String ... ins ) { } }

implementation: if ( ins == null || ins . length == 0 ) { return true ; } for ( String in : ins ) { if ( isEmptyOrNull ( in ) ) { return true ; } } return false ;


signature:
public class CBStringUtil { /** * 按照ascii ( 字典 ) 顺序比较字符大小
 * @ param str1 字符串1
 * @ param str2 字符串2
 * @ return 0 - 相等 正数 - 大于 负数 - 小于 */
public static int compare ( String str1 , String str2 ) { } }

implementation:
// 有一个为null的话按照非null的大处理
if ( str1 == null || str2 == null ) { return Integer . compare ( ( str1 == null ) ? 0 : 1 , ( str2 == null ) ? 0 : 1 ) ; } if ( str1 . length ( ) == 0 || str2 . length ( ) == 0 ) { return str1 . length ( ) - str2 . length ( ) ; } int res = 0 ; int position = 0 ; int maxComparePosition = Math . min ( str1 . length ( ) , str2 . length ( ) ) ; while ( position < maxComparePosition ) { char ch1 = str1 . charAt ( position ) ; char ch2 = str2 . charAt ( position ) ; if ( ch1 == ch2 ) { position ++ ; continue ; } // 不相等的话返回差值 , 代表字符串大小
res = ch1 - ch2 ; break ; } // 如果最后比较结果是相等的话 , 说明比较长度内的字符串相等 , 需要比较字符串长度
return res == 0 ? ( str1 . length ( ) - str2 . length ( ) ) : res ;


signature:
public class CBStringUtil { /** * 含子串是否超过一定次数
 * @ param srcString 原串
 * @ param desString 目标子串
 * @ param number 次数
 * @ return 是否 */
public static boolean containGreaterThan ( String srcString , String desString , int number ) { } }

implementation: boolean res = false ; int totalNumber = containStatistics ( srcString , desString ) ; if ( totalNumber > number ) { res = true ; } return res ;


signature:
public class CBStringUtil { /** * 含子串的次数
 * @ param srcString 原串
 * @ param desString 目标子串
 * @ return 次数 */
public static int containStatistics ( String srcString , String desString ) { } }

implementation: int length = desString . length ( ) ; String newString = srcString . replace ( desString , "" ) ; return ( srcString . length ( ) - newString . length ( ) ) / length ;


signature:
public class CBStringUtil { /** * 含模式串是否超过一定次数
 * @ param srcString 原串
 * @ param desString 目标模式串
 * @ param number 次数
 * @ return 是否 */
public static boolean containRegexGreaterThan ( String srcString , String desString , int number ) { } }

implementation: boolean res = false ; int totalNumber = containRegexStatistics ( srcString , desString ) ; if ( totalNumber > number ) { res = true ; } return res ;


signature:
public class CBStringUtil { /** * 含模式串的次数
 * @ param srcString 原串
 * @ param desString 目标模式串
 * @ return 次数 */
public static int containRegexStatistics ( String srcString , String desString ) { } }

implementation: int number = 0 ; while ( true ) { String newString = srcString . replaceFirst ( desString , "" ) ; if ( newString . length ( ) == srcString . length ( ) ) { break ; } number ++ ; srcString = newString ; } return number ;


signature:
public class DistinctProjection { /** * @ see org . criteria4jpa . projection . Projection # toQueryString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toQueryString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation: return new StringBuilder ( ) . append ( "DISTINCT " ) . append ( projection . toQueryString ( criteria , queryBuilder ) ) . toString ( ) ;


signature:
public class CBConnection { /** * 连接地址
 * @ param url url
 * @ param charset 编码
 * @ return 连接 */
public CBConnection connect ( String url , String charset ) { } }

implementation: this . url = url ; this . charset = charset ; return this ;


signature:
public class CBConnection { /** * 添加请求头部 , 此方法将会清空之前所有已经设置的头部信息
 * @ param header 请求头部
 * @ return 连接
 * @ see # header ( String , String ) */
public CBConnection header ( Map < String , String > header ) { } }

implementation: if ( header != null ) { this . header = header ; } else { header . clear ( ) ; } return this ;


signature:
public class CBConnection { /** * 添加请求头部 , 仅仅添加一个 , 不会清空之前已经设置的头部
 * @ param key 请求头部名字
 * @ param value 请求头部值
 * @ return 连接
 * @ see # header ( Map ) */
public CBConnection header ( String key , String value ) { } }

implementation: header . put ( key , value ) ; return this ;


signature:
public class CBConnection { /** * 设置请求数据
 * @ param data 表单数据
 * @ return 连接 */
public CBConnection data ( String ... data ) { } }

implementation: if ( data . length % 2 == 0 ) { this . data = CBParam . paramsToString ( charset , data ) ; } return this ;


signature:
public class CBConnection { /** * 设置请求数据
 * @ param data 表单数据
 * @ return 连接 */
public CBConnection data ( Map < String , String > data ) { } }

implementation: if ( data != null ) { this . data = CBParam . paramsToString ( charset , data ) ; } return this ;


signature:
public class CBConnection { /** * 获取网页的内容
 * @ return 网页 / 目标源码
 * @ throws IOException 异常 */
public String execute ( ) throws IOException { } }

implementation:
if ( CBStringUtil . isEmptyOrNull ( this . url ) ) { return null ; } StringBuilder netString = new StringBuilder ( ) ; URL url = new URL ( this . url ) ; HttpURLConnection conn = ( HttpURLConnection ) url . openConnection ( ) ; // 设置请求方法
conn . setRequestMethod ( method . value ) ; // 设置头部
for ( Map . Entry < String , String > item : header . entrySet ( ) ) { conn . setRequestProperty ( item . getKey ( ) , item . getValue ( ) ) ; } // 保持session的把设置cookie
if ( keepSession && ! CBStringUtil . isEmptyOrNull ( cookie ) && ! header . containsKey ( CBHeader . COOKIE ) && ! pauseSessionForOnce ) { conn . setRequestProperty ( CBHeader . COOKIE , cookie ) ; } pauseSessionForOnce = false ; // 设置超时时间
conn . setConnectTimeout ( timeout ) ; conn . setReadTimeout ( timeout ) ; // 设置跳转
conn . setInstanceFollowRedirects ( followRedirects ) ; if ( method == CBMethod . POST && ! CBStringUtil . isEmptyOrNull ( data ) ) { conn . setDoOutput ( true ) ; OutputStream out = conn . getOutputStream ( ) ; out . write ( data . getBytes ( ) ) ; out . flush ( ) ; out . close ( ) ; } BufferedReader buff = new BufferedReader ( new InputStreamReader ( conn . getInputStream ( ) , charset ) ) ; String line ; while ( ( line = buff . readLine ( ) ) != null ) { netString . append ( "\n" ) ; netString . append ( line ) ; } buff . close ( ) ; // 记录cookie值 , 用于下次传递
String tmpCookie = conn . getHeaderField ( CBHeader . SET_COOKIE ) ; if ( keepSession && CBStringUtil . isEmptyOrNull ( cookie ) && ! CBStringUtil . isEmptyOrNull ( tmpCookie ) ) { cookie = tmpCookie ; } return netString . length ( ) > 0 ? netString . substring ( 1 ) : netString . toString ( ) ;


signature:
public class CBConnection { /** * 参数重置
 * 其中timeout , cookie , keepSession不进行重置
 * @ return 连接 */
protected CBConnection resetSomeState ( ) { } }

implementation: url = null ; followRedirects = CBDefaultConfig . FOLLOW_REDIRECTS ; header . clear ( ) ; data = null ; if ( ! keepMethod ) { method = CBDefaultConfig . METHOD ; } if ( ! keepCharset ) { charset = CBDefaultConfig . CHARSET ; } return this ;


signature:
public class CBConnection { /** * 保存指定位置的文件
 * @ param file 保存文件
 * @ throws IOException IO异常 */
public void saveToFile ( File file ) throws IOException { } }

implementation: if ( CBStringUtil . isEmptyOrNull ( this . url ) ) { return ; } URL url = new URL ( this . url ) ; URLConnection conn = url . openConnection ( ) ; InputStream is = conn . getInputStream ( ) ; OutputStream os = new FileOutputStream ( file ) ; byte [ ] b = new byte [ 1024 ] ; int len ; while ( ( len = is . read ( b ) ) != - 1 ) { os . write ( b , 0 , len ) ; } os . close ( ) ; is . close ( ) ;


signature:
public class PaletteView { /** * create controls and apply configurations . */
public void createPartControl ( Composite parent ) { } }

implementation:
viewer = new PaletteViewer ( ) ; viewer . createControl ( parent ) ; PaletteRoot root = new PaletteRoot ( ) ; String [ ] category = getCategories ( ) ; for ( int i = 0 ; i < category . length ; i ++ ) { PaletteDrawer group = new PaletteDrawer ( category [ i ] ) ; IPaletteItem [ ] items = getPaletteItems ( category [ i ] ) ; for ( int j = 0 ; j < items . length ; j ++ ) { HTMLPaletteEntry entry = new HTMLPaletteEntry ( items [ j ] . getLabel ( ) , null , items [ j ] . getImageDescriptor ( ) ) ; tools . put ( entry , items [ j ] ) ; group . add ( entry ) ; } root . add ( group ) ; } viewer . setPaletteRoot ( root ) ; viewer . getControl ( ) . addMouseListener ( new MouseAdapter ( ) { @ Override public void mouseDoubleClick ( MouseEvent e ) { // IWorkbenchPage page = PlatformUI . getWorkbench ( ) . getActiveWorkbenchWindow ( ) . getActivePage ( ) ;
// IEditorPart editorPart = page . getActiveEditor ( ) ;
// if ( editorPart ! = null ) {
// editorPart . setFocus ( ) ;
if ( e . button == 1 ) { EditPart part = PaletteView . this . viewer . findObjectAt ( new Point ( e . x , e . y ) ) ; IPaletteItem item = null ; if ( part != null ) { if ( part . getModel ( ) instanceof HTMLPaletteEntry ) item = tools . get ( part . getModel ( ) ) ; } if ( item != null ) insert ( item ) ; } } } ) ;


signature:
public class PaletteView { /** * Adds PaletteItem to the specified category .
 * @ param category the category
 * @ param item the item */
private void addPaletteItem ( String category , IPaletteItem item ) { } }

implementation: if ( items . get ( category ) == null ) { List < IPaletteItem > list = new ArrayList < IPaletteItem > ( ) ; items . put ( category , list ) ; } List < IPaletteItem > list = items . get ( category ) ; list . add ( item ) ;


signature:
public class PaletteView { /** * Returns PaletteItems which are contained by the specified category .
 * @ param category the category
 * @ return the array of items which are contained by the category */
private IPaletteItem [ ] getPaletteItems ( String category ) { } }

implementation: List < IPaletteItem > list = items . get ( category ) ; if ( list == null ) { return new IPaletteItem [ 0 ] ; } return list . toArray ( new IPaletteItem [ list . size ( ) ] ) ;


signature:
public class NewCardTemplatesWizardPage { /** * Correctly resizes the table so no phantom columns appear
 * @ param parent
 * the parent control
 * @ param buttons
 * the buttons
 * @ param table
 * the table
 * @ param column1
 * the first column
 * @ param column2
 * the second column
 * @ param column3
 * the third column */
private void configureTableResizing ( final Composite parent , final Table table , final TableColumn column1 , final TableColumn column2 ) { } }

implementation:
parent . addControlListener ( new ControlAdapter ( ) { public void controlResized ( ControlEvent e ) { Rectangle area = parent . getClientArea ( ) ; Point preferredSize = table . computeSize ( SWT . DEFAULT , SWT . DEFAULT ) ; int width = area . width - 2 * table . getBorderWidth ( ) ; if ( preferredSize . y > area . height ) { // Subtract the scrollbar width from the total column
// width
// if a vertical scrollbar will be required
Point vBarSize = table . getVerticalBar ( ) . getSize ( ) ; width -= vBarSize . x ; } Point oldSize = table . getSize ( ) ; if ( oldSize . x > width ) { // table is getting smaller so make the columns
// smaller first and then resize the table to
// match the client area width
column1 . setWidth ( width / 2 ) ; column2 . setWidth ( width / 2 ) ; table . setSize ( width , area . height ) ; } else { // table is getting bigger so make the table
// bigger first and then make the columns wider
// to match the client area width
table . setSize ( width , area . height ) ; column1 . setWidth ( width / 2 ) ; column2 . setWidth ( width / 2 ) ; } } } ) ;


signature:
public class NewCardTemplatesWizardPage { /** * Creates , configures and returns a source viewer to present the template
 * pattern on the preference page . Clients may override to provide a
 * custom source viewer featuring e . g . syntax coloring .
 * @ param parent
 * the parent control
 * @ return a configured source viewer */
private SourceViewer createViewer ( Composite parent ) { } }

implementation:
SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration ( ) { StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationHTML ( ) ; public String [ ] getConfiguredContentTypes ( ISourceViewer sourceViewer ) { return baseConfiguration . getConfiguredContentTypes ( sourceViewer ) ; } public LineStyleProvider [ ] getLineStyleProviders ( ISourceViewer sourceViewer , String partitionType ) { return baseConfiguration . getLineStyleProviders ( sourceViewer , partitionType ) ; } } ; SourceViewer viewer = new StructuredTextViewer ( parent , null , null , false , SWT . BORDER | SWT . V_SCROLL | SWT . H_SCROLL ) ; viewer . getTextWidget ( ) . setFont ( JFaceResources . getFont ( "org.eclipse.wst.sse.ui.textfont" ) ) ; // $ NON - NLS - 1 $
IStructuredModel scratchModel = StructuredModelManager . getModelManager ( ) . createUnManagedStructuredModelFor ( "org.glassmaker.ui.editor.CardContent" ) ; IDocument document = scratchModel . getStructuredDocument ( ) ; viewer . configure ( sourceViewerConfiguration ) ; viewer . setDocument ( document ) ; return viewer ;


signature:
public class NewCardTemplatesWizardPage { /** * Enable / disable controls in page based on fUseTemplateButton ' s current
 * state . */
void enableTemplates ( ) { } }

implementation:
boolean enabled = fUseTemplateButton . getSelection ( ) ; if ( ! enabled ) { // save last selected template
Template template = getSelectedTemplate ( ) ; if ( template != null ) fLastSelectedTemplateName = template . getName ( ) ; else fLastSelectedTemplateName = "" ; // $ NON - NLS - 1 $
fTableViewer . setSelection ( null ) ; } else { setSelectedTemplate ( fLastSelectedTemplateName ) ; } fTableViewer . getControl ( ) . setEnabled ( enabled ) ; fPatternViewer . getControl ( ) . setEnabled ( enabled ) ;


signature:
public class NewCardTemplatesWizardPage { /** * Get the currently selected template .
 * @ return */
private Template getSelectedTemplate ( ) { } }

implementation: Template template = null ; IStructuredSelection selection = ( IStructuredSelection ) fTableViewer . getSelection ( ) ; if ( selection . size ( ) == 1 ) { template = ( Template ) selection . getFirstElement ( ) ; } return template ;


signature:
public class NewCardTemplatesWizardPage { /** * Returns template string to insert .
 * @ return String to insert or null if none is to be inserted */
String getTemplateString ( ) { } }

implementation: String templateString = null ; Template template = getSelectedTemplate ( ) ; if ( template != null ) { TemplateContextType contextType = GlassmakerUIPlugin . getDefault ( ) . getTemplateContextRegistry ( ) . getContextType ( CardContextType . CONTEXT_TYPE ) ; IDocument document = new Document ( ) ; TemplateContext context = new DocumentTemplateContext ( contextType , document , 0 , 0 ) ; try { TemplateBuffer buffer = context . evaluate ( template ) ; templateString = buffer . getString ( ) ; } catch ( Exception e ) { GlassmakerUIPlugin . logError ( "Could not create template for new html" , e ) ; } } return templateString ;


signature:
public class NewCardTemplatesWizardPage { /** * Load the last template name used in New HTML File wizard . */
private void loadLastSavedPreferences ( ) { } }

implementation:
fLastSelectedTemplateName = "" ; // $ NON - NLS - 1 $
boolean setSelection = false ; String templateName = GlassmakerUIPlugin . getDefault ( ) . getPreferenceStore ( ) . getString ( HTMLUIPreferenceNames . NEW_FILE_TEMPLATE_NAME ) ; if ( templateName == null || templateName . length ( ) == 0 ) { templateName = GlassmakerUIPlugin . getDefault ( ) . getPreferenceStore ( ) . getString ( HTMLUIPreferenceNames . NEW_FILE_TEMPLATE_ID ) ; if ( templateName != null && templateName . length ( ) > 0 ) { Template template = fTemplateStore . findTemplateById ( templateName ) ; if ( template != null ) { fLastSelectedTemplateName = template . getName ( ) ; setSelection = true ; } } } else { fLastSelectedTemplateName = templateName ; setSelection = true ; } fUseTemplateButton . setSelection ( setSelection ) ; enableTemplates ( ) ;


signature:
public class NewCardTemplatesWizardPage { /** * Save template name used for next call to New HTML File wizard . */
void saveLastSavedPreferences ( ) { } }

implementation:
String templateName = "" ; // $ NON - NLS - 1 $
Template template = getSelectedTemplate ( ) ; if ( template != null ) { templateName = template . getName ( ) ; } GlassmakerUIPlugin . getDefault ( ) . getPreferenceStore ( ) . setValue ( "newFileTemplateName" , templateName ) ; GlassmakerUIPlugin . getDefault ( ) . savePluginPreferences ( ) ;


signature:
public class NewCardTemplatesWizardPage { /** * Select a template in the table viewer given the template name . If
 * template name cannot be found or templateName is null , just select
 * first item in table . If no items in table select nothing .
 * @ param templateName */
private void setSelectedTemplate ( String templateName ) { } }

implementation:
Object template = null ; if ( templateName != null && templateName . length ( ) > 0 ) { // pick the last used template
template = fTemplateStore . findTemplate ( templateName , CardContextType . CONTEXT_TYPE ) ; } // no record of last used template so just pick first element
if ( template == null ) { // just pick first element
template = fTableViewer . getElementAt ( 0 ) ; } if ( template != null ) { IStructuredSelection selection = new StructuredSelection ( template ) ; fTableViewer . setSelection ( selection , true ) ; }


signature:
public class NewCardTemplatesWizardPage { /** * Updates the pattern viewer . */
void updateViewerInput ( ) { } }

implementation:
Template template = getSelectedTemplate ( ) ; if ( template != null ) { fPatternViewer . getDocument ( ) . set ( template . getPattern ( ) ) ; String imageId = "org.glassmaker.ui.templates." + template . getName ( ) . replace ( " " , "" ) . toLowerCase ( ) ; ImageDescriptor desc = imageRegistry . getDescriptor ( imageId ) ; if ( desc != null ) { fImage . setImage ( desc . createImage ( ) ) ; } else { fImage . setImage ( null ) ; } } else { fPatternViewer . getDocument ( ) . set ( "" ) ; // $ NON - NLS - 1 $
}


signature:
public class JodaDateTimeSerializer { /** * ( non - Javadoc )
 * @ see org . codehaus . jackson . map . JsonSerializer # serialize ( java . lang . Object ,
 * org . codehaus . jackson . JsonGenerator ,
 * org . codehaus . jackson . map . SerializerProvider ) */
@ Override public void serialize ( final DateTime value , final JsonGenerator jgen , final SerializerProvider provider ) throws IOException , JsonProcessingException { } }

implementation: jgen . writeString ( value . toString ( formatter ) ) ;


signature:
public class Restrictions { /** * Adds a " like " constraint to a < i > persistent field < / i > . This method
 * requires a { @ link MatchMode } to specify how wildcards are added
 * to the value . You may also use { @ link # like ( String , String ) } if you
 * want to manually specify the wildcards in the match string .
 * @ param relativePath relative path of the field
 * @ param value the match string
 * @ param matchMode specifies how to add wildcards to the value to create
 * the LIKE expression
 * @ return { @ link Criterion } instance */
public static SimpleExpression like ( String relativePath , String value , MatchMode matchMode ) { } }

implementation: return new SimpleExpression ( relativePath , matchMode . toMatchString ( value ) , "LIKE" ) ;


signature:
public class Restrictions { /** * Adds a case - insensitive " like " constraint to a < i > persistent field < / i > .
 * This method requires a { @ link MatchMode } to specify how wildcards are added
 * to the value . You may also use { @ link # like ( String , String ) } if you
 * want to manually specify the wildcards in the match string .
 * @ param relativePath relative path of the string field
 * @ param value the match string
 * @ param matchMode specifies how to add wildcards to the value to create
 * the LIKE expression
 * @ return { @ link Criterion } instance */
public static Criterion ilike ( String relativePath , String value , MatchMode matchMode ) { } }

implementation: return new ILikeExpression ( relativePath , matchMode . toMatchString ( value ) ) ;


signature:
public class Restrictions { /** * Adds a " between " constraint to a < i > persistent field < / i > .
 * @ param relativePath relative path of the field
 * @ param lo the low end of the " between " expression
 * @ param hi the high end of the " between " expression
 * @ return { @ link Criterion } instance */
public static Criterion between ( String relativePath , Object lo , Object hi ) { } }

implementation: return new BetweenExpression ( relativePath , lo , hi , false ) ;


signature:
public class Restrictions { /** * Adds a " not between " constraint to a < i > persistent field < / i > .
 * @ param relativePath relative path of the field
 * @ param lo the low end of the " not between " expression
 * @ param hi the high end of the " not between " expression
 * @ return { @ link Criterion } instance */
public static Criterion notBetween ( String relativePath , Object lo , Object hi ) { } }

implementation: return new BetweenExpression ( relativePath , lo , hi , true ) ;


signature:
public class Restrictions { /** * Connects multiple restrictions with an logical conjunction .
 * Calling this method is a shortcut for creating a { @ link Conjunction }
 * by calling { @ link # conjunction ( ) } and adding all restrictions
 * to it .
 * @ param criterionList The restrictions to add to the conjunction .
 * @ return { @ link Conjunction } instance */
public static Conjunction and ( Criterion ... criterionList ) { } }

implementation: Conjunction junction = new Conjunction ( ) ; for ( Criterion criterion : criterionList ) { junction . add ( criterion ) ; } return junction ;


signature:
public class Restrictions { /** * Connects multiple restrictions with an logical disjunction .
 * Calling this method is a shortcut for creating a { @ link Disjunction }
 * by calling { @ link # disjunction ( ) } and adding all restrictions
 * to it .
 * @ param criterionList The restrictions to add to the disjunction .
 * @ return { @ link Disjunction } instance */
public static Disjunction or ( Criterion ... criterionList ) { } }

implementation: Disjunction junction = new Disjunction ( ) ; for ( Criterion criterion : criterionList ) { junction . add ( criterion ) ; } return junction ;


signature:
public class Restrictions { /** * Adds an " in " restriction to a persistent field .
 * @ param relativePath relative path of the persistent field
 * @ param values expected values of the field
 * @ return { @ link Criterion } instance */
public static Criterion in ( String relativePath , Collection < ? > values ) { } }

implementation: return new InExpression ( relativePath , values . toArray ( ) ) ;


signature:
public class Restrictions { /** * Creates a conjunction of " equals " restrictions for each
 * entry in the map .
 * Same as manually creating a conjunction via { @ link # conjunction ( ) }
 * and adding an equals restriction via { @ link # eq ( String , Object ) } for
 * each map entry .
 * @ param values Map containing property name to value mappings
 * @ return { @ link Conjunction } of " equal " constraints */
public static Criterion allEq ( Map < String , Object > values ) { } }

implementation: Conjunction conjunction = new Conjunction ( ) ; for ( Entry < String , Object > entry : values . entrySet ( ) ) { conjunction . add ( eq ( entry . getKey ( ) , entry . getValue ( ) ) ) ; } return conjunction ;


signature:
public class Restrictions { /** * Creates a " member of " restriction .
 * @ param relativePath relative path of a collection
 * @ param value The value to check membership for
 * @ return new { @ link Criterion } instance */
public static Criterion memberOf ( String relativePath , Object value ) { } }

implementation: return new MemberOfExpression ( relativePath , value , false ) ;


signature:
public class Restrictions { /** * Creates a " not member of " restriction .
 * @ param relativePath relative path of a collection
 * @ param value The value to check membership for
 * @ return new { @ link Criterion } instance */
public static Criterion notMemberOf ( String relativePath , Object value ) { } }

implementation: return new MemberOfExpression ( relativePath , value , true ) ;


signature:
public class ProjectionList { /** * @ see org . criteria4jpa . projection . Projection # toQueryString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toQueryString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation:
// check whether list is empty
if ( projectionList . isEmpty ( ) ) { throw new IllegalStateException ( "A projection list must have at least one child." ) ; } // query builder
StringBuilder builder = new StringBuilder ( ) ; // iterate over all projections from the list
Iterator < Projection > iter = projectionList . iterator ( ) ; while ( iter . hasNext ( ) ) { Projection projection = iter . next ( ) ; // call toQueryString ( ) on child
builder . append ( projection . toQueryString ( criteria , queryBuilder ) ) ; // append comma if more projections follow
if ( iter . hasNext ( ) ) { builder . append ( "," ) ; } } // return result
return builder . toString ( ) ;


signature:
public class ProjectionList { /** * @ see org . criteria4jpa . projection . Projection # toGroupByString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toGroupByString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation:
// query builder
StringBuilder builder = new StringBuilder ( ) ; // iterate over all projections from the list
Iterator < Projection > iter = projectionList . iterator ( ) ; while ( iter . hasNext ( ) ) { Projection projection = iter . next ( ) ; // call toGroupByString ( ) on child
String groupBy = projection . toGroupByString ( criteria , queryBuilder ) ; // add only if result is not null
if ( groupBy != null && groupBy . trim ( ) . length ( ) > 0 ) { // first add a comma if the builder already contains something
if ( builder . length ( ) > 0 ) { builder . append ( "," ) ; } // add group by expression of child
builder . append ( groupBy ) ; } } // return result if something has been written to the builder
String result = builder . toString ( ) . trim ( ) ; if ( result . length ( ) > 0 ) { return result ; } return null ;


signature:
public class CBMd5Sha { /** * Md5加密
 * @ param text
 * 输入
 * @ return md5 编码 */
public static String md5 ( String text ) { } }

implementation: if ( text == null ) { return null ; } if ( text . length ( ) == 0 ) { return "" ; } try { md1 . update ( text . getBytes ( "UTF8" ) ) ; return hex ( md1 . digest ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return null ;


signature:
public class CBMd5Sha { /** * sha加密 此处对text进行反向 , 对结果再次反向
 * @ param text
 * 输入字 串
 * @ return sha编 后 字 串 */
public static String sha ( String text ) { } }

implementation: if ( text == null ) { return null ; } if ( text . length ( ) == 0 ) { return "" ; } try { md2 . update ( text . getBytes ( "UTF8" ) ) ; return hex ( md2 . digest ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return null ;


signature:
public class CBMd5Sha { /** * 字节转换为16进制
 * @ param arr
 * 字节数组
 * @ return 16进制字 串 */
private static String hex ( byte [ ] arr ) { } }

implementation: StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < arr . length ; ++ i ) { sb . append ( Integer . toHexString ( ( arr [ i ] & 0xFF ) | 0x100 ) . substring ( 1 , 3 ) ) ; } return sb . toString ( ) ;


signature:
public class CBVersionUtil { /** * 本号比较 ( 例如1.10.0与1.2.0版本比较 ) , 返回是否有新版本
 * @ param oldVersion
 * 旧版本
 * @ param newVersion
 * 新版本
 * @ return 是否有新的版本存在 ( 是否新版本版本号大于老的版本号 ) */
public static boolean hasNewVersion ( String oldVersion , String newVersion ) { } }

implementation:
// 版本号有一个不正常就返回false
if ( CBStringUtil . isEmptyOrNull ( oldVersion ) || CBStringUtil . isEmptyOrNull ( newVersion ) ) { return false ; } boolean res = false ; String [ ] oldVersionSnippet = oldVersion . split ( "\\." ) ; String [ ] newVersionSnippet = newVersion . split ( "\\." ) ; int maxComparePosition = Math . min ( oldVersionSnippet . length , newVersionSnippet . length ) ; int i = 0 ; for ( ; i < maxComparePosition ; i ++ ) { int newNumber = Integer . parseInt ( newVersionSnippet [ i ] ) ; int oldNumber = Integer . parseInt ( oldVersionSnippet [ i ] ) ; if ( newNumber == oldNumber ) { continue ; } if ( newNumber > oldNumber ) { res = true ; break ; } if ( newNumber < oldNumber ) { res = false ; break ; } } // 前面的都相等 , 比较长度
if ( i == maxComparePosition ) { res = newVersionSnippet . length > oldVersionSnippet . length ; } return res ;


signature:
public class LoginPreferencePage { /** * Creates the field editors . Field editors are abstractions of
 * the common GUI blocks needed to manipulate various types
 * of preferences . Each field editor knows how to save and
 * restore itself . */
public void createFieldEditors ( ) { } }

implementation: addField ( new StringFieldEditor ( PreferenceConstants . CLIENT_ID , "Google API Client Id:" , getFieldEditorParent ( ) ) ) ; addField ( new StringFieldEditor ( PreferenceConstants . CLIENT_SECRET , "Google API Client Secret:" , getFieldEditorParent ( ) ) ) ;


signature:
public class PathProjection { /** * @ see org . criteria4jpa . projection . Projection # toQueryString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toQueryString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation: if ( absolute ) { return path ; } else { return queryBuilder . getAbsolutePath ( criteria , path ) ; }


signature:
public class PathProjection { /** * @ see org . criteria4jpa . projection . Projection # toGroupByString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toGroupByString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation: if ( grouped ) { if ( absolute ) { return path ; } else { return queryBuilder . getAbsolutePath ( criteria , path ) ; } } return null ;


signature:
public class MemberOfExpression { /** * @ see org . criteria4jpa . criterion . Criterion # toQueryString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toQueryString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; builder . append ( queryBuilder . createPositionalParameter ( ) ) ; if ( negate ) { builder . append ( " NOT" ) ; } builder . append ( " MEMBER OF " ) ; builder . append ( queryBuilder . getAbsolutePath ( criteria , relativePath ) ) ; return builder . toString ( ) ;


signature:
public class StringUtils { /** * Method to create unique aliases for JPA identifiers . Each alias
 * consists of two parts . The < i > basename < / i > should be a human
 * readable string that helps to identify which entity is referred .
 * The < i > counter < / i > is unique number that is added to the
 * alias to make the alias unique . It is recommended to use each
 * counter value one once independently from the basename used .
 * @ param basename a base name that will be used for alias creation
 * @ param counter A unique number
 * @ param fallback An optional fallback name
 * @ return the generated JPQL alias */
public static String generateAlias ( String basename , int counter , String fallback ) { } }

implementation:
// build trimmed and lower case version of the base name
String lowerCaseBaseName = basename . trim ( ) . toLowerCase ( Locale . ENGLISH ) ; // use only simple characters for the alias
StringBuilder builder = new StringBuilder ( ) ; for ( char c : lowerCaseBaseName . toCharArray ( ) ) { if ( c >= 'a' && c <= 'z' ) { builder . append ( c ) ; } } // add some default keyword , if builder is still empty
if ( builder . length ( ) == 0 ) { if ( fallback != null && fallback . length ( ) > 0 ) { builder . append ( fallback ) ; } else { builder . append ( "default" ) ; } } // finally append the counter to get uniqueness
builder . append ( counter ) ; // return the result
return builder . toString ( ) ;


signature:
public class StringUtils { /** * Returns the last component of a dot - separated path .
 * @ param path relative or absolute path expression
 * @ return last component of path expression */
public static String getLastPathComponent ( String path ) { } }

implementation:
// find last ' . ' character
int pos = path . lastIndexOf ( '.' ) ; // return the last path component
// or the complete path , if no ' . ' chars were found
return pos >= 0 ? path . substring ( pos + 1 ) : path ;


signature:
public class ConstructorProjection { /** * @ see org . criteria4jpa . projection . Projection # toQueryString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toQueryString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; builder . append ( "NEW " ) ; builder . append ( clazz . getName ( ) ) ; builder . append ( '(' ) ; builder . append ( projectionList . toQueryString ( criteria , queryBuilder ) ) ; builder . append ( ')' ) ; return builder . toString ( ) ;


signature:
public class ConstructorProjection { /** * @ see org . criteria4jpa . projection . Projection # toGroupByString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toGroupByString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation: return projectionList . toGroupByString ( criteria , queryBuilder ) ;


signature:
public class NewCardFileWizardPage { /** * This method is overridden to set the selected folder to web contents
 * folder if the current selection is outside the web contents folder . */
protected void initialPopulateContainerNameField ( ) { } }

implementation: super . initialPopulateContainerNameField ( ) ; IPath fullPath = getContainerFullPath ( ) ; IProject project = getProjectFromPath ( fullPath ) ; IPath root = ProjectUtils . getRootContainerForPath ( project , fullPath ) ; if ( root != null ) { return ; } root = ProjectUtils . getDefaultRootContainer ( project ) ; if ( root != null ) { setContainerFullPath ( root ) ; return ; }


signature:
public class NewCardFileWizardPage { /** * This method is overridden to set additional validation specific to html
 * files . */
protected boolean validatePage ( ) { } }

implementation:
setMessage ( null ) ; setErrorMessage ( null ) ; if ( ! super . validatePage ( ) ) { return false ; } String fileName = getFileName ( ) ; IPath fullPath = getContainerFullPath ( ) ; if ( ( fullPath != null ) && ( fullPath . isEmpty ( ) == false ) && ( fileName != null ) ) { // check that filename does not contain invalid extension
if ( ! extensionValidForContentType ( fileName ) ) { setErrorMessage ( "Filename must end with .card" ) ; return false ; } // no file extension specified so check adding default
// extension doesn ' t equal a file that already exists
if ( fileName . lastIndexOf ( '.' ) == - 1 ) { String newFileName = addDefaultExtension ( fileName ) ; IPath resourcePath = fullPath . append ( newFileName ) ; IWorkspace workspace = ResourcesPlugin . getWorkspace ( ) ; IStatus result = workspace . validatePath ( resourcePath . toString ( ) , IResource . FOLDER ) ; if ( ! result . isOK ( ) ) { // path invalid
setErrorMessage ( result . getMessage ( ) ) ; return false ; } if ( ( workspace . getRoot ( ) . getFolder ( resourcePath ) . exists ( ) || workspace . getRoot ( ) . getFile ( resourcePath ) . exists ( ) ) ) { setErrorMessage ( "There is a card with that name" ) ; return false ; } } // get the IProject for the selection path
IProject project = getProjectFromPath ( fullPath ) ; // if inside web project , check if inside webContent folder
if ( project != null && isWebProject ( project ) ) { // check that the path is inside the webContent folder
IPath [ ] webContentPaths = ProjectUtils . getAcceptableRootPaths ( project ) ; boolean isPrefix = false ; for ( int i = 0 ; ! isPrefix && i < webContentPaths . length ; i ++ ) { isPrefix |= webContentPaths [ i ] . isPrefixOf ( fullPath ) ; } if ( ! isPrefix ) { setMessage ( "Cards must be inside the web contents" , WARNING ) ; } } } return true ;


signature:
public class NewCardFileWizardPage { /** * Verifies if fileName is valid name for content type . Takes base content
 * type into consideration .
 * @ param fileName
 * @ return true if extension is valid for this content type */
private boolean extensionValidForContentType ( String fileName ) { } }

implementation:
boolean valid = false ; IContentType type = getContentType ( ) ; // there is currently an extension
if ( fileName . lastIndexOf ( '.' ) != - 1 ) { // check what content types are associated with current extension
IContentType [ ] types = Platform . getContentTypeManager ( ) . findContentTypesFor ( fileName ) ; int i = 0 ; while ( i < types . length && ! valid ) { valid = types [ i ] . isKindOf ( type ) ; ++ i ; } } else valid = true ; // no extension so valid
return valid ;


signature:
public class NewCardFileWizardPage { /** * Adds default extension to the filename
 * @ param filename
 * @ return */
String addDefaultExtension ( String filename ) { } }

implementation:
StringBuffer newFileName = new StringBuffer ( filename ) ; String ext = "card" ; newFileName . append ( "." ) ; // $ NON - NLS - 1 $
newFileName . append ( ext ) ; return newFileName . toString ( ) ;


signature:
public class NewCardFileWizardPage { /** * Returns the project that contains the specified path
 * @ param path
 * the path which project is needed
 * @ return IProject object . If path is < code > null < / code > the return value is
 * also < code > null < / code > . */
private IProject getProjectFromPath ( IPath path ) { } }

implementation: IWorkspace workspace = ResourcesPlugin . getWorkspace ( ) ; IProject project = null ; if ( path != null ) { if ( workspace . validatePath ( path . toString ( ) , IResource . PROJECT ) . isOK ( ) ) { project = workspace . getRoot ( ) . getProject ( path . toString ( ) ) ; } else { project = workspace . getRoot ( ) . getFile ( path ) . getProject ( ) ; } } return project ;


signature:
public class CriteriaUtils { /** * Creates a new { @ link Criteria } query for a entity class .
 * Please note that the entity name is deduced from the unqualified class name .
 * You should use { @ link # createCriteria ( EntityManager , String ) }
 * if you have changed the entity name by using the < code > name < / code > attribute
 * of the { @ link Entity } annotation .
 * @ param entityManager { @ link EntityManager } for query creation
 * @ param persistentClass persistent class
 * @ return new { @ link Criteria } query */
public static Criteria createCriteria ( EntityManager entityManager , Class < ? > persistentClass ) { } }

implementation: errorIfClosed ( entityManager ) ; return new CriteriaImpl ( entityManager , persistentClass . getSimpleName ( ) ) ;


signature:
public class CriteriaUtils { /** * Creates a new { @ link Criteria } query for a entity class . Sets the
 * specified alias for the root entity . You may later use this alias to
 * refer to the entity in { @ link Criterion } , { @ link Projection } and
 * { @ link Order } instances .
 * Please note that the entity name is deduced from the unqualified class name .
 * You should use { @ link # createCriteria ( EntityManager , Class , String ) }
 * if you have changed the entity name by using the < code > name < / code > attribute
 * of the { @ link Entity } annotation .
 * @ param entityManager { @ link EntityManager } for query creation
 * @ param persistentClass persistent class
 * @ param alias alias to set for the criteria
 * @ return new { @ link Criteria } query */
public static Criteria createCriteria ( EntityManager entityManager , Class < ? > persistentClass , String alias ) { } }

implementation: return new CriteriaImpl ( entityManager , persistentClass . getSimpleName ( ) , alias ) ;


signature:
public class CriteriaUtils { /** * Creates a new { @ link Criteria } query for a named entity . Sets the
 * specified alias for the root entity . You may later use this alias to
 * refer to the entity in { @ link Criterion } , { @ link Projection } and
 * { @ link Order } instances .
 * @ param entityManager { @ link EntityManager } for query creation
 * @ param entityName name of the entity
 * @ return new { @ link Criteria } query */
public static Criteria createCriteria ( EntityManager entityManager , String entityName , String alias ) { } }

implementation: errorIfClosed ( entityManager ) ; return new CriteriaImpl ( entityManager , entityName , alias ) ;


signature:
public class Junction { /** * @ see org . criteria4jpa . criterion . Criterion # toQueryString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toQueryString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation:
// fallback for empty criteria list
if ( criterionList . isEmpty ( ) ) { return "1=1" ; } // build junction
StringBuilder builder = new StringBuilder ( ) ; builder . append ( "(" ) ; Iterator < Criterion > critIter = criterionList . iterator ( ) ; while ( critIter . hasNext ( ) ) { // add JPQL string
builder . append ( critIter . next ( ) . toQueryString ( criteria , queryBuilder ) ) ; // add op if more entries follow
if ( critIter . hasNext ( ) ) { builder . append ( ' ' ) . append ( op ) . append ( ' ' ) ; } } builder . append ( ")" ) ; return builder . toString ( ) ;


signature:
public class Junction { /** * @ see org . criteria4jpa . criterion . Criterion # getParameterValues ( ) */
public Object [ ] getParameterValues ( ) { } }

implementation:
ArrayList < Object > values = new ArrayList < Object > ( ) ; // process all criteria from criterionList
for ( Criterion criterion : criterionList ) { // add all values from this criterion to result list
for ( Object value : criterion . getParameterValues ( ) ) { values . add ( value ) ; } } return values . toArray ( ) ;


signature:
public class OAuth2Util { /** * Creates and returns a new { @ link AuthorizationCodeFlow } for this app . */
public AuthorizationCodeFlow newAuthorizationCodeFlow ( ) throws IOException { } }

implementation: return new GoogleAuthorizationCodeFlow . Builder ( new NetHttpTransport ( ) , new JacksonFactory ( ) , clientId , clientSecret , Collections . singleton ( scope ) ) . setAccessType ( accessType ) . setCredentialDataStore ( getInMemoryDatastore ( ) ) . build ( ) ;


signature:
public class OAuth2Util { /** * Get the current user ' s ID from the session
 * @ return string user id or null if no one is logged in */
public String getUserId ( HttpServletRequest request ) { } }

implementation: HttpSession session = request . getSession ( ) ; return ( String ) session . getAttribute ( "userId" ) ;


signature:
public class CardEditor { /** * Creates Structured Twext Editot of the multi - page editor , which contains an HTML editor . */
void createPage0 ( ) { } }

implementation: try { textEditor = new StructuredTextEditor ( ) ; int index = addPage ( textEditor , getEditorInput ( ) ) ; setPageText ( index , "Source" ) ; setPartName ( textEditor . getTitle ( ) ) ; } catch ( PartInitException e ) { ErrorDialog . openError ( getSite ( ) . getShell ( ) , "Error creating nested text editor" , null , e . getStatus ( ) ) ; }


signature:
public class CardEditor { /** * Creates page 1 of the multi - page editor , which is used to preview the page . */
void createPage1 ( ) { } }

implementation: Composite composite = new Composite ( getContainer ( ) , SWT . NONE ) ; RowLayout layout = new RowLayout ( ) ; layout . wrap = false ; layout . pack = true ; layout . justify = true ; layout . type = SWT . VERTICAL ; layout . marginLeft = 5 ; layout . marginTop = 5 ; layout . marginRight = 5 ; layout . marginBottom = 5 ; layout . spacing = 0 ; composite . setLayout ( layout ) ; browser = new Browser ( composite , SWT . NONE ) ; browser . setLayoutData ( new RowData ( 640 , 360 ) ) ; Button previewOnGlass = new Button ( composite , SWT . NONE ) ; previewOnGlass . setText ( "#throughglass" ) ; previewOnGlass . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent event ) { if ( ! setClientprovider ( ) ) { GoogleLogin . promptToLogIn ( "Glassmaker" ) ; } if ( GoogleLogin . getInstance ( ) . isLoggedIn ( ) ) previewOnGlass ( ) ; } } ) ; int index = addPage ( composite ) ; setPageText ( index , "Preview" ) ;


signature:
public class CardEditor { /** * Saves the multi - page editor ' s document as another file . Also updates the
 * text for page 0 ' s tab , and updates this multi - page editor ' s input to
 * correspond to the nested editor ' s . */
public void doSaveAs ( ) { } }

implementation: IEditorPart editor = getEditor ( 0 ) ; editor . doSaveAs ( ) ; setPageText ( 0 , editor . getTitle ( ) ) ; setInput ( editor . getEditorInput ( ) ) ;


signature:
public class CardEditor { /** * The < code > MultiPageEditorExample < / code > implementation of this method
 * checks that the input is an instance of < code > IFileEditorInput < / code > . */
public void init ( IEditorSite site , IEditorInput editorInput ) throws PartInitException { } }

implementation: if ( ! ( editorInput instanceof IFileEditorInput ) ) throw new PartInitException ( "Invalid Input: Must be IFileEditorInput" ) ; super . init ( site , editorInput ) ;


signature:
public class CardEditor { /** * Closes all project files on project close . */
public void resourceChanged ( final IResourceChangeEvent event ) { } }

implementation: if ( event . getType ( ) == IResourceChangeEvent . PRE_CLOSE ) { Display . getDefault ( ) . asyncExec ( new Runnable ( ) { public void run ( ) { IWorkbenchPage [ ] pages = getSite ( ) . getWorkbenchWindow ( ) . getPages ( ) ; for ( int i = 0 ; i < pages . length ; i ++ ) { if ( ( ( FileEditorInput ) textEditor . getEditorInput ( ) ) . getFile ( ) . getProject ( ) . equals ( event . getResource ( ) ) ) { IEditorPart editorPart = pages [ i ] . findEditor ( textEditor . getEditorInput ( ) ) ; pages [ i ] . closeEditor ( editorPart , true ) ; } } } } ) ; }


signature:
public class CardEditor { /** * Sorts the words in page 0 , and shows them in page 2. */
void showPage ( ) { } }

implementation:
String editorText = getDocumentProvider ( ) . getDocument ( textEditor . getEditorInput ( ) ) . get ( ) ; deletePreviewFiles ( ) ; File file = toPreviewFile ( editorText ) ; if ( file != null ) { PREVIEW_FILES_LIST . add ( file ) ; String s = "file://" + file . getAbsolutePath ( ) ; // $ NON - NLS - 1 $
browser . setJavascriptEnabled ( true ) ; browser . setUrl ( s ) ; } else { browser . setText ( editorText , true ) ; }


signature:
public class QueryLogHelper { /** * Method to create a human readable log message regarding a generated query .
 * @ param query the JPQL query string
 * @ param parameterValues the parameter values of the query
 * @ return log string */
public static String createQueryLogMessage ( String query , List < Object > parameterValues ) { } }

implementation:
// builder for log message
StringBuilder builder = new StringBuilder ( ) ; // log the JPQL query string
builder . append ( "Query: \"" ) ; builder . append ( query ) ; builder . append ( "\"" ) ; // append parameter value list
if ( parameterValues != null && parameterValues . size ( ) > 0 ) { builder . append ( ", parameters: { " ) ; // parameter value iterator
Iterator < Object > parameterIterator = parameterValues . iterator ( ) ; // iterate over all parameter values
while ( parameterIterator . hasNext ( ) ) { // use private helper to create string representation
builder . append ( objectToString ( parameterIterator . next ( ) ) ) ; // append comma if more values follow
if ( parameterIterator . hasNext ( ) ) { builder . append ( ", " ) ; } } // closing bracket
builder . append ( " }" ) ; } // return result
return builder . toString ( ) ;


signature:
public class QueryLogHelper { /** * Helper method to create a string representation of an object .
 * @ param obj the object to print
 * @ return a string representation of the object */
private static String objectToString ( Object obj ) { } }

implementation:
// handle ' null '
if ( obj == null ) { return "null" ; } // enclose Strings in quotes
if ( obj instanceof CharSequence ) { return "\"" + obj . toString ( ) + "\"" ; } // use toString ( ) for all other objects
return obj . toString ( ) ;


signature:
public class MirrorTemplate { /** * Inserts a simple timeline item .
 * @ param getCredential
 * ( credential ) the user ' s credential
 * @ param item
 * the item to insert */
public TimelineItem insertTimelineItem ( TimelineItem item ) throws IOException { } }

implementation: return getMirror ( ) . timeline ( ) . insert ( item ) . execute ( ) ;


signature:
public class MirrorTemplate { /** * Inserts an item with an attachment provided as a byte array .
 * @ param item
 * the item to insert
 * @ param attachmentContentType
 * the MIME type of the attachment ( or null if none )
 * @ param attachmentData
 * data for the attachment ( or null if none ) */
public void insertTimelineItem ( TimelineItem item , String attachmentContentType , byte [ ] attachmentData ) throws IOException { } }

implementation: Mirror . Timeline timeline = getMirror ( ) . timeline ( ) ; timeline . insert ( item , new ByteArrayContent ( attachmentContentType , attachmentData ) ) . execute ( ) ;


signature:
public class MirrorTemplate { /** * Inserts an item with an attachment provided as an input stream .
 * @ param item
 * the item to insert
 * @ param attachmentContentType
 * the MIME type of the attachment ( or null if none )
 * @ param attachmentInputStream
 * input stream for the attachment ( or null if none ) */
public void insertTimelineItem ( TimelineItem item , String attachmentContentType , InputStream attachmentInputStream ) throws IOException { } }

implementation: insertTimelineItem ( item , attachmentContentType , ByteStreams . toByteArray ( attachmentInputStream ) ) ;


signature:
public class DefaultIronCacheProvider { /** * Configures the ObjectMapper . Currently adds { @ link AfterburnerModule } for
 * more speed and Joda date / time serializer / deserializers .
 * @ param json
 * is the { @ link ObjectMapper } to augment */
protected static ObjectMapper configure ( final ObjectMapper json ) { } }

implementation:
final SimpleModule jodaModule = new SimpleModule ( "Joda" ) ; jodaModule . addSerializer ( new JodaDateTimeSerializer ( ) ) ; jodaModule . addDeserializer ( DateTime . class , new JodaDateTimeDeserializer ( ) ) ; json . registerModule ( jodaModule ) ; // Increase performance even more
json . registerModule ( new AfterburnerModule ( ) ) ; return json ;


signature:
public class DefaultIronCacheProvider { /** * ( non - Javadoc )
 * @ see
 * com . github . mrcritical . ironcache . SimpleIronCache # clearCache ( java . lang .
 * String ) */
@ Override public void clearCache ( final String name ) { } }

implementation:
try { final CacheResponse response = objectMapper . readValue ( requestFactory . buildPostRequest ( new ClearCacheUrl ( hostName , projectId , name ) , new EmptyContent ( ) ) . execute ( ) . getContent ( ) , CacheResponse . class ) ; validate ( response , "cleared" ) ; log . debug ( "Successful request to clear to cache {}" , name ) ; } catch ( final HTTPException e ) { if ( e . getStatusCode ( ) == 301 ) { // Swallow this since that is what happens when cleared ( it
// isn ' t documented in the API spec )
return ; } throw Throwables . propagate ( e ) ; } catch ( final Exception e ) { throw Throwables . propagate ( e ) ; }


signature:
public class DefaultIronCacheProvider { /** * ( non - Javadoc )
 * @ see
 * com . github . mrcritical . ironcache . SimpleIronCache # deleteCache ( java . lang
 * . String ) */
@ Override public void deleteCache ( final String name ) { } }

implementation: try { final CacheResponse response = objectMapper . readValue ( requestFactory . buildDeleteRequest ( new CacheUrl ( hostName , projectId , name ) ) . execute ( ) . getContent ( ) , CacheResponse . class ) ; validate ( response , "deleted" ) ; } catch ( final Exception e ) { throw Throwables . propagate ( e ) ; }


signature:
public class DefaultIronCacheProvider { /** * ( non - Javadoc )
 * @ see
 * com . github . mrcritical . ironcache . SimpleIronCache # deleteItem ( java . lang .
 * String , java . lang . String ) */
@ Override public void deleteItem ( final String name , final String key ) { } }

implementation: try { final CacheResponse response = objectMapper . readValue ( requestFactory . buildDeleteRequest ( new CacheItemUrl ( hostName , projectId , name , key ) ) . execute ( ) . getContent ( ) , CacheResponse . class ) ; validate ( response , "deleted" ) ; } catch ( final Exception e ) { throw Throwables . propagate ( e ) ; }


signature:
public class DefaultIronCacheProvider { /** * ( non - Javadoc )
 * @ see
 * com . github . mrcritical . ironcache . SimpleIronCache # getCache ( java . lang . String */
@ Override public Optional < Cache > getCache ( final String name ) { } }

implementation: try { return Optional . fromNullable ( objectMapper . readValue ( requestFactory . buildGetRequest ( new CacheUrl ( hostName , projectId , name ) ) . execute ( ) . getContent ( ) , Cache . class ) ) ; } catch ( final HTTPException e ) { if ( e . getStatusCode ( ) == 404 ) { return Optional . absent ( ) ; } throw Throwables . propagate ( e ) ; } catch ( final Exception e ) { throw Throwables . propagate ( e ) ; }


signature:
public class DefaultIronCacheProvider { /** * ( non - Javadoc )
 * @ see
 * com . github . mrcritical . ironcache . SimpleIronCache # getItem ( java . lang . String ,
 * java . lang . String ) */
@ Override public Optional < CachedItem > getItem ( final String name , final String key ) { } }

implementation: try { return Optional . fromNullable ( objectMapper . readValue ( requestFactory . buildGetRequest ( new CacheItemUrl ( hostName , projectId , name , key ) ) . execute ( ) . getContent ( ) , CachedItem . class ) ) ; } catch ( final HTTPException e ) { if ( e . getStatusCode ( ) == 404 ) { return Optional . absent ( ) ; } throw Throwables . propagate ( e ) ; } catch ( final Exception e ) { throw Throwables . propagate ( e ) ; }


signature:
public class DefaultIronCacheProvider { /** * ( non - Javadoc )
 * @ see
 * com . github . mrcritical . ironcache . SimpleIronCache # incrementItem ( java . lang
 * . String , java . lang . String , int ) */
@ Override public void incrementItem ( final String name , final String key , final int amount ) { } }

implementation:
try { final IncrementCacheResponse response = objectMapper . readValue ( requestFactory . buildPostRequest ( new IncrementCacheItemUrl ( hostName , projectId , name , key ) , new JsonHttpContent ( JSON_FACTORY , new Increment ( ) . amount ( amount ) ) ) . execute ( ) . getContent ( ) , IncrementCacheResponse . class ) ; // Validate an increment , presence of a value is validation
if ( null == response . getValue ( ) ) { String message = MoreObjects . firstNonNull ( response . getMessage ( ) , "Increment value returned NULL" ) ; throw new IllegalArgumentException ( message ) ; } } catch ( final Exception e ) { throw Throwables . propagate ( e ) ; }


signature:
public class DefaultIronCacheProvider { /** * ( non - Javadoc )
 * @ see com . github . mrcritical . ironcache . SimpleIronCache # listCaches ( ) */
@ Override public List < Cache > listCaches ( ) { } }

implementation: try { return objectMapper . readValue ( requestFactory . buildGetRequest ( new CachesUrl ( hostName , projectId ) ) . execute ( ) . getContent ( ) , new TypeReference < List < Cache > > ( ) { } ) ; } catch ( final Exception e ) { throw Throwables . propagate ( e ) ; }


signature:
public class DefaultIronCacheProvider { /** * ( non - Javadoc )
 * @ see
 * com . github . mrcritical . ironcache . SimpleIronCache # putItem ( java . lang . String ,
 * com . github . mrcritical . ironcache . model . CacheItemRequest ) */
@ Override public void putItem ( final String name , final CacheItemRequest request ) { } }

implementation:
try { validate ( request ) ; final CacheRequest item = new CacheRequest ( ) . value ( request . getValue ( ) ) . cas ( request . getCas ( ) ) . expires ( request . getExpireAfter ( ) ) ; // . replace ( request . getOnlyIfExists ( ) )
// . add ( request . getOnlyIfNotExists ( ) ) ;
final CacheResponse response = objectMapper . readValue ( requestFactory . buildPutRequest ( new CacheItemUrl ( hostName , projectId , name , request . getKey ( ) ) , new JsonHttpContent ( JSON_FACTORY , item ) ) . execute ( ) . getContent ( ) , CacheResponse . class ) ; validate ( response , "stored" ) ; log . debug ( "Successful request to add item {} with value {} to the cache {}" , request . getKey ( ) , request . getValue ( ) , name ) ; } catch ( final Exception e ) { throw Throwables . propagate ( e ) ; }


signature:
public class DefaultIronCacheProvider { /** * Validates that the request being made is going to end up in a valid
 * request when processed on the server . This includes :
 * < ul >
 * < li > Verifying that a key was provided that is not blank < / li >
 * < li > Verifying that a NON - NULL value was provided < / li >
 * < li > That { @ link CacheItemRequest # getOnlyIfExists ( ) } and
 * { @ link CacheItemRequest # getOnlyIfNotExists ( ) } are not both set ( that
 * negate each other ) < / li >
 * < li > Verifying that any expiration provided is greater then 0 < / li >
 * < / ul >
 * @ param request
 * is the request to validate */
private void validate ( final CacheItemRequest request ) { } }

implementation: Preconditions . checkArgument ( ! Strings . isNullOrEmpty ( request . getKey ( ) ) , "A valid key must be supplied" ) ; Preconditions . checkArgument ( null != request . getValue ( ) , "A valid value must be supplied, it maybe an empty string" ) ; Preconditions . checkArgument ( ! ( null != request . getOnlyIfExists ( ) && null != request . getOnlyIfNotExists ( ) ) , "Cannot specify both Only If Exists and Only If Not Exists. The two conditions negate each other." ) ; Preconditions . checkArgument ( null == request . getExpireAfter ( ) || null != request . getExpireAfter ( ) && request . getExpireAfter ( ) > 0 , "An expiration value must be greater then 0" ) ;


signature:
public class DefaultIronCacheProvider { /** * Validates that the keyword expected was returned . Otherwise throws an
 * exception with the message returned included .
 * @ param response
 * is the response to check
 * @ param keyword
 * is the keyword to expected */
private void validate ( final CacheResponse response , final String keyword ) { } }

implementation: if ( ! response . getMessage ( ) . toLowerCase ( Locale . US ) . startsWith ( keyword ) ) { throw new IllegalArgumentException ( response . getMessage ( ) ) ; }


signature:
public class Order { /** * Renders the order to a ORDER BY substring of JPQL query
 * @ param criteria The { @ link Criteria } the order is associated with
 * @ param queryBuilder The builder of the JPQL query
 * @ return the generated query string */
public String toQueryString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation: String absolutePath = queryBuilder . getAbsolutePath ( criteria , relativePath ) ; return ascending ? absolutePath : absolutePath + " DESC" ;


signature:
public class GlassmakerUIPlugin { /** * Returns the template store for the html editor templates .
 * @ return the template store for the html editor templates */
public TemplateStore getTemplateStore ( ) { } }

implementation: if ( fTemplateStore == null ) { fTemplateStore = new ContributionTemplateStore ( getTemplateContextRegistry ( ) , getPreferenceStore ( ) , "org.eclipse.wst.sse.ui.custom_templates" ) ; try { fTemplateStore . load ( ) ; } catch ( IOException e ) { logError ( "" , e ) ; } } return fTemplateStore ;


signature:
public class GlassmakerUIPlugin { /** * Returns the template context type registry for the html plugin .
 * @ return the template context type registry for the html plugin */
public ContextTypeRegistry getTemplateContextRegistry ( ) { } }

implementation: if ( fContextTypeRegistry == null ) { ContributionContextTypeRegistry registry = new ContributionContextTypeRegistry ( ) ; registry . addContextType ( CardContextType . CONTEXT_TYPE ) ; fContextTypeRegistry = registry ; } return fContextTypeRegistry ;


signature:
public class InExpression { /** * @ see org . criteria4jpa . criterion . Criterion # toQueryString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toQueryString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation:
// query builder
StringBuilder builder = new StringBuilder ( ) ; // build the basic query
builder . append ( queryBuilder . getAbsolutePath ( criteria , relativePath ) ) ; builder . append ( " IN (" ) ; // We must add each value as a parameter , because not all JPA
// implementations allow lists or arrays as parameters .
if ( values != null ) { for ( int i = 0 ; i < values . length ; i ++ ) { builder . append ( queryBuilder . createPositionalParameter ( ) ) ; if ( i < values . length - 1 ) { builder . append ( ',' ) ; } } } builder . append ( ")" ) ; // return result
return builder . toString ( ) ;


signature:
public class JPQLExpression { /** * @ see org . criteria4jpa . criterion . Criterion # toQueryString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toQueryString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation:
// replace alias variable by real name
String queryFragment = jpql . replace ( "{alias}" , queryBuilder . getRequiredAlias ( criteria ) ) ; // process parameters
for ( int i = 1 ; i <= values . length ; i ++ ) { // create positional parameter for this value
String paramater = queryBuilder . createPositionalParameter ( ) ; /* * Replace variable with generated positional parameter .
 * Note : This kind of string processing is not very efficient ,
 * because it generates a new string object in each iteration .
 * But we assume that the number of iterations will be
 * relative small , so it won ' t be a real problem . */
queryFragment = queryFragment . replace ( "{" + i + "}" , paramater ) ; } return queryFragment ;


signature:
public class CBMapSortUtil { /** * 按照Map中key进行升序排列
 * @ param sourceMap
 * 要排序 map
 * @ return 排序后 map */
public Map < K , V > getMapSortByValueUp ( Map < K , V > sourceMap ) { } }

implementation: return sortByValue ( sourceMap , GROW_UP ) ;


signature:
public class CBMapSortUtil { /** * 按照Map中key进行降序排列
 * @ param sourceMap
 * 要排序 map
 * @ return 排序后 map */
public Map < K , V > getMapSortByValueDown ( Map < K , V > sourceMap ) { } }

implementation: return sortByValue ( sourceMap , GROW_DOWN ) ;


signature:
public class CBMapSortUtil { /** * 按照Map中value进行升序排列
 * @ param sourceMap
 * 要排序 map
 * @ return 排序后 map */
public Map < K , V > getMapSortByKeyUp ( Map < K , V > sourceMap ) { } }

implementation: return sortByKey ( sourceMap , GROW_UP ) ;


signature:
public class CBMapSortUtil { /** * 按照Map中value进行降序排列
 * @ param sourceMap
 * 要排序 map
 * @ return 排序后 map */
public Map < K , V > getMapSortByKeyDown ( Map < K , V > sourceMap ) { } }

implementation: return sortByKey ( sourceMap , GROW_DOWN ) ;


signature:
public class CBMapSortUtil { /** * 根据map中key进行排序
 * @ param sourceMap
 * 要排序 map
 * @ param growthPattern
 * 排序规则 , 升序或者降序
 * @ return 排序后 map */
private Map < K , V > sortByKey ( Map < K , V > sourceMap , final int growthPattern ) { } }

implementation: List < Entry < K , V > > list = new ArrayList < Entry < K , V > > ( sourceMap . entrySet ( ) ) ; Collections . sort ( list , new Comparator < Entry < K , V > > ( ) { @ Override public int compare ( Entry < K , V > o1 , Entry < K , V > o2 ) { K k1 = o1 . getKey ( ) ; K k2 = o2 . getKey ( ) ; return compareValue ( k1 , k2 ) * growthPattern ; } } ) ; Map < K , V > desMap = new LinkedHashMap < K , V > ( ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { Entry < K , V > item = list . get ( i ) ; desMap . put ( item . getKey ( ) , item . getValue ( ) ) ; } return desMap ;


signature:
public class CBMapSortUtil { /** * 对键值对中值进行比较 , 只针对6种基本类型 , short int long float double char ,
 * 其他一律返回相等
 * @ param v1
 * 值1
 * @ param v2
 * 值2
 * @ return 比较结果 */
private int compareValue ( Object v1 , Object v2 ) { } }

implementation: if ( v1 instanceof Integer ) return Integer . compare ( ( Integer ) v1 , ( Integer ) v2 ) ; if ( v1 instanceof Float ) return Float . compare ( ( Float ) v1 , ( Float ) v2 ) ; if ( v1 instanceof Double ) return Double . compare ( ( Double ) v1 , ( Double ) v2 ) ; if ( v1 instanceof Long ) return Long . compare ( ( Long ) v1 , ( Long ) v2 ) ; if ( v1 instanceof Character ) return Character . compare ( ( Character ) v1 , ( Character ) v2 ) ; if ( v1 instanceof Short ) return Short . compare ( ( Short ) v1 , ( Short ) v2 ) ; return 0 ;


signature:
public class ApacheHttpRequest { /** * ( non - Javadoc )
 * @ see com . google . api . client . http . LowLevelHttpRequest # setTimeout ( int , int ) */
@ Override public void setTimeout ( int connectTimeout , int readTimeout ) throws IOException { } }

implementation: request . setConfig ( RequestConfig . custom ( ) . setSocketTimeout ( readTimeout ) . setConnectTimeout ( connectTimeout ) . build ( ) ) ;


signature:
public class CardEditorContributor { /** * Returns the action registed with the given text editor .
 * @ return IAction or null if editor is null . */
protected IAction getAction ( ITextEditor editor , String actionID ) { } }

implementation: return ( editor == null ? null : editor . getAction ( actionID ) ) ;


signature:
public class CardEditorContributor { /** * / * ( non - JavaDoc )
 * Method declared in AbstractMultiPageEditorActionBarContributor . */
public void setActivePage ( IEditorPart part ) { } }

implementation: if ( activeEditorPart == part ) return ; activeEditorPart = part ; IActionBars actionBars = getActionBars ( ) ; if ( actionBars != null ) { ITextEditor editor = ( part instanceof ITextEditor ) ? ( ITextEditor ) part : null ; actionBars . setGlobalActionHandler ( ActionFactory . DELETE . getId ( ) , getAction ( editor , ITextEditorActionConstants . DELETE ) ) ; actionBars . setGlobalActionHandler ( ActionFactory . UNDO . getId ( ) , getAction ( editor , ITextEditorActionConstants . UNDO ) ) ; actionBars . setGlobalActionHandler ( ActionFactory . REDO . getId ( ) , getAction ( editor , ITextEditorActionConstants . REDO ) ) ; actionBars . setGlobalActionHandler ( ActionFactory . CUT . getId ( ) , getAction ( editor , ITextEditorActionConstants . CUT ) ) ; actionBars . setGlobalActionHandler ( ActionFactory . COPY . getId ( ) , getAction ( editor , ITextEditorActionConstants . COPY ) ) ; actionBars . setGlobalActionHandler ( ActionFactory . PASTE . getId ( ) , getAction ( editor , ITextEditorActionConstants . PASTE ) ) ; actionBars . setGlobalActionHandler ( ActionFactory . SELECT_ALL . getId ( ) , getAction ( editor , ITextEditorActionConstants . SELECT_ALL ) ) ; actionBars . setGlobalActionHandler ( ActionFactory . FIND . getId ( ) , getAction ( editor , ITextEditorActionConstants . FIND ) ) ; actionBars . setGlobalActionHandler ( IDEActionFactory . BOOKMARK . getId ( ) , getAction ( editor , IDEActionFactory . BOOKMARK . getId ( ) ) ) ; actionBars . updateActionBars ( ) ; }


signature:
public class JodaDateTimeDeserializer { /** * ( non - Javadoc )
 * @ see org . codehaus . jackson . map . JsonDeserializer # deserialize ( org . codehaus
 * . jackson . JsonParser , org . codehaus . jackson . map . DeserializationContext ) */
@ Override public DateTime deserialize ( final JsonParser parser , final DeserializationContext context ) throws IOException , JsonProcessingException { } }

implementation: return formatter . parseDateTime ( parser . getText ( ) ) ;


signature:
public class RootEntityProjection { /** * @ see org . criteria4jpa . projection . Projection # toQueryString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toQueryString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation: return queryBuilder . getRequiredAlias ( queryBuilder . getRootCriteria ( ) ) ;


signature:
public class CBTimeWait { /** * 等待
 * @ param millis millis
 * @ param nanos nanos */
public static void waitTime ( long millis , int nanos ) { } }

implementation: try { Thread . sleep ( millis , nanos ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; }


signature:
public class CBParam { /** * convert parameters to string
 * @ param charset
 * 编码
 * @ param params
 * parameter
 * @ return 拼接后的字符串 */
public static String paramsToString ( String charset , String ... params ) { } }

implementation: StringBuffer sb = new StringBuffer ( ) ; try { for ( int i = 0 ; i < params . length - 1 ; i = i + 1 ) { sb . append ( "&" ) ; sb . append ( URLEncoder . encode ( params [ i ] , charset ) ) ; sb . append ( "=" ) ; sb . append ( URLEncoder . encode ( params [ i + 1 ] , charset ) ) ; } } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } return sb . substring ( 1 ) ;


signature:
public class CBParam { /** * convert parameters to string
 * @ param charset
 * 编码
 * @ param params
 * parameter
 * @ return 拼接后的字符串 */
public static String paramsToString ( String charset , Map < String , String > params ) { } }

implementation: StringBuffer sb = new StringBuffer ( ) ; try { for ( Map . Entry < String , String > item : params . entrySet ( ) ) { sb . append ( "&" ) ; sb . append ( URLEncoder . encode ( item . getKey ( ) , charset ) ) ; sb . append ( "=" ) ; sb . append ( URLEncoder . encode ( item . getValue ( ) , charset ) ) ; } } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } return sb . substring ( 1 ) ;


signature:
public class IsNullExpression { /** * @ see org . criteria4jpa . criterion . Criterion # toQueryString ( org . criteria4jpa . Criteria , org . criteria4jpa . impl . CriteriaQueryBuilder ) */
public String toQueryString ( Criteria criteria , CriteriaQueryBuilder queryBuilder ) { } }

implementation: String path = queryBuilder . getAbsolutePath ( criteria , propertyName ) ; if ( ! negate ) { return path + " IS NULL" ; } else { return path + " IS NOT NULL" ; }


signature:
public class CBTimer { /** * 记录当前时间 */
public synchronized void push ( ) { } }

implementation: times . put ( String . format ( Locale . CHINA , TIME_KEY , ++ count ) , System . currentTimeMillis ( ) ) ;


signature:
public class CBTimer { /** * 将指定时间与key进行关联
 * < p > key值不要以CB _ TIMER开头 , CB _ TIMER为系统内置计时key , 以CB _ TIMER开头的key将自动被过滤掉 < / p >
 * @ param key key
 * @ param time 时间 */
public void push ( String key , long time ) { } }

implementation: if ( key . startsWith ( "CB_TIMER" ) ) { return ; } times . put ( key , time ) ;


signature:
public class CBTimer { /** * 获取最后一个push到当前的时间间隔 , 如果pop已经弹出了所有的key , 返回 - 1
 * 与 { @ link CBTimer # push ( ) } 对应
 * @ return 时间间隔 */
public long pop ( ) { } }

implementation: if ( count < 0 ) { return - 1 ; } String key = String . format ( Locale . CHINA , TIME_KEY , count ) ; count -- ; return pop ( key ) ;


signature:
public class CBTimer { /** * 获取最后一个push key到指定时间之间的时间间隔
 * 与 { @ link CBTimer # push ( String ) } 对应
 * @ param key key
 * @ param time 时间
 * @ return 时间间隔 */
public long pop ( String key , long time ) { } }

implementation: if ( ! times . containsKey ( key ) ) { return - 1L ; } long recordTime = times . get ( key ) ; times . remove ( key ) ; return time - recordTime ;


signature:
public class CBTimer { /** * 获取最后一次push的时间 ( pop操作会抵消一次push操作 ) , 如果没有对应的push , 返回null
 * @ return 时间 , 单位毫秒 */
public Long get ( ) { } }

implementation: return times . get ( String . format ( Locale . CHINA , TIME_KEY , count ) ) ;


signature:
public class CBFileUtil { /** * 按照指定编码得到文件内容
 * @ param filePath 源文件路径
 * @ param encoding 文件编
 * @ return 文件内容
 * @ throws IOException io exception */
public static String getFileContent ( String filePath , String encoding ) throws IOException { } }

implementation: BufferedReader buff = new BufferedReader ( new InputStreamReader ( new FileInputStream ( filePath ) , encoding ) ) ; String content = getContent ( buff ) ; buff . close ( ) ; return content ;


signature:
public class CBFileUtil { /** * 按照指定编码得到文件内容 , 保存list中
 * @ param filePath 源文件路径
 * @ param encoding 文件编
 * @ return 文件内容
 * @ throws IOException io exception */
public static List < String > getFileContentAsList ( String filePath , String encoding ) throws IOException { } }

implementation: return Arrays . asList ( getFileContent ( filePath , encoding ) . split ( "\\n" ) ) ;


signature:
public class CBFileUtil { /** * 按照指定编码得到文件内容 , 保存list中
 * @ param file 源文件
 * @ param encoding 文件编
 * @ return 文件内容
 * @ throws IOException io exception */
public static List < String > getFileContentAsList ( File file , String encoding ) throws IOException { } }

implementation: return Arrays . asList ( getFileContent ( new FileInputStream ( file ) , encoding ) . split ( "\\n" ) ) ;


signature:
public class CBFileUtil { /** * 按照UTF - 8编码得到输入流内容
 * @ param is 输入流
 * @ return 文件内容
 * @ throws IOException io exception */
public static String getFileContent ( InputStream is ) throws IOException { } }

implementation: BufferedReader buff = new BufferedReader ( new InputStreamReader ( is , "UTF-8" ) ) ; String content = getContent ( buff ) ; buff . close ( ) ; return content ;


signature:
public class CBFileUtil { /** * 按照指定编码获取输入流字节内容
 * @ param is 输入流
 * @ param encoding 编码
 * @ return 字节数组
 * @ throws IOException io exception */
public static byte [ ] getFileByteContent ( InputStream is , String encoding ) throws IOException { } }

implementation: byte [ ] buffer = new byte [ 1024 ] ; int len ; ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ; while ( ( len = is . read ( buffer ) ) != - 1 ) { outputStream . write ( buffer , 0 , len ) ; } outputStream . close ( ) ; is . close ( ) ; return outputStream . toByteArray ( ) ;


signature:
public class CBFileUtil { /** * 获取BufferedReader对应字符串
 * @ param buff bufferedReader
 * @ return 内容
 * @ throws IOException io exception */
private static String getContent ( BufferedReader buff ) throws IOException { } }

implementation: String line ; StringBuffer content = new StringBuffer ( ) ; while ( ( line = buff . readLine ( ) ) != null ) { content . append ( '\n' ) ; content . append ( line ) ; } return content . substring ( 1 ) . toString ( ) ;