idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
14,300 | public static final < T > T applyList ( Object base , String fieldname ) { return applyList ( base , fieldname , BeanHelper :: defaultFactory ) ; } | Applies bean action by using default factory . |
14,301 | public static final String applyPrefix ( String property ) { int addIdx = property . lastIndexOf ( Add ) ; if ( addIdx != - 1 ) { return property . substring ( 0 , addIdx ) ; } else { int assignIdx = property . lastIndexOf ( Assign ) ; if ( assignIdx != - 1 ) { return property . substring ( 0 , assignIdx ) ; } else { if ( property . endsWith ( Remove ) ) { return property . substring ( 0 , property . length ( ) - 1 ) ; } else { return property ; } } } } | Return prefix of apply pattern or pattern if not apply - pattern . |
14,302 | public static final Object removeList ( Object bean , String property ) { return doFor ( bean , property , null , ( Object a , int i ) -> { throw new UnsupportedOperationException ( "not supported" ) ; } , ( List l , int i ) -> { return l . remove ( i ) ; } , ( Object b , Class c , String p ) -> { throw new UnsupportedOperationException ( "not supported" ) ; } , ( Object b , Method m ) -> { throw new UnsupportedOperationException ( "not supported" ) ; } ) ; } | Removes pattern item from list |
14,303 | public static final < T > void addList ( Object bean , String property , T value ) { addList ( bean , property , null , ( Class < T > c , String h ) -> { return value ; } ) ; } | Adds pattern item to end of list |
14,304 | public static final < T > T addList ( Object bean , String property , String hint , BiFunction < Class < T > , String , T > factory ) { Object fieldValue = getValue ( bean , property ) ; if ( fieldValue instanceof List ) { List list = ( List ) fieldValue ; Class [ ] pt = getParameterTypes ( bean , property ) ; T value = ( T ) factory . apply ( pt [ 0 ] , hint ) ; if ( value != null && ! pt [ 0 ] . isAssignableFrom ( value . getClass ( ) ) ) { throw new IllegalArgumentException ( pt [ 0 ] + " not assignable from " + value ) ; } list . add ( value ) ; return value ; } else { throw new IllegalArgumentException ( fieldValue + " not List" ) ; } } | Adds pattern item to end of list using given factory and hint |
14,305 | public static final String getter ( Field field , String fieldName ) { Class < ? > type = field . getType ( ) ; if ( type . isPrimitive ( ) && "boolean" . equals ( type . getName ( ) ) ) { return isser ( fieldName ) ; } else { return getter ( fieldName ) ; } } | property - > getProperty |
14,306 | public static final String prefix ( String pattern ) { int idx = CharSequences . lastIndexOf ( pattern , BeanHelper :: separator ) ; if ( idx != - 1 ) { return pattern . substring ( 0 , idx ) ; } else { return "" ; } } | Return string before last reparator |
14,307 | public static final boolean isListItem ( String pattern ) { int idx = pattern . lastIndexOf ( Lim ) ; if ( idx != - 1 ) { try { Integer . parseInt ( pattern . substring ( idx + 1 ) ) ; return true ; } catch ( NumberFormatException ex ) { return false ; } } else { return false ; } } | Return true if string after last separator is numeric |
14,308 | public static final Set < String > getProperties ( Object bean ) { return stream ( bean ) . collect ( Collectors . toSet ( ) ) ; } | Return set of objects patterns |
14,309 | public void free ( ) { super . free ( ) ; if ( m_record != null ) m_record . removeField ( this ) ; m_record = null ; m_strFieldName = null ; m_strFieldDesc = null ; if ( m_vScreenField != null ) { m_vScreenField . removeAllElements ( ) ; m_vScreenField = null ; } } | Free this field s resources . Removes this fieldlist from the parent record . |
14,310 | public void addComponent ( Object sField ) { if ( m_vScreenField == null ) m_vScreenField = new Vector < Object > ( ) ; m_vScreenField . addElement ( sField ) ; } | This screen component is displaying this field . |
14,311 | public Object getComponent ( int iPosition ) { if ( m_vScreenField == null ) return null ; if ( iPosition < m_vScreenField . size ( ) ) { try { return m_vScreenField . elementAt ( iPosition ) ; } catch ( ArrayIndexOutOfBoundsException e ) { return null ; } } return null ; } | Get the component at this position . |
14,312 | public void displayField ( ) { if ( m_vScreenField == null ) return ; for ( int i = 0 ; i < m_vScreenField . size ( ) ; i ++ ) { Object component = m_vScreenField . elementAt ( i ) ; Convert converter = null ; if ( component instanceof ScreenComponent ) converter = ( ( ScreenComponent ) component ) . getConverter ( ) ; if ( converter == null ) converter = this ; if ( ( this . getFieldName ( ) . equals ( this . getNameByReflection ( component ) ) ) || ( converter . getField ( ) == this ) ) { if ( component instanceof FieldComponent ) ( ( FieldComponent ) component ) . setControlValue ( converter . getData ( ) ) ; else if ( component . getClass ( ) . getName ( ) . contains ( "ext" ) ) this . setTextByReflection ( component , converter . getString ( ) ) ; } } } | Display this field . Go through the sFieldList and setText for JTextComponents and setControlValue for FieldComponents . |
14,313 | public String getFieldDesc ( ) { String strFieldDesc = null ; if ( m_strFieldDesc != null ) strFieldDesc = m_strFieldDesc ; else { if ( this . getRecord ( ) != null ) strFieldDesc = this . getRecord ( ) . getString ( this . getFieldName ( ) ) ; } return strFieldDesc ; } | Get the short field description . |
14,314 | public String getFieldTip ( ) { String strTipKey = this . getFieldName ( ) + Constants . TIP ; String strFieldTip = strTipKey ; if ( this . getRecord ( ) != null ) strFieldTip = this . getRecord ( ) . getString ( strTipKey ) ; if ( strFieldTip == strTipKey ) return this . getFieldDesc ( ) ; return strFieldTip ; } | Get the long field description tip . Look in the resource for the long description if not found return the field desc . |
14,315 | public int getMaxLength ( ) { if ( m_iMaxLength == Constants . DEFAULT_FIELD_LENGTH ) { m_iMaxLength = 20 ; if ( m_classData == Short . class ) m_iMaxLength = 4 ; else if ( m_classData == Integer . class ) m_iMaxLength = 8 ; else if ( m_classData == Float . class ) m_iMaxLength = 8 ; else if ( m_classData == Double . class ) m_iMaxLength = 15 ; else if ( m_classData == java . util . Date . class ) m_iMaxLength = 15 ; else if ( m_classData == String . class ) m_iMaxLength = 30 ; else if ( m_classData == Boolean . class ) m_iMaxLength = 10 ; } return m_iMaxLength ; } | Maximum string length . |
14,316 | public int initField ( boolean bDisplayOption ) { if ( ( this . getDefault ( ) == null ) || ( this . getDefault ( ) instanceof String ) ) return this . setString ( ( String ) this . getDefault ( ) , bDisplayOption , Constants . INIT_MOVE ) ; return this . setData ( this . getDefault ( ) , bDisplayOption , Constants . INIT_MOVE ) ; } | Set this field back to the original value . |
14,317 | public double getValue ( ) { Object objData = this . getData ( ) ; if ( objData != null ) { Class < ? > classData = this . getDataClass ( ) ; if ( classData != Object . class ) if ( classData == objData . getClass ( ) ) { if ( classData == Short . class ) return ( ( Short ) objData ) . shortValue ( ) ; else if ( classData == Integer . class ) return ( ( Integer ) objData ) . intValue ( ) ; else if ( classData == Float . class ) return ( ( Float ) objData ) . floatValue ( ) ; else if ( classData == Double . class ) return ( ( Double ) objData ) . doubleValue ( ) ; else if ( classData == java . util . Date . class ) return ( ( Date ) objData ) . getTime ( ) ; else if ( classData == Boolean . class ) return ( ( ( Boolean ) objData ) . booleanValue ( ) ? 1 : 0 ) ; else if ( classData != String . class ) { try { return this . stringToDouble ( ( String ) objData ) . doubleValue ( ) ; } catch ( Exception ex ) { } } } } return super . getValue ( ) ; } | For numeric fields get the current value . Usually overidden . |
14,318 | public int setState ( boolean bState , boolean bDisplayOption , int iMoveMode ) { Boolean objData = new Boolean ( bState ) ; if ( this . getDataClass ( ) == Boolean . class ) return this . setData ( objData , bDisplayOption , iMoveMode ) ; else if ( Number . class . isAssignableFrom ( this . getDataClass ( ) ) ) return this . setValue ( objData . booleanValue ( ) ? 1 : 0 , bDisplayOption , iMoveMode ) ; else if ( this . getDataClass ( ) == String . class ) return this . setString ( objData . booleanValue ( ) ? Constants . TRUE : Constants . FALSE , bDisplayOption , iMoveMode ) ; return super . setState ( bState , bDisplayOption , iMoveMode ) ; } | Set the data in this field to true or false . |
14,319 | public boolean getState ( ) { if ( this . getDataClass ( ) == Boolean . class ) { Boolean objData = ( Boolean ) this . getData ( ) ; if ( objData != null ) return objData . booleanValue ( ) ; } return false ; } | Get the state of this boolean field . |
14,320 | public Optional < T > updateResourceWithLog ( ) { Optional < T > resourceAsOpt = updateResource ( ) ; log . debug ( "Updated Resource - {}" , updateResource ( ) . isPresent ( ) ? "YES" : "NO" ) ; return resourceAsOpt ; } | Update resource with log optional . |
14,321 | public Optional < T > updateResource ( ) { return JMOptional . getOptional ( JMRestfulResource . getStringWithRestOrClasspathOrFilePath ( restfulResourceUrl ) ) . filter ( getEquals ( cachedJsonString ) . negate ( ) ) . filter ( peek ( this :: setJsonStringCache ) ) . map ( jsonString -> JMJson . withJsonString ( jsonString , typeReference ) ) . filter ( peek ( resource -> this . cachedResource = resource ) ) ; } | Update resource optional . |
14,322 | private static String stripFileExtensionIfAny ( final String name ) { final int suffix = name . lastIndexOf ( ".html" ) ; return suffix == - 1 ? name : name . substring ( 0 , suffix ) ; } | bit of a hack ... |
14,323 | public void addPropertyListeners ( ) { this . addPropertiesFieldBehavior ( this . getField ( MessageDetail . DESTINATION_SITE ) , TrxMessageHeader . DESTINATION_PARAM ) ; this . addPropertiesFieldBehavior ( this . getField ( MessageDetail . DESTINATION_PATH ) , TrxMessageHeader . DESTINATION_MESSAGE_PARAM ) ; this . addPropertiesFieldBehavior ( this . getField ( MessageDetail . RETURN_SITE ) , TrxMessageHeader . SOURCE_PARAM ) ; this . addPropertiesFieldBehavior ( this . getField ( MessageDetail . RETURN_PATH ) , TrxMessageHeader . SOURCE_MESSAGE_PARAM ) ; this . addPropertiesFieldBehavior ( this . getField ( MessageDetail . XSLT_DOCUMENT ) , TrxMessageHeader . XSLT_DOCUMENT ) ; this . addPropertiesFieldBehavior ( this . getField ( MessageDetail . INITIAL_MANUAL_TRANSPORT_STATUS_ID ) , MessageTransport . INITIAL_MESSAGE_DATA_STATUS ) ; this . addPropertiesFieldBehavior ( this . getField ( MessageDetail . DEFAULT_MESSAGE_VERSION_ID ) , TrxMessageHeader . MESSAGE_VERSION_ID ) ; } | AddPropertyListeners Method . |
14,324 | public TrxMessageHeader addMessageProperties ( TrxMessageHeader trxMessageHeader , MessageDetailTarget recMessageDetailTarget , MessageProcessInfo recMessageProcessInfo , MessageTransport recMessageTransport ) { try { if ( trxMessageHeader == null ) trxMessageHeader = new TrxMessageHeader ( null , null ) ; ContactType recContactType = ( ContactType ) ( ( ReferenceField ) this . getField ( MessageDetail . CONTACT_TYPE_ID ) ) . getReferenceRecord ( null ) ; recContactType = ( ContactType ) recContactType . getContactType ( ( Record ) recMessageDetailTarget ) ; if ( recContactType == null ) return trxMessageHeader ; this . setKeyArea ( MessageDetail . CONTACT_TYPE_ID_KEY ) ; this . getField ( MessageDetail . CONTACT_TYPE_ID ) . moveFieldToThis ( ( BaseField ) recContactType . getCounterField ( ) ) ; this . getField ( MessageDetail . PERSON_ID ) . moveFieldToThis ( ( BaseField ) ( ( Record ) recMessageDetailTarget ) . getCounterField ( ) ) ; this . getField ( MessageDetail . MESSAGE_PROCESS_INFO_ID ) . moveFieldToThis ( ( BaseField ) recMessageProcessInfo . getCounterField ( ) ) ; this . getField ( MessageDetail . MESSAGE_TRANSPORT_ID ) . moveFieldToThis ( ( BaseField ) recMessageTransport . getCounterField ( ) ) ; if ( this . seek ( null ) ) { Map < String , Object > propHeader = ( ( PropertiesField ) this . getField ( MessageDetail . PROPERTIES ) ) . loadProperties ( ) ; if ( propHeader == null ) propHeader = new HashMap < String , Object > ( ) ; Map < String , Object > map = trxMessageHeader . getMessageHeaderMap ( ) ; if ( map != null ) map . putAll ( propHeader ) ; else map = propHeader ; trxMessageHeader . setMessageHeaderMap ( map ) ; if ( ( recMessageTransport != null ) && ( ( recMessageTransport . getEditMode ( ) == DBConstants . EDIT_CURRENT ) || ( recMessageTransport . getEditMode ( ) == DBConstants . EDIT_IN_PROGRESS ) ) ) { trxMessageHeader = recMessageTransport . addMessageProperties ( trxMessageHeader ) ; } } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } return trxMessageHeader ; } | Get the message properties for this vendor . |
14,325 | @ SuppressWarnings ( "unchecked" ) public final SelfType startTime ( final DateTime when , final TimeSpan jitter ) { final DateTime now = new DateTime ( ) . withZone ( when . getZone ( ) ) ; final int startWeekDay = when . getDayOfWeek ( ) ; final int currentWeekDay = now . getDayOfWeek ( ) ; final int daysTilStart = ( startWeekDay - currentWeekDay + DAYS_PER_WEEK ) % DAYS_PER_WEEK ; Preconditions . checkState ( daysTilStart >= 0 && daysTilStart < DAYS_PER_WEEK , "daysTilStart must be 0..%s, but is %s" , DAYS_PER_WEEK , daysTilStart ) ; final long millisecondsTilStart = ( when . getMillisOfDay ( ) - now . getMillisOfDay ( ) + daysTilStart * MILLIS_PER_DAY + MILLIS_PER_WEEK ) % MILLIS_PER_WEEK ; Preconditions . checkState ( millisecondsTilStart >= 0 && millisecondsTilStart < MILLIS_PER_WEEK , "millisecondsTilStart must be 0..%s, but is %s" , MILLIS_PER_WEEK , millisecondsTilStart ) ; this . delay = Duration . millis ( ( long ) ( ThreadLocalRandom . current ( ) . nextDouble ( ) * jitter . getMillis ( ) ) + millisecondsTilStart ) ; return ( SelfType ) this ; } | Set the time - of - day when the first run of the job will take place . |
14,326 | public void doFilter ( ServletRequest request , ServletResponse response , FilterChain chain ) throws IOException , ServletException { if ( response instanceof HttpServletResponse ) { HttpServletResponse httpResponse = ( HttpServletResponse ) response ; String queryString = ( ( HttpServletRequest ) request ) . getQueryString ( ) ; if ( queryString == null ) { queryString = "" ; } if ( regExpFilters == null || regExpFilters . isEmpty ( ) ) { setHeaders ( httpResponse ) ; } else { if ( Pattern . matches ( regExpFilters , queryString ) ) { setHeaders ( httpResponse ) ; } } } chain . doFilter ( request , response ) ; } | Add no - cache headers if Query String matches reqExoFilters |
14,327 | private void setHeader ( HttpServletResponse response , String name , String value ) { if ( response . containsHeader ( value ) ) { response . setHeader ( name , value ) ; } else { response . addHeader ( name , value ) ; } } | Set Cache header . |
14,328 | protected Element createLinkWrapperElement ( final Document document , final Node node , final String cssClass ) { final Element linkElement = document . createElement ( "para" ) ; if ( cssClass != null ) { linkElement . setAttribute ( "role" , cssClass ) ; } node . appendChild ( linkElement ) ; return linkElement ; } | Creates the wrapper element for bug or editor links and adds it to the document . |
14,329 | protected Element createExternalLinkElement ( final DocBookVersion docBookVersion , final Document document , String title , final String url ) { final Element linkEle ; if ( docBookVersion == DocBookVersion . DOCBOOK_50 ) { linkEle = document . createElement ( "link" ) ; linkEle . setAttributeNS ( "http://www.w3.org/1999/xlink" , "xlink:href" , url ) ; } else { linkEle = document . createElement ( "ulink" ) ; linkEle . setAttribute ( "url" , url ) ; } linkEle . setTextContent ( title ) ; return linkEle ; } | Creates an element that represents an external link . |
14,330 | protected String createExternalLinkElement ( final DocBookVersion docBookVersion , final String title , final String url ) { final StringBuilder linkEle = new StringBuilder ( ) ; if ( docBookVersion == DocBookVersion . DOCBOOK_50 ) { linkEle . append ( "<link xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:href=\"" ) . append ( url ) . append ( "\">" ) ; linkEle . append ( title ) ; linkEle . append ( "</link>" ) ; } else { linkEle . append ( "<ulink url=\"" ) . append ( url ) . append ( "\">" ) ; linkEle . append ( title ) ; linkEle . append ( "</ulink>" ) ; } return linkEle . toString ( ) ; } | Creates a string that represents an external link . |
14,331 | public void processTopicAdditionalInfo ( final BuildData buildData , final SpecTopic specTopic , final Document document ) throws BuildProcessingException { if ( ! shouldAddAdditionalInfo ( buildData , specTopic ) ) return ; final List < Node > invalidNodes = XMLUtilities . getChildNodes ( document . getDocumentElement ( ) , "section" ) ; if ( invalidNodes == null || invalidNodes . size ( ) == 0 ) { final Element rootEle = getRootAdditionalInfoElement ( document , document . getDocumentElement ( ) ) ; if ( buildData . getBuildOptions ( ) . getInsertEditorLinks ( ) && specTopic . getTopicType ( ) != TopicType . AUTHOR_GROUP ) { processTopicEditorLinks ( buildData , specTopic , document , rootEle ) ; } if ( buildData . getBuildOptions ( ) . getInsertBugLinks ( ) && specTopic . getTopicType ( ) == TopicType . NORMAL ) { processTopicBugLink ( buildData , specTopic , document , rootEle ) ; } } } | Adds some debug information and links to the end of the topic |
14,332 | protected static boolean shouldAddAdditionalInfo ( final BuildData buildData , final SpecTopic specTopic ) { return ( buildData . getBuildOptions ( ) . getInsertEditorLinks ( ) && specTopic . getTopicType ( ) != TopicType . AUTHOR_GROUP ) || ( buildData . getBuildOptions ( ) . getInsertBugLinks ( ) && specTopic . getTopicType ( ) == TopicType . NORMAL ) ; } | Checks to see if additional info should be added based on the build options and the spec topic type . |
14,333 | private static List < InjectionData > processIdList ( final String list ) { final String [ ] ids = list . split ( "," ) ; List < InjectionData > retValue = new ArrayList < InjectionData > ( ids . length ) ; for ( final String id : ids ) { final String topicId = id . replaceAll ( OPTIONAL_MARKER , "" ) . trim ( ) ; final boolean optional = id . contains ( OPTIONAL_MARKER ) ; try { final InjectionData topicData = new InjectionData ( topicId , optional ) ; retValue . add ( topicData ) ; } catch ( final NumberFormatException ex ) { LOG . debug ( "Unable to convert Injection Point ID into a Number" , ex ) ; retValue . add ( new InjectionData ( "-1" , false ) ) ; } } return retValue ; } | Takes a comma separated list of ints and returns an array of Integers . This is used when processing custom injection points . |
14,334 | public static byte [ ] encodeLength ( int length , int offset ) { if ( length < SIZE_THRESHOLD ) { byte firstByte = ( byte ) ( length + offset ) ; return new byte [ ] { firstByte } ; } else if ( length < MAX_ITEM_LENGTH ) { byte [ ] binaryLength ; if ( length > 0xFF ) binaryLength = intToBytesNoLeadZeroes ( length ) ; else binaryLength = new byte [ ] { ( byte ) length } ; byte firstByte = ( byte ) ( binaryLength . length + offset + SIZE_THRESHOLD - 1 ) ; return concatenate ( new byte [ ] { firstByte } , binaryLength ) ; } else { throw new RuntimeException ( "Input too long" ) ; } } | Integer limitation goes up to 2^31 - 1 so length can never be bigger than MAX_ITEM_LENGTH |
14,335 | public double getIntensity ( double dlat , double dlong , double year , double altitude ) { calcGeoMag ( dlat , dlong , year , altitude ) ; return ti ; } | Returns the magnetic field intensity from the Department of Defense geomagnetic model and data in nano Tesla . |
14,336 | public double getHorizontalIntensity ( double dlat , double dlong , double year , double altitude ) { calcGeoMag ( dlat , dlong , year , altitude ) ; return bh ; } | Returns the horizontal magnetic field intensity from the Department of Defense geomagnetic model and data in nano Tesla . |
14,337 | public double getVerticalIntensity ( double dlat , double dlong , double year , double altitude ) { calcGeoMag ( dlat , dlong , year , altitude ) ; return bz ; } | Returns the vertical magnetic field intensity from the Department of Defense geomagnetic model and data in nano Tesla . |
14,338 | public double getNorthIntensity ( double dlat , double dlong , double year , double altitude ) { calcGeoMag ( dlat , dlong , year , altitude ) ; return by ; } | Returns the northerly magnetic field intensity from the Department of Defense geomagnetic model and data in nano Tesla . |
14,339 | public double getEastIntensity ( double dlat , double dlong , double year , double altitude ) { calcGeoMag ( dlat , dlong , year , altitude ) ; return bx ; } | Returns the easterly magnetic field intensity from the Department of Defense geomagnetic model and data in nano Tesla . |
14,340 | public double getDipAngle ( double dlat , double dlong , double year , double altitude ) { calcGeoMag ( dlat , dlong , year , altitude ) ; return dip ; } | Returns the magnetic field dip angle from the Department of Defense geomagnetic model and data in degrees . |
14,341 | private void setCoeff ( ) { c [ 0 ] [ 0 ] = 0.0 ; cd [ 0 ] [ 0 ] = 0.0 ; epoch = Double . parseDouble ( input [ 0 ] . trim ( ) . split ( "[\\s]+" ) [ 0 ] ) ; defaultDate = epoch + 2.5 ; String [ ] tokens ; for ( int i = 1 ; i < input . length ; i ++ ) { tokens = input [ i ] . trim ( ) . split ( "[\\s]+" ) ; int n = Integer . parseInt ( tokens [ 0 ] ) ; int m = Integer . parseInt ( tokens [ 1 ] ) ; double gnm = Double . parseDouble ( tokens [ 2 ] ) ; double hnm = Double . parseDouble ( tokens [ 3 ] ) ; double dgnm = Double . parseDouble ( tokens [ 4 ] ) ; double dhnm = Double . parseDouble ( tokens [ 5 ] ) ; if ( m <= n ) { c [ m ] [ n ] = gnm ; cd [ m ] [ n ] = dgnm ; if ( m != 0 ) { c [ n ] [ m - 1 ] = hnm ; cd [ n ] [ m - 1 ] = dhnm ; } } } } | This method sets the input data to the internal fit coefficents . If there is an exception reading the input file WMM . COF these values are used . |
14,342 | void setState ( final WorldState state ) { if ( this . ready ) { throw new IllegalStateException ( "Cannot reassign the world state of a response." ) ; } this . state = state ; this . ready = true ; synchronized ( this ) { this . notifyAll ( ) ; } } | Sets the state of this Response message . This method should only be called once . |
14,343 | public < T > T asObject ( String string , Class < T > valueType ) { return ( T ) TimeZone . getTimeZone ( string ) ; } | Create time zone instance from time zone ID . If time zone ID is not recognized return UTC . |
14,344 | public static < I , O > JMProcessor < I , O > build ( Function < I , O > transformerFunction ) { return new JMProcessor < > ( transformerFunction ) ; } | Build jm processor . |
14,345 | public static < T , M , R > Processor < T , R > combine ( Processor < T , M > processor1 , Processor < M , R > processor2 ) { processor1 . subscribe ( processor2 ) ; return new Processor < > ( ) { public void subscribe ( Flow . Subscriber < ? super R > subscriber ) { processor2 . subscribe ( subscriber ) ; } public void onSubscribe ( Flow . Subscription subscription ) { processor1 . onSubscribe ( subscription ) ; } public void onNext ( T item ) { processor1 . onNext ( item ) ; } public void onError ( Throwable throwable ) { processor1 . onError ( throwable ) ; } public void onComplete ( ) { processor1 . onComplete ( ) ; } } ; } | Combine processor . |
14,346 | public boolean isContactDisplay ( ) { String strUserContactType = this . getProperty ( DBParams . CONTACT_TYPE ) ; String strUserContactID = this . getProperty ( DBParams . CONTACT_ID ) ; String strContactType = ( ( ReferenceField ) this . getScreenRecord ( ) . getField ( MessageLogScreenRecord . CONTACT_TYPE_ID ) ) . getReference ( ) . getField ( ContactType . CODE ) . toString ( ) ; String strContactID = this . getScreenRecord ( ) . getField ( MessageLogScreenRecord . CONTACT_ID ) . toString ( ) ; if ( ( strUserContactID != null ) && ( strUserContactID . equals ( strContactID ) ) ) if ( ( strUserContactType != null ) && ( strUserContactType . equals ( strContactType ) ) ) return true ; return false ; } | IsContactDisplay Method . |
14,347 | public static Date parseDate ( final String date , final List < String > patterns ) { for ( final String pattern : patterns ) { final SimpleDateFormat formatter = new SimpleDateFormat ( pattern ) ; try { return formatter . parse ( date ) ; } catch ( final ParseException e ) { } } return null ; } | Tries to convert the given String to a Date . |
14,348 | public static Date parseToDate ( final String datum , final String [ ] formats , final Locale locale ) { for ( final String format : formats ) { final SimpleDateFormat sdf = new SimpleDateFormat ( format , locale ) ; try { return sdf . parse ( datum ) ; } catch ( final ParseException e ) { } } return null ; } | Returns a date - object if the array with the formats are valid otherwise null . |
14,349 | private String readBeanName ( Class beanClass ) throws NoSuchFieldException , IllegalAccessException { final Field field = beanClass . getField ( "BEAN_NAME" ) ; return String . valueOf ( field . get ( null ) ) ; } | Find what s stored in BEAN_NAME and return it or toss an exception . |
14,350 | public static final double deltaLongitude ( double latitude , double distance , double bearing ) { double departure = departure ( latitude ) ; double sin = Math . sin ( Math . toRadians ( bearing ) ) ; return ( sin * distance ) / ( 60 * departure ) ; } | Return longitude change after moving distance at bearing |
14,351 | public static final double departure ( WayPoint loc1 , WayPoint loc2 ) { return departure ( loc2 . getLatitude ( ) , loc1 . getLatitude ( ) ) ; } | Return average departure of two waypoints |
14,352 | public static final double departure ( double latitude1 , double latitude2 ) { checkLatitude ( latitude1 ) ; checkLatitude ( latitude2 ) ; return departure ( ( latitude1 + latitude2 ) / 2 ) ; } | Returns departure of average latitude |
14,353 | public static final double bearing ( WayPoint wp1 , WayPoint wp2 ) { double lat1 = wp1 . getLatitude ( ) ; double lat2 = wp2 . getLatitude ( ) ; double lon1 = wp1 . getLongitude ( ) ; double lon2 = wp2 . getLongitude ( ) ; return bearing ( lat1 , lon1 , lat2 , lon2 ) ; } | Return bearing from wp1 to wp2 in degrees |
14,354 | public static final double speed ( WayPoint wp1 , WayPoint wp2 ) { double lat1 = wp1 . getLatitude ( ) ; double lat2 = wp2 . getLatitude ( ) ; double lon1 = wp1 . getLongitude ( ) ; double lon2 = wp2 . getLongitude ( ) ; long time1 = wp1 . getTime ( ) ; long time2 = wp2 . getTime ( ) ; return speed ( time1 , lat1 , lon1 , time2 , lat2 , lon2 ) ; } | Returns the speed needed to move from wp1 to wp2 |
14,355 | public static final double addLongitude ( double longitude , double delta ) { double gha = longitudeToGHA ( longitude ) ; gha -= delta ; return ghaToLongitude ( normalizeAngle ( gha ) ) ; } | Adds delta to longitude . Positive delta is to east |
14,356 | public void setVersion ( String value ) { clear ( ) ; if ( value == null || value . length ( ) == 0 ) { return ; } String pcs [ ] = value . split ( "\\." , 4 ) ; int len = Math . min ( pcs . length , 4 ) ; for ( int i = 0 ; i < len ; i ++ ) { ver [ i ] = Long . parseLong ( pcs [ i ] ) ; } } | Set version components from input value . |
14,357 | private void appendVersion ( StringBuilder sb , long ver ) { if ( sb . length ( ) > 0 ) { sb . append ( "." ) ; } sb . append ( ver ) ; } | Append version component . |
14,358 | public void init ( String jsonString ) throws AuthenticationException { try { setConfig ( new JsonSimpleConfig ( jsonString ) ) ; } catch ( UnsupportedEncodingException e ) { throw new AuthenticationException ( e ) ; } catch ( IOException e ) { throw new AuthenticationException ( e ) ; } } | Initialisation of Internal Authentication plugin |
14,359 | private void setConfig ( JsonSimpleConfig config ) throws IOException { user_object = new InternalUser ( ) ; file_path = config . getString ( null , "authentication" , "internal" , "path" ) ; loadUsers ( ) ; } | Set default configuration |
14,360 | private void loadUsers ( ) throws IOException { file_store = new Properties ( ) ; try { File user_file = new File ( file_path ) ; if ( ! user_file . exists ( ) ) { user_file . getParentFile ( ) . mkdirs ( ) ; OutputStream out = new FileOutputStream ( user_file ) ; IOUtils . copy ( getClass ( ) . getResourceAsStream ( "/" + DEFAULT_FILE_NAME ) , out ) ; out . close ( ) ; } file_store . load ( new FileInputStream ( file_path ) ) ; } catch ( Exception e ) { throw new IOException ( e ) ; } } | Load users from the file |
14,361 | private void saveUsers ( ) throws IOException { if ( file_store != null ) { try { file_store . store ( new FileOutputStream ( file_path ) , "" ) ; } catch ( Exception e ) { throw new IOException ( e ) ; } } } | Save user lists to the file on the disk |
14,362 | private String encryptPassword ( String password ) throws AuthenticationException { byte [ ] passwordBytes = password . getBytes ( ) ; try { MessageDigest algorithm = MessageDigest . getInstance ( "MD5" ) ; algorithm . reset ( ) ; algorithm . update ( passwordBytes ) ; byte messageDigest [ ] = algorithm . digest ( ) ; BigInteger number = new BigInteger ( 1 , messageDigest ) ; password = number . toString ( 16 ) ; if ( password . length ( ) == 31 ) { password = "0" + password ; } } catch ( Exception e ) { throw new AuthenticationException ( "Internal password encryption failure: " + e . getMessage ( ) ) ; } return password ; } | Password encryption method |
14,363 | public User createUser ( String username , String password ) throws AuthenticationException { String user = file_store . getProperty ( username ) ; if ( user != null ) { throw new AuthenticationException ( "User '" + username + "' already exists." ) ; } String ePwd = encryptPassword ( password ) ; file_store . put ( username , ePwd ) ; try { saveUsers ( ) ; } catch ( IOException e ) { throw new AuthenticationException ( "Error changing password: " , e ) ; } return getUser ( username ) ; } | Create a user . |
14,364 | public void changePassword ( String username , String password ) throws AuthenticationException { String user = file_store . getProperty ( username ) ; if ( user == null ) { throw new AuthenticationException ( "User '" + username + "' not found." ) ; } String ePwd = encryptPassword ( password ) ; file_store . put ( username , ePwd ) ; try { saveUsers ( ) ; } catch ( IOException e ) { throw new AuthenticationException ( "Error changing password: " , e ) ; } } | Change a user s password . |
14,365 | public User getUser ( String username ) throws AuthenticationException { String user = file_store . getProperty ( username ) ; if ( user == null ) { throw new AuthenticationException ( "User '" + username + "' not found." ) ; } user_object = new InternalUser ( ) ; user_object . init ( username ) ; return user_object ; } | Returns a User object if the implementing class supports user queries without authentication . |
14,366 | public List < User > searchUsers ( String search ) throws AuthenticationException { String [ ] users = file_store . keySet ( ) . toArray ( new String [ file_store . size ( ) ] ) ; List < User > found = new ArrayList < User > ( ) ; for ( int i = 0 ; i < users . length ; i ++ ) { if ( users [ i ] . toLowerCase ( ) . contains ( search . toLowerCase ( ) ) ) { found . add ( getUser ( users [ i ] ) ) ; } } return found ; } | Returns a list of users matching the search . |
14,367 | public Map < String , Object > getServerProperties ( ) { Map < String , Object > properties = super . getServerProperties ( ) ; return BaseDatabase . addDBProperties ( properties , this , null ) ; } | Get the base properties to pass to the server . |
14,368 | public String getResourceClassName ( String strBasePackage , String resourceName ) { if ( resourceName == null ) resourceName = strBasePackage . substring ( strBasePackage . lastIndexOf ( '.' ) + 1 ) ; strBasePackage = strBasePackage . substring ( 0 , strBasePackage . lastIndexOf ( '.' ) + 1 ) ; resourceName = Utility . getFullClassName ( null , strBasePackage , resourceName ) ; resourceName = Utility . convertClassName ( resourceName , Constants . RES_SUBPACKAGE ) ; return strBasePackage ; } | Given a class name in the program package get this resource s class name in the res package . |
14,369 | public static long calculateOffsetInMs ( int intervalInMinutes , int offsetInMinutes ) { while ( offsetInMinutes < 0 ) { offsetInMinutes = intervalInMinutes + offsetInMinutes ; } while ( offsetInMinutes > intervalInMinutes ) { offsetInMinutes -= intervalInMinutes ; } return offsetInMinutes * MINUTE_IN_MS ; } | Reformulates negative offsets or offsets larger than interval . |
14,370 | public static void updateLookAndFeel ( Container container , PropertyOwner propertyOwner , Map < String , Object > properties ) { String lookAndFeelClassName = ScreenUtil . getPropery ( ScreenUtil . LOOK_AND_FEEL , propertyOwner , properties , null ) ; if ( lookAndFeelClassName == null ) lookAndFeelClassName = ScreenUtil . DEFAULT ; if ( ScreenUtil . DEFAULT . equalsIgnoreCase ( lookAndFeelClassName ) ) { lookAndFeelClassName = UIManager . getCrossPlatformLookAndFeelClassName ( ) ; } if ( ScreenUtil . SYSTEM . equalsIgnoreCase ( lookAndFeelClassName ) ) lookAndFeelClassName = UIManager . getSystemLookAndFeelClassName ( ) ; String themeClassName = ScreenUtil . getPropery ( ScreenUtil . THEME , propertyOwner , properties , null ) ; MetalTheme theme = null ; FontUIResource font = ScreenUtil . getFont ( propertyOwner , properties , false ) ; ColorUIResource colorText = ScreenUtil . getColor ( ScreenUtil . TEXT_COLOR , propertyOwner , properties ) ; ColorUIResource colorControl = ScreenUtil . getColor ( ScreenUtil . CONTROL_COLOR , propertyOwner , properties ) ; ColorUIResource colorBackground = ScreenUtil . getColor ( ScreenUtil . BACKGROUND_COLOR , propertyOwner , properties ) ; if ( ( themeClassName == null ) || ( themeClassName . equalsIgnoreCase ( ScreenUtil . DEFAULT ) ) ) if ( font == null ) font = ScreenUtil . getFont ( propertyOwner , properties , true ) ; if ( ( font != null ) || ( colorControl != null ) || ( colorText != null ) ) { if ( ! ( theme instanceof CustomTheme ) ) theme = new CustomTheme ( ) ; if ( font != null ) ( ( CustomTheme ) theme ) . setDefaultFont ( font ) ; if ( colorControl != null ) ( ( CustomTheme ) theme ) . setWhite ( colorControl ) ; if ( colorText != null ) ( ( CustomTheme ) theme ) . setBlack ( colorText ) ; if ( colorBackground != null ) { ( ( CustomTheme ) theme ) . setSecondaryColor ( colorBackground ) ; ( ( CustomTheme ) theme ) . setPrimaryColor ( colorBackground ) ; } } else { if ( ( themeClassName == null ) || ( themeClassName . equalsIgnoreCase ( ScreenUtil . DEFAULT ) ) ) theme = null ; else theme = ( MetalTheme ) ClassServiceUtility . getClassService ( ) . makeObjectFromClassName ( themeClassName ) ; } if ( MetalLookAndFeel . class . getName ( ) . equals ( lookAndFeelClassName ) ) { if ( theme == null ) theme = new OceanTheme ( ) ; MetalLookAndFeel . setCurrentTheme ( theme ) ; } try { UIManager . setLookAndFeel ( lookAndFeelClassName ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } SwingUtilities . updateComponentTreeUI ( container ) ; } | Set the look and feel . |
14,371 | public static String getPropery ( String key , PropertyOwner propertyOwner , Map < String , Object > properties , String defaultValue ) { String returnValue = null ; if ( propertyOwner != null ) returnValue = propertyOwner . getProperty ( key ) ; if ( properties != null ) if ( returnValue == null ) returnValue = ( String ) properties . get ( key ) ; if ( returnValue == null ) returnValue = defaultValue ; return returnValue ; } | A utility to get the property from the propertyowner or the property . |
14,372 | public static void setProperty ( String key , String value , PropertyOwner propertyOwner , Map < String , Object > properties ) { if ( propertyOwner != null ) { propertyOwner . setProperty ( key , value ) ; } if ( properties != null ) { if ( value != null ) properties . put ( key , value ) ; else properties . remove ( key ) ; } } | A utility to set the property from the propertyowner or the property . |
14,373 | public static Frame getFrame ( Component component ) { while ( component != null ) { if ( component instanceof Frame ) return ( Frame ) component ; component = component . getParent ( ) ; } return null ; } | Get the frame for this component . |
14,374 | public static void setEnabled ( Component component , boolean bEnabled ) { if ( component instanceof JPanel ) { for ( int i = 0 ; i < ( ( JPanel ) component ) . getComponentCount ( ) ; i ++ ) { JComponent componentSub = ( JComponent ) ( ( JPanel ) component ) . getComponent ( i ) ; ScreenUtil . setEnabled ( componentSub , bEnabled ) ; } } else if ( component instanceof JScrollPane ) { JComponent componentSub = ( JComponent ) ( ( JScrollPane ) component ) . getViewport ( ) . getView ( ) ; ScreenUtil . setEnabled ( componentSub , bEnabled ) ; } else component . setEnabled ( bEnabled ) ; } | Fake disable a control . |
14,375 | @ SuppressWarnings ( "ProhibitedExceptionDeclared" ) public void init ( ) throws Exception { final String configFileLocation = getConfigFileLocation ( ) ; T fileConfig = getEmptyConfig ( ) ; boolean fileExists = false ; log . info ( "Using {} as config file location" , configFileLocation ) ; try ( Reader reader = new BufferedReader ( new InputStreamReader ( new FileInputStream ( configFileLocation ) , "UTF-8" ) ) ) { fileConfig = mapper . readValue ( reader , getConfigClass ( ) ) ; if ( fileConfig instanceof PasswordsConfig < ? > ) { fileConfig = ( ( PasswordsConfig < T > ) fileConfig ) . withDecryptedPasswords ( textEncryptor ) ; } fileExists = true ; } catch ( final FileNotFoundException e ) { log . warn ( "Config file not found, using empty configuration object" ) ; } catch ( final IOException e ) { log . error ( "Error reading config file at {}" , configFileLocation ) ; log . error ( "Recording stack trace" , e ) ; throw new IllegalStateException ( "Could not initialize configuration" , e ) ; } if ( StringUtils . isNotBlank ( defaultConfigFile ) ) { try ( InputStream defaultConfigInputStream = getClass ( ) . getResourceAsStream ( defaultConfigFile ) ) { if ( defaultConfigInputStream != null ) { final T defaultConfig = mapper . readValue ( defaultConfigInputStream , getConfigClass ( ) ) ; fileConfig = fileConfig . merge ( defaultConfig ) ; if ( ! fileExists ) { fileConfig = generateDefaultLogin ( fileConfig ) ; try { writeOutConfigFile ( fileConfig , configFileLocation ) ; } catch ( final IOException e ) { throw new IllegalStateException ( "Could not initialize configuration" , e ) ; } } } } catch ( final IOException e ) { log . error ( "Error reading default config file" , e ) ; throw new IllegalStateException ( "Could not initialize configuration" , e ) ; } } try { fileConfig . basicValidate ( "Root" ) ; } catch ( final ConfigException e ) { log . error ( "Config validation failed in " + e ) ; throw new IllegalStateException ( "Could not initialize configuration" , e ) ; } config . set ( fileConfig ) ; postInitialise ( getConfig ( ) ) ; } | Exception thrown by method in library |
14,376 | public ConfigResponse < T > getConfigResponse ( ) { T config = this . config . get ( ) ; config = withoutDefaultLogin ( config ) ; if ( config instanceof PasswordsConfig < ? > ) { config = ( ( PasswordsConfig < T > ) config ) . withoutPasswords ( ) ; } return new ConfigResponse < > ( config , getConfigFileLocation ( ) , configFileLocation ) ; } | Returns the Config in a format suitable for revealing to users . |
14,377 | public void clearBuffer ( ) { super . clearBuffer ( ) ; if ( m_vector == null ) m_vector = new Vector < Object > ( ) ; else m_vector . removeAllElements ( ) ; m_iCurrentIndex = 0 ; } | Initialize the physical data buffer . |
14,378 | public List < T > fetchList ( int limit ) throws SQLException , InstantiationException , IllegalAccessException { ArrayList < T > result = new ArrayList < T > ( ) ; if ( primitive ) { for ( int i = 0 ; i < limit ; i ++ ) { if ( ! finished ) { result . add ( fetchSingleInternal ( ) ) ; next ( ) ; } else { break ; } } } else { for ( int i = 0 ; i < limit ; i ++ ) { if ( ! finished ) { result . add ( fetchSingleInternal ( ) ) ; next ( ) ; } else { break ; } } } return result ; } | Fetches limited list of entities . |
14,379 | public List < T > fetchList ( ) throws SQLException , InstantiationException , IllegalAccessException { ArrayList < T > result = new ArrayList < T > ( ) ; if ( primitive ) { while ( ! finished ) { result . add ( fetchSinglePrimitiveInternal ( ) ) ; next ( ) ; } } else { while ( ! finished ) { result . add ( fetchSingleInternal ( ) ) ; next ( ) ; } } return result ; } | Fetches the whole list of entities . It will not stop until entire result set will end . |
14,380 | public T fetchSingle ( ) throws InstantiationException , IllegalAccessException , SQLException { if ( ! finished ) { T result = primitive ? fetchSinglePrimitiveInternal ( ) : fetchSingleInternal ( ) ; next ( ) ; return result ; } else { throw new SQLException ( "Result set don't have data for single fetch." ) ; } } | Fetches single entity being sure that it exists . Throws exception if there is no entity . |
14,381 | public T fetchSingleOrNull ( ) throws InstantiationException , IllegalAccessException , SQLException { if ( ! finished ) { T result = primitive ? fetchSinglePrimitiveInternal ( ) : fetchSingleInternal ( ) ; next ( ) ; return result ; } else { return null ; } } | Fetches single entity or null . |
14,382 | public void close ( boolean closeConnection ) throws SQLException { if ( closeConnection ) { resultSet . getStatement ( ) . getConnection ( ) . close ( ) ; } else { resultSet . close ( ) ; } finished = true ; } | Closes underlying result set and optionally the whole connection . |
14,383 | public void close ( ) { super . close ( ) ; try { if ( m_remoteDatabase != null ) { synchronized ( this . getSyncObject ( m_remoteDatabase ) ) { m_remoteDatabase . close ( ) ; } } } catch ( RemoteException ex ) { Utility . getLogger ( ) . warning ( "Remote close error: " + ex . getMessage ( ) ) ; ex . printStackTrace ( ) ; } } | Close the remote databases . |
14,384 | public RemoteDatabase getRemoteDatabase ( ) throws RemoteException { if ( m_remoteDatabase != null ) return m_remoteDatabase ; try { if ( this . getTableCount ( ) == 0 ) return null ; ClientTable table = ( ClientTable ) m_vTableList . get ( 0 ) ; RemoteTable tableRemote = table . getRemoteTable ( ) ; if ( tableRemote != null ) { synchronized ( this . getSyncObject ( tableRemote ) ) { Map < String , Object > propDatabase = BaseDatabase . addDBProperties ( this . getProperties ( ) , this , null ) ; BaseDatabase . addDBProperty ( propDatabase , this , null , this . getDatabaseName ( false ) + BaseDatabase . DBSHARED_PARAM_SUFFIX ) ; BaseDatabase . addDBProperty ( propDatabase , this , null , this . getDatabaseName ( false ) + BaseDatabase . DBUSER_PARAM_SUFFIX ) ; m_remoteDatabase = tableRemote . getRemoteDatabase ( propDatabase ) ; } } if ( m_remoteDatabase != null ) { synchronized ( this . getSyncObject ( m_remoteDatabase ) ) { m_remoteProperties = m_remoteDatabase . getDBProperties ( ) ; } } } catch ( RemoteException ex ) { Utility . getLogger ( ) . warning ( "dbServer exception: " + ex . getMessage ( ) ) ; throw ex ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } return m_remoteDatabase ; } | Open the remote database . |
14,385 | public String getRemoteProperty ( String strProperty , boolean readIfNotCached ) { if ( m_remoteProperties == null ) if ( readIfNotCached ) { try { this . getRemoteDatabase ( ) ; } catch ( RemoteException e ) { e . printStackTrace ( ) ; } } if ( m_remoteProperties != null ) return ( String ) m_remoteProperties . get ( strProperty ) ; return this . getFakeRemoteProperty ( strProperty ) ; } | Get this property from the remote database . This does not make a remote call it just return the property cached on remote db open . |
14,386 | public String getFakeRemoteProperty ( String strProperty ) { if ( SQLParams . EDIT_DB_PROPERTY . equalsIgnoreCase ( strProperty ) ) return SQLParams . DB_EDIT_NOT_SUPPORTED ; return null ; } | To keep from having to contact the remote database remote a property that will not effect the logic . |
14,387 | public void commit ( ) throws DBException { super . commit ( ) ; try { if ( this . getRemoteDatabase ( ) != null ) { synchronized ( this . getSyncObject ( this . getRemoteDatabase ( ) ) ) { this . getRemoteDatabase ( ) . commit ( ) ; } } } catch ( RemoteException ex ) { Utility . getLogger ( ) . warning ( "Remote commit error: " + ex . getMessage ( ) ) ; ex . printStackTrace ( ) ; } catch ( Exception ex ) { throw this . convertError ( ex ) ; } } | Commit the transactions since the last commit . |
14,388 | public BaseMessage processMessage ( BaseMessage message ) { if ( message == null ) return null ; this . updateLogFiles ( message , true ) ; String strReturnQueueName = null ; if ( message . getMessageHeader ( ) instanceof TrxMessageHeader ) strReturnQueueName = ( String ) ( ( TrxMessageHeader ) message . getMessageHeader ( ) ) . getMessageHeaderMap ( ) . get ( MessageConstants . RETURN_QUEUE_NAME ) ; if ( strReturnQueueName == null ) strReturnQueueName = MessageConstants . TRX_RETURN_QUEUE ; TrxMessageHeader privateMessageHeader = new TrxMessageHeader ( strReturnQueueName , MessageConstants . INTERNET_QUEUE , null ) ; if ( message . getMessageHeader ( ) . getRegistryIDMatch ( ) == null ) { Integer intRegistryID = this . getRegistryID ( message ) ; if ( intRegistryID != null ) message . getMessageHeader ( ) . setRegistryIDMatch ( intRegistryID ) ; } privateMessageHeader . setRegistryIDMatch ( message . getMessageHeader ( ) . getRegistryIDMatch ( ) ) ; message . setMessageHeader ( privateMessageHeader ) ; Environment env = null ; if ( ( this . getTask ( ) != null ) && ( this . getTask ( ) . getApplication ( ) != null ) ) env = ( ( BaseApplication ) this . getTask ( ) . getApplication ( ) ) . getEnvironment ( ) ; if ( env == null ) env = Environment . getEnvironment ( null ) ; App app = null ; if ( this . getTask ( ) != null ) app = this . getTask ( ) . getApplication ( ) ; MessageManager msgManager = env . getMessageManager ( app , true ) ; msgManager . sendMessage ( message ) ; return null ; } | Given the converted message for return do any further processing before returning the message . |
14,389 | public static String getPathForResource ( final String resourcePath ) { URL path = ResourceUtil . class . getResource ( resourcePath ) ; if ( path == null ) { path = ResourceUtil . class . getResource ( "/" ) ; File tmpFile = new File ( path . getPath ( ) , resourcePath ) ; return tmpFile . getPath ( ) ; } return path . getPath ( ) ; } | Convert a resource path to an absolute file path . |
14,390 | public static File getFileForResource ( final String resourcePath ) { URL path = ResourceUtil . class . getResource ( resourcePath ) ; if ( path == null ) { path = ResourceUtil . class . getResource ( "/" ) ; return new File ( new File ( path . getPath ( ) ) , resourcePath ) ; } return new File ( path . getPath ( ) ) ; } | Convert a resource path to a File object . |
14,391 | public static String getResourceAsString ( final String resourcePath ) { File resource = getFileForResource ( resourcePath ) ; if ( ! resource . exists ( ) || resource . isDirectory ( ) ) { logger . error ( "Cannot read resource, does not exist" + " (or is a directory)." ) ; return "" ; } try { return FileUtils . readFileToString ( resource ) ; } catch ( IOException ioe ) { logger . error ( ioe . getMessage ( ) ) ; return "" ; } } | Read the resource found at a specific path into a string . |
14,392 | public static InputStream getResourceAsStream ( final String resourcePath ) { File resource = getFileForResource ( resourcePath ) ; if ( ! resource . exists ( ) || resource . isDirectory ( ) ) { logger . error ( "Cannot read resource, does not exist" + " (or is a directory)." ) ; return new NullInputStream ( 0 ) ; } try { return new FileInputStream ( resource ) ; } catch ( IOException ioe ) { logger . error ( ioe . getMessage ( ) ) ; return new NullInputStream ( 0 ) ; } } | Read the resource found at the given path into a stream . |
14,393 | public SetBuilder < T > add ( T ... items ) { set . addAll ( Arrays . asList ( items ) ) ; return this ; } | Adds items to the set . |
14,394 | public int getPrintOptions ( ) throws DBException { int iHtmlOptions = HtmlConstants . HTML_DISPLAY ; if ( ( ( BaseGridScreen ) this . getScreenField ( ) ) . getEditing ( ) ) iHtmlOptions |= HtmlConstants . HTML_INPUT ; String strParamForm = this . getProperty ( HtmlConstants . FORMS ) ; if ( ( strParamForm == null ) || ( strParamForm . length ( ) == 0 ) ) strParamForm = HtmlConstants . BOTHIFDATA ; boolean bPrintReport = true ; if ( ( strParamForm . equalsIgnoreCase ( HtmlConstants . INPUT ) ) || ( strParamForm . equalsIgnoreCase ( HtmlConstants . BOTHIFDATA ) ) || ( strParamForm . equalsIgnoreCase ( HtmlConstants . BOTH ) ) ) { bPrintReport = false ; boolean bScreenFound = false ; int iNumCols = ( ( BaseGridScreen ) this . getScreenField ( ) ) . getSFieldCount ( ) ; for ( int iIndex = 0 ; iIndex < iNumCols ; iIndex ++ ) { ScreenField sField = ( ( BaseGridScreen ) this . getScreenField ( ) ) . getSField ( iIndex ) ; if ( sField instanceof ToolScreen ) if ( ( ! ( sField instanceof DisplayToolbar ) ) && ( ! ( sField instanceof MaintToolbar ) ) && ( ! ( sField instanceof MenuToolbar ) ) ) { HScreenField vField = ( HScreenField ) sField . getScreenFieldView ( ) ; if ( vField . moveControlInput ( Constants . BLANK ) == DBConstants . NORMAL_RETURN ) bPrintReport = true ; bScreenFound = true ; } } if ( ! bScreenFound ) bPrintReport = true ; if ( ! bPrintReport ) if ( this . getProperty ( DBConstants . STRING_OBJECT_ID_HANDLE ) != null ) bPrintReport = true ; } if ( strParamForm . equalsIgnoreCase ( HtmlConstants . DISPLAY ) ) iHtmlOptions |= HtmlConstants . HTML_DISPLAY ; else if ( strParamForm . equalsIgnoreCase ( HtmlConstants . DATA ) ) iHtmlOptions |= HtmlConstants . PRINT_TOOLBAR_BEFORE ; else if ( strParamForm . equalsIgnoreCase ( HtmlConstants . INPUT ) ) iHtmlOptions |= HtmlConstants . PRINT_TOOLBAR_BEFORE | HtmlConstants . DONT_PRINT_SCREEN ; else if ( strParamForm . equalsIgnoreCase ( HtmlConstants . BOTH ) ) iHtmlOptions |= HtmlConstants . PRINT_TOOLBAR_BEFORE ; else if ( strParamForm . equalsIgnoreCase ( HtmlConstants . BOTHIFDATA ) ) { iHtmlOptions |= HtmlConstants . PRINT_TOOLBAR_BEFORE ; if ( ! bPrintReport ) iHtmlOptions |= HtmlConstants . DONT_PRINT_SCREEN ; } return iHtmlOptions ; } | display this screen in html input format . |
14,395 | protected void readFileData ( final ParserData parserData , final BufferedReader br ) throws IOException { String line ; while ( ( line = br . readLine ( ) ) != null ) { parserData . addLine ( line ) ; } } | Reads the data from a file that is passed into a BufferedReader and processes it accordingly . |
14,396 | protected ParserResults processSpec ( final ParserData parserData , final ParsingMode mode , final boolean processProcesses ) { while ( parserData . getLines ( ) . peek ( ) != null ) { final String input = parserData . getLines ( ) . peek ( ) ; if ( isCommentLine ( input ) || isBlankLine ( input ) ) { parserData . setLineCount ( parserData . getLineCount ( ) + 1 ) ; if ( isCommentLine ( input ) ) { parserData . getContentSpec ( ) . appendComment ( input ) ; } else if ( isBlankLine ( input ) ) { parserData . getContentSpec ( ) . appendChild ( new TextNode ( "\n" ) ) ; } parserData . getLines ( ) . poll ( ) ; continue ; } else { break ; } } if ( mode == ParsingMode . NEW ) { return processNewSpec ( parserData , processProcesses ) ; } else if ( mode == ParsingMode . EDITED ) { return processEditedSpec ( parserData , processProcesses ) ; } else { return processEitherSpec ( parserData , processProcesses ) ; } } | Starting method to process a Content Specification string into a ContentSpec object . |
14,397 | protected ParserResults processNewSpec ( final ParserData parserData , final boolean processProcesses ) { final String input = parserData . getLines ( ) . poll ( ) ; parserData . setLineCount ( parserData . getLineCount ( ) + 1 ) ; try { final Pair < String , String > keyValuePair = ProcessorUtilities . getAndValidateKeyValuePair ( input ) ; final String key = keyValuePair . getFirst ( ) ; final String value = keyValuePair . getSecond ( ) ; if ( key . equalsIgnoreCase ( CommonConstants . CS_TITLE_TITLE ) ) { parserData . getContentSpec ( ) . setTitle ( value ) ; return processSpecContents ( parserData , processProcesses ) ; } else if ( key . equalsIgnoreCase ( CommonConstants . CS_CHECKSUM_TITLE ) ) { log . error ( ProcessorConstants . ERROR_INCORRECT_NEW_MODE_MSG ) ; return new ParserResults ( false , null ) ; } else { log . error ( ProcessorConstants . ERROR_INCORRECT_FILE_FORMAT_MSG ) ; return new ParserResults ( false , null ) ; } } catch ( InvalidKeyValueException e ) { log . error ( ProcessorConstants . ERROR_INCORRECT_FILE_FORMAT_MSG , e ) ; return new ParserResults ( false , null ) ; } } | Process a New Content Specification . That is that it should start with a Title instead of a CHECKSUM and ID . |
14,398 | protected ParserResults processEditedSpec ( final ParserData parserData , final boolean processProcesses ) { final String input = parserData . getLines ( ) . poll ( ) ; parserData . setLineCount ( parserData . getLineCount ( ) + 1 ) ; try { final Pair < String , String > keyValuePair = ProcessorUtilities . getAndValidateKeyValuePair ( input ) ; final String key = keyValuePair . getFirst ( ) ; final String value = keyValuePair . getSecond ( ) ; if ( key . equalsIgnoreCase ( CommonConstants . CS_CHECKSUM_TITLE ) ) { parserData . getContentSpec ( ) . setChecksum ( value ) ; final String specIdLine = parserData . getLines ( ) . poll ( ) ; parserData . setLineCount ( parserData . getLineCount ( ) + 1 ) ; if ( specIdLine != null ) { final Pair < String , String > specIdPair = ProcessorUtilities . getAndValidateKeyValuePair ( specIdLine ) ; final String specIdKey = specIdPair . getFirst ( ) ; final String specIdValue = specIdPair . getSecond ( ) ; if ( specIdKey . equalsIgnoreCase ( CommonConstants . CS_ID_TITLE ) ) { int contentSpecId ; try { contentSpecId = Integer . parseInt ( specIdValue ) ; } catch ( NumberFormatException e ) { log . error ( format ( ProcessorConstants . ERROR_INVALID_CS_ID_FORMAT_MSG , specIdLine . trim ( ) ) ) ; return new ParserResults ( false , null ) ; } parserData . getContentSpec ( ) . setId ( contentSpecId ) ; return processSpecContents ( parserData , processProcesses ) ; } else { log . error ( ProcessorConstants . ERROR_CS_NO_CHECKSUM_MSG ) ; return new ParserResults ( false , null ) ; } } else { log . error ( ProcessorConstants . ERROR_INCORRECT_FILE_FORMAT_MSG ) ; return new ParserResults ( false , null ) ; } } else if ( key . equalsIgnoreCase ( CommonConstants . CS_ID_TITLE ) ) { int contentSpecId ; try { contentSpecId = Integer . parseInt ( value ) ; } catch ( NumberFormatException e ) { log . error ( format ( ProcessorConstants . ERROR_INVALID_CS_ID_FORMAT_MSG , input . trim ( ) ) ) ; return new ParserResults ( false , null ) ; } parserData . getContentSpec ( ) . setId ( contentSpecId ) ; return processSpecContents ( parserData , processProcesses ) ; } else { log . error ( ProcessorConstants . ERROR_INCORRECT_EDIT_MODE_MSG ) ; return new ParserResults ( false , null ) ; } } catch ( InvalidKeyValueException e ) { log . error ( ProcessorConstants . ERROR_INCORRECT_FILE_FORMAT_MSG , e ) ; return new ParserResults ( false , null ) ; } } | Process an Edited Content Specification . That is that it should start with a CHECKSUM and ID instead of a Title . |
14,399 | protected ParserResults processEitherSpec ( final ParserData parserData , final boolean processProcesses ) { try { final Pair < String , String > keyValuePair = ProcessorUtilities . getAndValidateKeyValuePair ( parserData . getLines ( ) . peek ( ) ) ; final String key = keyValuePair . getFirst ( ) ; if ( key . equalsIgnoreCase ( CommonConstants . CS_CHECKSUM_TITLE ) || key . equalsIgnoreCase ( CommonConstants . CS_ID_TITLE ) ) { return processEditedSpec ( parserData , processProcesses ) ; } else { return processNewSpec ( parserData , processProcesses ) ; } } catch ( InvalidKeyValueException e ) { log . error ( ProcessorConstants . ERROR_INCORRECT_FILE_FORMAT_MSG , e ) ; return new ParserResults ( false , null ) ; } } | Process Content Specification that is either NEW or EDITED . That is that it should start with a CHECKSUM and ID or a Title . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.