idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
15,600 | public Future < V > queue ( Callable < V > callable ) { return service . executeAsynchronously ( callable , config ) ; } | Invokes runnable asynchronously with respecting circuit logic and cache logic if configured . |
15,601 | public Environment getEnvironment ( ) { Environment env = ( ( BaseApplication ) this . getApplication ( ) ) . getEnvironment ( ) ; if ( env == null ) env = Environment . getEnvironment ( null ) ; return env ; } | Get this task s environment . |
15,602 | public RemoteSendQueue createRemoteSendQueue ( String strQueueName , String strQueueType ) throws RemoteException { MessageManager messageManager = this . getEnvironment ( ) . getMessageManager ( this . getApplication ( ) , true ) ; BaseMessageSender sender = ( BaseMessageSender ) messageManager . getMessageQueue ( strQueueName , strQueueType ) . getMessageSender ( ) ; SendQueueSession remoteQueue = new SendQueueSession ( this , sender ) ; return remoteQueue ; } | Create the remote send queue . |
15,603 | public RemoteReceiveQueue createRemoteReceiveQueue ( String strQueueName , String strQueueType ) throws RemoteException { MessageManager messageManager = this . getEnvironment ( ) . getMessageManager ( this . getApplication ( ) , true ) ; BaseMessageReceiver receiver = ( BaseMessageReceiver ) messageManager . getMessageQueue ( strQueueName , strQueueType ) . getMessageReceiver ( ) ; ReceiveQueueSession remoteQueue = new ReceiveQueueSession ( this , receiver ) ; return remoteQueue ; } | Create the remote receive queue . |
15,604 | public void processMessageTimeout ( String strTrxID ) { MessageLog recMessageLog = ( MessageLog ) this . getMainRecord ( ) ; BaseMessage message = ( BaseMessage ) recMessageLog . createMessage ( strTrxID ) ; String strMessageError = "Message timeout" ; BaseMessage messageReply = ( BaseMessage ) BaseMessageProcessor . processErrorMessage ( this , message , strMessageError ) ; if ( messageReply != null ) { BaseMessageTransport transport = this . getMessageTransport ( message ) ; transport . setupReplyMessage ( messageReply , message , MessageInfoType . REPLY , MessageType . MESSAGE_IN ) ; transport . processIncomingMessage ( messageReply , message ) ; } } | ProcessMessageTimeout Method . |
15,605 | public int setString ( String fieldPtr , boolean bDisplayOption , int iMoveMode ) { if ( this . getField ( ) instanceof PropertiesField ) return ( ( PropertiesField ) this . getField ( ) ) . setProperty ( m_strProperty , fieldPtr , bDisplayOption , iMoveMode ) ; return DBConstants . NORMAL_RETURN ; } | Convert and move string to this field . Set this property in the property field . |
15,606 | @ SuppressWarnings ( "unchecked" ) public < T extends Object > T fetchObject ( Class < T > clazz , String id ) { if ( StringUtils . isEmpty ( id ) ) { return null ; } String json = VistAUtil . getBrokerSession ( ) . callRPC ( "RGSER FETCH" , PREFIX + getAlias ( clazz ) , id ) ; return ( T ) JSONUtil . deserialize ( json ) ; } | Fetch an instance of the domain class from the data store . |
15,607 | @ SuppressWarnings ( "unchecked" ) public < T extends Object > List < T > fetchObjects ( Class < T > clazz , String [ ] ids ) { if ( ids == null || ids . length == 0 ) { return Collections . emptyList ( ) ; } String json = VistAUtil . getBrokerSession ( ) . callRPC ( "RGSER FETCH" , PREFIX + getAlias ( clazz ) , ids ) ; return ( List < T > ) JSONUtil . deserialize ( json ) ; } | Fetch multiple instances of the domain class from the data store . |
15,608 | public String getAlias ( Class < ? > clazz ) { String alias = JSONUtil . getAlias ( clazz ) ; if ( alias == null ) { try { Class . forName ( clazz . getName ( ) ) ; } catch ( ClassNotFoundException e ) { throw MiscUtil . toUnchecked ( e ) ; } alias = JSONUtil . getAlias ( clazz ) ; } return alias ; } | Returns the alias for the domain class . A domain class will typically register its alias in a static initializer block . If the initial attempt to retrieve an alias fails this method forces the class loader to load the class to ensure that any static initializers are executed and then tries again . |
15,609 | public void writeFieldInit ( ) { String strClassName ; Record recClassInfo = this . getMainRecord ( ) ; strClassName = recClassInfo . getField ( ClassInfo . CLASS_NAME ) . getString ( ) ; if ( this . readThisMethod ( strClassName ) ) this . writeThisMethod ( CodeType . THICK ) ; else this . writeThisMethod ( CodeType . THICK ) ; } | Write the field initialize code |
15,610 | public void writeInitField ( ) { Record recLogicFile = this . getRecord ( LogicFile . LOGIC_FILE_FILE ) ; try { String strClassName ; Record recClassInfo = this . getMainRecord ( ) ; FieldData recFieldData = ( FieldData ) this . getRecord ( FieldData . FIELD_DATA_FILE ) ; strClassName = recClassInfo . getField ( ClassInfo . CLASS_NAME ) . getString ( ) ; if ( this . readThisMethod ( "initField" ) ) this . writeThisMethod ( CodeType . THICK ) ; else { String strInitField = this . getInitField ( recFieldData , false , false ) ; if ( strInitField . length ( ) != 0 ) { recLogicFile . getField ( LogicFile . METHOD_NAME ) . setString ( "initField" ) ; recLogicFile . setKeyArea ( LogicFile . METHOD_CLASS_NAME_KEY ) ; if ( ! recLogicFile . seek ( "=" ) ) { this . writeMethodInterface ( null , "initField" , "int" , "boolean displayOption" , "" , "Initialize the field." , null ) ; String setOp = ".setString" ; if ( ( strInitField . equalsIgnoreCase ( "todaysDate()" ) ) || ( strInitField . equalsIgnoreCase ( "currentTime()" ) ) || ( strInitField . equalsIgnoreCase ( "getUserID()" ) ) ) setOp = ".setValue" ; if ( strInitField . length ( ) > 0 ) if ( ( strInitField . charAt ( 0 ) == 'k' ) || ( Character . isDigit ( strInitField . charAt ( 0 ) ) ) || ( strInitField . indexOf ( ".k" ) != - 1 ) ) setOp = ".setValue" ; if ( ( strInitField . equals ( "true" ) ) || ( strInitField . equals ( "false" ) ) ) setOp = ".setState" ; if ( ( strClassName . equalsIgnoreCase ( "IntegerField" ) ) || ( strClassName . equalsIgnoreCase ( "ShortField" ) ) || ( strClassName . equalsIgnoreCase ( "FloatField" ) ) || ( strClassName . equalsIgnoreCase ( "RealField" ) ) || ( strClassName . equalsIgnoreCase ( "CurrencysField" ) ) || ( strClassName . equalsIgnoreCase ( "DoubleField" ) ) ) setOp = ".setValue" ; if ( strInitField . equals ( "all" ) ) { strInitField = "\"all\"" ; setOp = ".setString" ; } if ( ( strInitField . indexOf ( '_' ) != - 1 ) && ( strInitField . indexOf ( '.' ) == - 1 ) ) { strInitField = "\"\"/**" + strInitField + "*/" ; setOp = ".setString" ; } if ( strInitField != strClassName ) m_StreamOut . writeit ( "\treturn this" + setOp + "(" + strInitField + ", displayOption, DBConstants.INIT_MOVE);\n" ) ; m_StreamOut . writeit ( "}\n" ) ; } } } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { recLogicFile . setKeyArea ( LogicFile . SEQUENCE_KEY ) ; } } | Write the field init code |
15,611 | public void setDeviceId ( byte [ ] deviceId ) { if ( deviceId == null ) { throw new RuntimeException ( "Device ID cannot be null." ) ; } if ( deviceId . length != DEVICE_ID_SIZE ) { throw new RuntimeException ( String . format ( "Device ID must be %d bytes long." , Integer . valueOf ( DEVICE_ID_SIZE ) ) ) ; } this . deviceId = deviceId ; } | Sets the device identifier for the transmitter referenced in this sample . |
15,612 | public void setReceiverId ( byte [ ] receiverId ) { if ( receiverId == null ) { throw new RuntimeException ( "Receiver ID cannot be null." ) ; } if ( receiverId . length != DEVICE_ID_SIZE ) { throw new RuntimeException ( String . format ( "Receiver ID must be %d bytes long." , Integer . valueOf ( DEVICE_ID_SIZE ) ) ) ; } this . receiverId = receiverId ; } | Sets the device identifier for the receiver referenced in this sample . |
15,613 | public static EightyPath toRealPath ( Path path ) { if ( ! ( path instanceof EightyPath ) ) { throw new IllegalArgumentException ( path + " should be EightyPath" ) ; } EightyPath eightyPath = ( EightyPath ) path ; if ( eightyPath . knownReal ( ) ) { return eightyPath ; } return new RealPath ( eightyPath ) . to ( ) ; } | toRealPath follow links |
15,614 | public void init ( BaseField field , ScreenComponent screenField , BaseField fldTarget ) { super . init ( field ) ; m_screenField = screenField ; m_fldTarget = fldTarget ; m_bScreenMove = true ; m_bInitMove = false ; m_bReadMove = false ; if ( screenField == null ) this . lookupSField ( ) ; } | Constructor . This listener only responds to screen moves by default . |
15,615 | public int fieldChanged ( boolean bDisplayOption , int iMoveMode ) { if ( m_screenField == null ) this . lookupSField ( ) ; if ( m_bChangeIfNull != null ) { if ( ( m_bChangeIfNull . booleanValue ( ) ) && ( ! this . getOwner ( ) . isNull ( ) ) ) return DBConstants . NORMAL_RETURN ; if ( ( ! m_bChangeIfNull . booleanValue ( ) ) && ( this . getOwner ( ) . isNull ( ) ) ) return DBConstants . NORMAL_RETURN ; } if ( m_screenField != null ) m_screenField . requestFocus ( ) ; return DBConstants . NORMAL_RETURN ; } | The Field has Changed . Change to focus to the target field . |
15,616 | public Vector < LogMessage > getLogMessages ( ) { final Vector < LogMessage > output = new Vector < LogMessage > ( ) ; for ( final LogMessage msg : messages ) { if ( msg . getType ( ) == LogMessage . Type . DEBUG ) { if ( msg . getDebugLevel ( ) <= debugLevel ) { output . add ( msg ) ; } } else { output . add ( msg ) ; } } return output ; } | Gets the log messages and ignores message that are higher then the debug level |
15,617 | public void refresh ( ) throws IOException { if ( Files . exists ( file ) ) { fine ( "%s exist" , file ) ; writeLock . lock ( ) ; try { finer ( "start update(%s)" , file ) ; update ( file ) ; finer ( "end update(%s)" , file ) ; } finally { writeLock . unlock ( ) ; } FileTime lmt = Files . getLastModifiedTime ( file ) ; if ( thread == null && lmt . toMillis ( ) + expires < System . currentTimeMillis ( ) ) { thread = new Thread ( this , url . toString ( ) ) ; thread . setDaemon ( true ) ; thread . start ( ) ; fine ( "started thread for %s" , url ) ; } } else { fine ( "%s doesn't exist" , file ) ; run ( ) ; } } | Call to refresh the file . During the call consumer is called at least once . |
15,618 | private List getResources ( ZipFile file , String root ) { List resourceNames = new ArrayList ( ) ; Enumeration e = file . entries ( ) ; while ( e . hasMoreElements ( ) ) { ZipEntry entry = ( ZipEntry ) e . nextElement ( ) ; String name = entry . getName ( ) ; if ( name . startsWith ( root ) && ! ( name . indexOf ( '/' ) > root . length ( ) ) && ! entry . isDirectory ( ) ) { name = new File ( name ) . getPath ( ) ; resourceNames . add ( name ) ; } } return resourceNames ; } | Returns a list of file resources contained in the specified directory within a given Zip d archive file . |
15,619 | public String getMessage ( ) { String message = super . getMessage ( ) ; if ( m_iErrorCode != - 1 ) message = message + " Error code: " + m_iErrorCode ; return message ; } | Returns the detail message string of this throwable . |
15,620 | public static void encodeSingle ( final int input , final byte [ ] output , final int outoff ) { if ( output == null ) { throw new NullPointerException ( "output" ) ; } if ( outoff < 0 ) { throw new IllegalArgumentException ( "outoff(" + outoff + ") < 0" ) ; } if ( outoff >= output . length - 1 ) { throw new IllegalArgumentException ( "outoff(" + outoff + ") >= output.length(" + output . length + ") - 1" ) ; } output [ outoff ] = ( byte ) encodeHalf ( ( input >> 4 ) & 0x0F ) ; output [ outoff + 1 ] = ( byte ) encodeHalf ( input & 0x0F ) ; } | Encodes a single octet into two hex chars . |
15,621 | public static void encodeSingle ( final byte [ ] input , final int inoff , final byte [ ] output , final int outoff ) { if ( input == null ) { throw new NullPointerException ( "input" ) ; } if ( inoff < 0 ) { throw new IllegalArgumentException ( "inoff(" + inoff + ") < 0" ) ; } if ( inoff >= input . length ) { throw new IllegalArgumentException ( "inoff(" + inoff + ") >= input.length(" + input . length + ")" ) ; } encodeSingle ( input [ inoff ] , output , outoff ) ; } | Encodes a single octet into two nibbles . |
15,622 | public static byte [ ] encodeMultiple ( final byte [ ] input ) { if ( input == null ) { throw new NullPointerException ( "input" ) ; } final byte [ ] output = new byte [ input . length << 1 ] ; encodeMultiple ( input , 0 , output , 0 , input . length ) ; return output ; } | Encodes given sequence of octets into a sequence of nibbles . |
15,623 | public void addTaskProperties ( Task task ) { if ( task == null ) return ; this . put ( TrxMessageHeader . USER_ID , task . getProperty ( DBParams . USER_ID ) ) ; } | Add the task properties that I will need to start up a process somewhere else with this same environment . |
15,624 | public String getText ( ) { String strText = super . getText ( ) ; if ( strText != null ) if ( strText . equals ( m_strDescription ) ) strText = Constants . BLANK ; return strText ; } | Get text from JTextField . This method factors out the description . |
15,625 | public void setText ( String strText ) { if ( ( strText == null ) || ( strText . length ( ) == 0 ) ) { if ( ! m_bInFocus ) { strText = m_strDescription ; this . changeFont ( true ) ; } } else this . changeFont ( false ) ; super . setText ( strText ) ; } | Set this text component to this text string . This method factors out the description . |
15,626 | public void myFocusLost ( ) { m_bInFocus = false ; String strText = super . getText ( ) ; if ( ( strText == null ) || ( strText . length ( ) == 0 ) ) { if ( m_actionListener != null ) this . removeActionListener ( m_actionListener ) ; this . changeFont ( true ) ; super . setText ( m_strDescription ) ; if ( m_actionListener != null ) this . addActionListener ( m_actionListener ) ; } } | Gained the focus . Need to set the description back if this component is empty . |
15,627 | public void changeFont ( boolean bDescription ) { if ( m_fontNormal == null ) { m_fontNormal = this . getFont ( ) ; m_fontDesc = m_fontNormal . deriveFont ( Font . ITALIC ) ; m_colorNormal = this . getForeground ( ) ; m_colorDesc = Color . gray ; } if ( bDescription ) { this . setFont ( m_fontDesc ) ; this . setForeground ( m_colorDesc ) ; } else { this . setFont ( m_fontNormal ) ; this . setForeground ( m_colorNormal ) ; } } | Change the font depending of whether you are displaying the description or text . |
15,628 | public static boolean validate ( InputStream in ) throws IOException { final Map < String , AbstractDataMarshaller < ? > > marshallerMap = generateMarshallerMap ( false , Collections . EMPTY_LIST ) ; marshallerMap . putAll ( generateMarshallerMap ( false , DEFAULT_MARSHALLERS ) ) ; final GZIPInputStream gzipInputStream = new GZIPInputStream ( in ) ; try { MessageDigestInputStream messageDigestInputStream = new MessageDigestInputStream ( gzipInputStream , CHECKSUM_ALGORITHM ) ; CountingDataInputStream dIn = new CountingDataInputStream ( messageDigestInputStream ) ; checkHeader ( dIn ) ; deSerialize ( dIn , marshallerMap , true , DUMMY_PROGRESS_LISTENER ) ; byte [ ] checksumCalcualted = messageDigestInputStream . getDigest ( ) ; final int checksumAvailable = dIn . read ( ) ; byte [ ] checksumValue = new byte [ CHECKSUM_ALGORITHM_LENGTH ] ; if ( checksumAvailable == - 1 ) { return false ; } int readBytes = dIn . read ( checksumValue ) ; if ( readBytes == CHECKSUM_ALGORITHM_LENGTH ) { return Arrays . equals ( checksumValue , checksumCalcualted ) ; } else { return false ; } } catch ( NoSuchAlgorithmException ex ) { throw new IOException ( "Checksum algorithm not available" , ex ) ; } finally { gzipInputStream . close ( ) ; } } | explicitly validates the given xdata stream against the embedded checksum if there is no checksum or the checksum does not correspond to the data then false is returned . Otherwise true is returned . |
15,629 | private static DataNode marshalObject ( Map < String , AbstractDataMarshaller < ? > > marshallerMap , Object object ) { final Class < ? > clazz = object . getClass ( ) ; final AbstractDataMarshaller < Object > serializer = ( AbstractDataMarshaller < Object > ) marshallerMap . get ( clazz . getCanonicalName ( ) ) ; if ( serializer != null ) { final DataNode node = serializer . marshal ( object ) ; node . setObject ( META_CLASS_NAME , serializer . getDataClassName ( ) ) ; return node ; } return null ; } | wraps an deSerializedObject using the data marshaller for that given deSerializedObject |
15,630 | private static boolean serializeElement ( Object element , Deque < SerializationFrame > stack , DataOutputStream dOut , Map < String , AbstractDataMarshaller < ? > > marshallerMap , Map < SerializedObject , SerializedObject > serializedObjects , SerializedObject testSerializedObject , boolean ignoreMissingMarshallers ) throws IOException { if ( element instanceof List ) { stack . push ( new ListSerializationFrame ( element , ( List < ? > ) element ) ) ; return true ; } else if ( element == null || isPrimitiveOrString ( element ) ) { serializePrimitive ( dOut , element ) ; } else { testSerializedObject . object = element ; if ( serializedObjects . containsKey ( testSerializedObject ) ) { final SerializedObject serializedObject = serializedObjects . get ( testSerializedObject ) ; serializeReference ( serializedObject , dOut ) ; } else { DataNodeSerializationFrame dataNodeFrame ; if ( element instanceof DataNode ) { dataNodeFrame = new DataNodeSerializationFrame ( element , ( DataNode ) element ) ; } else { final DataNode marshalledObject = marshalObject ( marshallerMap , element ) ; if ( marshalledObject != null ) { dataNodeFrame = new DataNodeSerializationFrame ( element , marshalledObject ) ; } else { if ( ! ignoreMissingMarshallers ) { throw new IllegalStateException ( "No serializer defined for class " + element . getClass ( ) . getCanonicalName ( ) ) ; } else { serializePrimitive ( dOut , null ) ; return false ; } } } stack . push ( dataNodeFrame ) ; return true ; } } return false ; } | processes one element and either serializes it directly to the stream or pushes a corresponding frame to the stack . |
15,631 | private static void serialize ( Map < String , AbstractDataMarshaller < ? > > marshallerMap , DataOutputStream dOut , DataNode primaryNode , boolean ignoreMissingMarshallers , ProgressListener progressListener ) throws IOException { final Map < SerializedObject , SerializedObject > serializedObjects = new HashMap < > ( ) ; final Deque < SerializationFrame > stack = new LinkedList < > ( ) ; final DataNodeSerializationFrame primaryDataNodeFrame = new DataNodeSerializationFrame ( null , primaryNode ) ; progressListener . onTotalSteps ( primaryDataNodeFrame . entries . size ( ) ) ; stack . add ( primaryDataNodeFrame ) ; final SerializedObject testSerializedObject = new SerializedObject ( ) ; while ( ! stack . isEmpty ( ) ) { final SerializationFrame frame = stack . peek ( ) ; frame . writeHeader ( dOut ) ; if ( frame . hasNext ( ) ) { while ( frame . hasNext ( ) ) { if ( frame . next ( stack , dOut , marshallerMap , serializedObjects , testSerializedObject , ignoreMissingMarshallers ) ) { if ( frame == primaryDataNodeFrame ) { progressListener . onStep ( ) ; } break ; } if ( frame == primaryDataNodeFrame ) { progressListener . onStep ( ) ; } } } else { stack . pop ( ) ; if ( frame instanceof DataNodeSerializationFrame ) { DataNodeSerializationFrame dataNodeFrame = ( DataNodeSerializationFrame ) frame ; SerializedObject newSerializedObject = new SerializedObject ( ) ; newSerializedObject . object = frame . object ; newSerializedObject . positionInStream = dataNodeFrame . positionInStream ; serializedObjects . put ( newSerializedObject , newSerializedObject ) ; } } } } | actually serializes the data |
15,632 | private static void serializePrimitive ( DataOutputStream dOut , Object primitive ) throws IOException { if ( primitive == null ) { dOut . writeByte ( VAL_NULL ) ; } else { dOut . writeByte ( VAL_ELEMENT ) ; final Class < ? > resolvedObjectClass = primitive . getClass ( ) ; Serializer < Object > serializer = ( Serializer < Object > ) PRIMITIVE_SERIALIZERS_BY_CLASS . get ( resolvedObjectClass ) ; if ( serializer == null ) { throw new IllegalStateException ( "Can't serialize resolved class " + resolvedObjectClass . getCanonicalName ( ) ) ; } dOut . writeByte ( serializer . getSerializerId ( ) ) ; serializer . serialize ( primitive , dOut ) ; } } | serializes a primitive or null |
15,633 | public static void showMessageDialog ( final Component parentComponent , final Object message ) { execute ( new VoidOptionPane ( ) { public void show ( ) { JOptionPane . showMessageDialog ( parentComponent , message ) ; } } ) ; } | Brings up an information - message dialog titled Message . |
15,634 | public JNDIContentRepositoryBuilder withContextProperty ( final String name , final Object value ) { contextProperties . put ( name , value ) ; return this ; } | Adds a new context property to the environment for the JNDI lookup context |
15,635 | public JNDIContentRepositoryBuilder withSecurityPrincipal ( final String principalName , final String credentials ) { contextProperties . put ( Context . SECURITY_PRINCIPAL , principalName ) ; contextProperties . put ( Context . SECURITY_CREDENTIALS , credentials ) ; return this ; } | Sets the context properties for SECURITY_PRINCIPAL and SECURITY_CREDENTIAL to perform the lookup . This method is a convenience for setting the properties SECURITY_PRINCIPAL and SECURITY_CREDENTIAL on the environment . |
15,636 | public void freeRemoteSession ( ) throws RemoteException { try { if ( m_database . getTableCount ( ) == 0 ) m_database . free ( ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } super . freeRemoteSession ( ) ; } | Free the objects . This method is called from the remote client and frees this session . |
15,637 | public boolean fileMatchesRules ( File file ) { try { if ( file . exists ( ) ) { if ( includeFilesContainingText . length == 0 && excludeFilesContainingText . length == 0 ) { return fileMatchesRules ( getComparableFileName ( file ) ) ; } else { return fileMatchesRules ( getComparableFileName ( file ) , FileSupport . getTextFileFromFS ( file ) ) ; } } } catch ( IOException ioe ) { } return false ; } | Checks if file matches rules . |
15,638 | public static final FileSystem newFileSystem ( Path path , Map < String , ? > env ) throws IOException { return getDefault ( ) . provider ( ) . newFileSystem ( path , env ) ; } | Constructs a new FileSystem to access the contents of a file as a file system . |
15,639 | public void process ( ) throws CmdLineException { ProcessingContext context = new ProcessingContext ( ) ; for ( String arg : this . args ) { if ( arg != null && ! context . processPendingOptionAction ( arg ) && ! context . processOptionAction ( arg , this . optionActions ) && ! context . processSwitchAction ( arg , this . switchActions ) ) { Consumer < String > defaultAction = ( isActionArg ( arg ) ? this . unknownAction : this . unnamedAction ) ; if ( defaultAction != null ) { try { defaultAction . accept ( arg ) ; } catch ( RuntimeException e ) { throw new CmdLineException ( this , arg , e ) ; } } else { throw new CmdLineException ( this , arg ) ; } } } context . verifyNoPendingOptionAction ( ) ; } | Processes the command line and invoke the correspond actions . |
15,640 | public static final DenseMatrix64F get141Matrix ( int order ) { if ( order < 2 ) { throw new IllegalArgumentException ( "order has to be at least 2 for 1 4 1 matrix" ) ; } double [ ] data = new double [ order * order ] ; for ( int row = 0 ; row < order ; row ++ ) { for ( int col = 0 ; col < order ; col ++ ) { int index = row * order + col ; if ( row == col ) { data [ index ] = 4 ; } else { if ( Math . abs ( row - col ) == 1 ) { data [ index ] = 1 ; } else { data [ index ] = 0 ; } } } } return new DenseMatrix64F ( order , order , true , data ) ; } | Creates a 1 4 1 matrix eg . |4 1 0| |1 4 1| |0 1 4| |
15,641 | public double get ( double x , double epsilon ) { Point nearest = getNearest ( x , epsilon ) ; return nearest . getY ( ) ; } | Returns y for x . This is convenient method . Use getNearest to get exact evaluated point . |
15,642 | public static < S > S loadService ( Class < S > serviceInterface , ClassLoader classLoader ) { Iterator < S > services = ServiceLoader . load ( serviceInterface , classLoader ) . iterator ( ) ; if ( services . hasNext ( ) ) { return services . next ( ) ; } try { String serviceDescriptor = getResourceAsString ( "/services/" + serviceInterface . getName ( ) ) ; return newInstance ( serviceDescriptor ) ; } catch ( Throwable e ) { } return null ; } | Load service of requested interface using given class loader . Throws exception if service implementation not found on run - time . |
15,643 | public static < S > S loadOptionalService ( Class < S > serviceInterface ) { S service = null ; ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( classLoader != null ) { service = loadService ( serviceInterface , classLoader ) ; } if ( service == null ) { service = loadService ( serviceInterface , Classes . class . getClassLoader ( ) ) ; } return service ; } | Load service of requested interface returning null if service provider not found . Caller should test returned value and take appropriate actions . |
15,644 | public static Class < ? > [ ] getParameterTypes ( Object ... arguments ) { Class < ? > [ ] types = new Class < ? > [ arguments . length ] ; for ( int i = 0 ; i < arguments . length ; i ++ ) { Object argument = arguments [ i ] ; if ( argument == null ) { types [ i ] = Object . class ; continue ; } if ( ! ( argument instanceof VarArgs ) ) { types [ i ] = argument . getClass ( ) ; if ( types [ i ] . isAnonymousClass ( ) ) { Class < ? > [ ] interfaces = types [ i ] . getInterfaces ( ) ; Class < ? > superclass = interfaces . length > 0 ? interfaces [ 0 ] : null ; if ( superclass == null ) { superclass = types [ i ] . getSuperclass ( ) ; } types [ i ] = superclass ; } continue ; } if ( i != arguments . length - 1 ) { throw new BugError ( "Variable arguments must be the last in arguments list." ) ; } @ SuppressWarnings ( "unchecked" ) VarArgs < Object > varArgs = ( VarArgs < Object > ) argument ; int index = arguments . length - 1 ; types [ index ] = varArgs . getType ( ) ; arguments [ index ] = varArgs . getArguments ( ) ; } return types ; } | Get method formal parameter types inferred from actual invocation arguments . This utility is a helper for method discovery when have access to the actual invocation argument but not the formal parameter types list declared by method signature . |
15,645 | private static Object invoke ( Object object , Method method , Object ... arguments ) throws Exception { Throwable cause = null ; try { method . setAccessible ( true ) ; return method . invoke ( object instanceof Class < ? > ? null : object , arguments ) ; } catch ( IllegalAccessException e ) { throw new BugError ( e ) ; } catch ( InvocationTargetException e ) { cause = e . getCause ( ) ; if ( cause instanceof Exception ) { throw ( Exception ) cause ; } if ( cause instanceof AssertionError ) { throw ( AssertionError ) cause ; } } throw new BugError ( "Method |%s| invocation fails: %s" , method , cause ) ; } | Do the actual reflexive method invocation . |
15,646 | public static String getCallerMethod ( ) { StackTraceElement [ ] stackTrace = Thread . currentThread ( ) . getStackTrace ( ) ; if ( stackTrace . length == 0 ) { return "unknown" ; } final StackTraceElement e = stackTrace [ 0 ] ; return Strings . concat ( e . getClassName ( ) , '#' , e . getMethodName ( ) , ':' , e . getLineNumber ( ) ) ; } | Get source line for the caller method . |
15,647 | public static Field getOptionalField ( Class < ? > clazz , String fieldName ) { try { Field field = clazz . getDeclaredField ( fieldName ) ; field . setAccessible ( true ) ; return field ; } catch ( NoSuchFieldException expectable ) { } catch ( SecurityException e ) { throw new BugError ( e ) ; } return null ; } | Get class field or null if not found . Try to get named class field and returns null if not found ; this method does not throw any exception . |
15,648 | public static < T > T getOptionalFieldValue ( Object object , String fieldName , Class < T > ... fieldType ) { Class < ? > clazz = null ; if ( object instanceof Class < ? > ) { clazz = ( Class < ? > ) object ; object = null ; } else { clazz = object . getClass ( ) ; } return getFieldValue ( object , clazz , fieldName , fieldType . length == 1 ? fieldType [ 0 ] : null , true ) ; } | Get optional field value from instance or class . Retrieve named field value from given instance or class ; if field is missing return null . Note that this method does not throw exceptions . Also if optional desired field type is present and named field is of different type returns null . |
15,649 | public static < T > T getFieldValue ( Object object , Class < ? > clazz , String fieldName ) { return getFieldValue ( object , clazz , fieldName , null , false ) ; } | Get instance field value declared into superclass . Retrieve inherited field value from given instance throwing exception if field is not declared into superclass . |
15,650 | public static void setFieldValue ( Object object , Class < ? > clazz , String fieldName , Object value ) { Field field = getField ( clazz , fieldName ) ; if ( object == null ^ Modifier . isStatic ( field . getModifiers ( ) ) ) { throw new BugError ( "Cannot access static field |%s| from instance |%s|." , fieldName , clazz ) ; } setFieldValue ( object , field , value ) ; } | Set instance field declared into superclass . Try to set field value throwing exception if field is not declared into superclass ; if field is static object instance should be null . |
15,651 | private static URL getResource ( String name , ClassLoader [ ] classLoaders ) { for ( ClassLoader classLoader : classLoaders ) { URL url = classLoader . getResource ( name ) ; if ( url == null ) { url = classLoader . getResource ( '/' + name ) ; } if ( url != null ) { return url ; } } return null ; } | Get named resource URL from a list of class loaders . Traverses class loaders in given order searching for requested resource . Return first resource found or null if none found . |
15,652 | private static InputStream getResourceAsStream ( String name , ClassLoader [ ] classLoaders ) { for ( ClassLoader classLoader : classLoaders ) { InputStream stream = classLoader . getResourceAsStream ( name ) ; if ( stream == null ) { stream = classLoader . getResourceAsStream ( '/' + name ) ; } if ( stream != null ) { return stream ; } } return null ; } | Get named resource input stream from a list of class loaders . Traverses class loaders in given order searching for requested resource . Return first resource found or null if none found . |
15,653 | @ SuppressWarnings ( "unchecked" ) public static < T > T newInstance ( String className , Object ... arguments ) { return ( T ) newInstance ( Classes . forName ( className ) , arguments ) ; } | Create a new instance . Handy utility for hidden classes creation . Constructor accepting given arguments if any must exists . |
15,654 | private static NoSuchBeingException missingConstructorException ( Class < ? > clazz , Object ... arguments ) { Type [ ] types = new Type [ arguments . length ] ; for ( int i = 0 ; i < arguments . length ; ++ i ) { types [ i ] = arguments [ i ] . getClass ( ) ; } return new NoSuchBeingException ( "Missing constructor(%s) for |%s|." , Arrays . toString ( types ) , clazz ) ; } | Helper for missing constructor exception . |
15,655 | @ SuppressWarnings ( "unchecked" ) public static < T extends List < ? > > Class < T > getListDefaultImplementation ( Type listType ) { return ( Class < T > ) getImplementation ( LISTS , listType ) ; } | Get default implementation for requested list type . |
15,656 | public static Class < ? > getImplementation ( Map < Class < ? > , Class < ? > > implementationsRegistry , Type interfaceType ) { Class < ? > implementation = implementationsRegistry . get ( interfaceType ) ; if ( implementation == null ) { throw new BugError ( "No registered implementation for type |%s|." , interfaceType ) ; } return implementation ; } | Lookup implementation into given registry throwing exception if not found . |
15,657 | @ SuppressWarnings ( "unchecked" ) private static < T > T newRegisteredInstance ( Map < Class < ? > , Class < ? > > implementationsRegistry , Type interfaceType ) throws BugError { Class < ? > implementation = getImplementation ( implementationsRegistry , interfaceType ) ; try { return ( T ) implementation . newInstance ( ) ; } catch ( IllegalAccessException e ) { throw new BugError ( e ) ; } catch ( InstantiationException e ) { throw new BugError ( e ) ; } } | Lookup implementation for requested interface into given registry and return a new instance of it . |
15,658 | @ SuppressWarnings ( "unchecked" ) public static < T extends Map < ? , ? > > T newMap ( Type type ) { Class < ? > implementation = MAPS . get ( type ) ; if ( implementation == null ) { throw new BugError ( "No registered implementation for map |%s|." , type ) ; } return ( T ) newInstance ( implementation ) ; } | Create new map of given type . |
15,659 | public static Class < ? > forType ( Type type ) { if ( type instanceof Class ) { return ( Class < ? > ) type ; } if ( type instanceof ParameterizedType ) { return forType ( ( ( ParameterizedType ) type ) . getRawType ( ) ) ; } if ( ! ( type instanceof GenericArrayType ) ) { return null ; } Type componentType = ( ( GenericArrayType ) type ) . getGenericComponentType ( ) ; Class < ? > componentClass = forType ( componentType ) ; return componentClass != null ? Array . newInstance ( componentClass , 0 ) . getClass ( ) : null ; } | Get the underlying class for a type or null if the type is a variable type . |
15,660 | public synchronized boolean removeLock ( Object bookmark , SessionInfo sessionInfo ) { Utility . getLogger ( ) . info ( "Unlock: " + bookmark + ", Session: " + sessionInfo . m_iSessionID + " success: " + sessionInfo . equals ( this . get ( bookmark ) ) ) ; if ( ! sessionInfo . equals ( this . get ( bookmark ) ) ) return false ; if ( this . getWaitlist ( bookmark , false ) != null ) if ( this . getWaitlist ( bookmark , false ) . size ( ) > 0 ) { SessionInfo sessionInfoToUnlock = this . getWaitlist ( bookmark , true ) . get ( 0 ) ; if ( sessionInfoToUnlock == null ) return false ; synchronized ( sessionInfoToUnlock ) { if ( sessionInfoToUnlock != this . popWaitlistSession ( bookmark ) ) return false ; boolean bSuccess = sessionInfo . equals ( this . remove ( bookmark ) ) ; if ( bSuccess ) sessionInfoToUnlock . notify ( ) ; return bSuccess ; } } return sessionInfo . equals ( this . remove ( bookmark ) ) ; } | Remove this bookmark from the lock list . |
15,661 | public synchronized boolean unlockAll ( SessionInfo sessionInfo ) { Utility . getLogger ( ) . info ( "Unlock all, Session: " + sessionInfo . m_iSessionID ) ; for ( Object bookmark : this . keySet ( ) ) { SessionInfo thisSession = ( SessionInfo ) this . get ( bookmark ) ; if ( sessionInfo . equals ( thisSession ) ) this . removeLock ( bookmark , thisSession ) ; } return true ; } | Unlock all the locks for this session . |
15,662 | @ SuppressWarnings ( "unchecked" ) public < T > T proxy ( final Object delegate , Class < ? > [ ] interfaces ) { return ( T ) Proxy . newProxyInstance ( delegate . getClass ( ) . getClassLoader ( ) , interfaces , new ProxyInvocationHandler ( delegate ) ) ; } | Construct a proxy for which each method is invoked by the execution server . |
15,663 | public void printIt ( Record recLayout , PrintWriter out , int iIndents , String strEnd ) { String strName = recLayout . getField ( Layout . NAME ) . toString ( ) ; String strType = recLayout . getField ( Layout . TYPE ) . toString ( ) ; String strValue = recLayout . getField ( Layout . FIELD_VALUE ) . toString ( ) ; String strReturns = recLayout . getField ( Layout . RETURNS_VALUE ) . toString ( ) ; String strMax = recLayout . getField ( Layout . MAXIMUM ) . toString ( ) ; String strDescription = recLayout . getField ( Layout . COMMENT ) . toString ( ) ; boolean bLoop = false ; if ( ( strType . equalsIgnoreCase ( "module" ) ) || ( strType . equalsIgnoreCase ( "enum" ) ) || ( strType . equalsIgnoreCase ( "struct" ) ) || ( strType . equalsIgnoreCase ( "interface" ) ) ) bLoop = true ; if ( bLoop ) { this . println ( out , strType + " " + strName , strDescription , iIndents , "" ) ; String strEndLoop = ";" ; if ( strType . equalsIgnoreCase ( "enum" ) ) strEndLoop = null ; this . println ( out , "{" , null , iIndents , "" ) ; Layout recLayoutLoop = new Layout ( recLayout . findRecordOwner ( ) ) ; recLayoutLoop . setKeyArea ( Layout . PARENT_FOLDER_ID_KEY ) ; recLayoutLoop . addListener ( new SubFileFilter ( recLayout ) ) ; try { boolean bFirstLoop = true ; while ( recLayoutLoop . hasNext ( ) ) { if ( strEndLoop == null ) if ( ! bFirstLoop ) this . println ( out , "," , null , 0 , "" ) ; recLayoutLoop . next ( ) ; this . printIt ( recLayoutLoop , out , iIndents + 1 , strEndLoop ) ; bFirstLoop = false ; } if ( strEndLoop == null ) if ( ! bFirstLoop ) this . println ( out , "" , null , 0 , "" ) ; recLayoutLoop . free ( ) ; recLayoutLoop = null ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } this . println ( out , "}" , null , iIndents , strEnd ) ; } else { if ( strType . equalsIgnoreCase ( "collection" ) ) strType = "typedef sequence<" + strValue + ">" ; else if ( strType . equalsIgnoreCase ( "method" ) ) { strType = strReturns + " " ; strName += "(" + strValue + ")" ; } else if ( strType . equalsIgnoreCase ( "comment" ) ) strType = "//\t" + strType ; else if ( strValue . length ( ) > 0 ) strName += " = " + strValue ; this . println ( out , strType + " " + strName , strDescription , iIndents , strEnd ) ; } } | PrintIt Method . |
15,664 | public void println ( PrintWriter out , String string , String strDescription , int iIndents , String strEnd ) { while ( iIndents -- > 0 ) out . print ( "\t" ) ; if ( strEnd != null ) if ( ( strDescription != null ) && ( strDescription . length ( ) > 0 ) ) strEnd = strEnd + "\t\t// " + strDescription ; if ( strEnd != null ) out . println ( string + strEnd ) ; else out . print ( string ) ; } | Println Method . |
15,665 | public void addService ( TDefinitions descriptionType ) { String interfacens ; String interfacename ; QName qname ; String name ; if ( soapFactory == null ) soapFactory = new org . xmlsoap . schemas . wsdl . soap . ObjectFactory ( ) ; TService service = wsdlFactory . createTService ( ) ; descriptionType . getAnyTopLevelOptionalElement ( ) . add ( service ) ; name = this . getControlProperty ( MessageControl . SERVICE_NAME ) ; service . setName ( name ) ; interfacens = this . getNamespace ( ) ; interfacename = this . getControlProperty ( MessageControl . BINDING_NAME ) ; qname = new QName ( interfacens , interfacename ) ; TPort port = wsdlFactory . createTPort ( ) ; service . getPort ( ) . add ( port ) ; port . setName ( name + "Port" ) ; port . setBinding ( qname ) ; org . xmlsoap . schemas . wsdl . soap . TAddress tAddress = soapFactory . createTAddress ( ) ; port . getAny ( ) . add ( soapFactory . createAddress ( tAddress ) ) ; String address = this . getURIValue ( this . getRecord ( MessageControl . MESSAGE_CONTROL_FILE ) . getField ( MessageControl . WEB_SERVICES_SERVER ) . toString ( ) ) ; tAddress . setLocation ( address ) ; } | AddService Method . |
15,666 | public void addBindingsType ( TDefinitions definitions ) { String interfacens ; String interfacename ; QName qname ; String value ; String name ; if ( soapFactory == null ) soapFactory = new org . xmlsoap . schemas . wsdl . soap . ObjectFactory ( ) ; TBinding binding = wsdlFactory . createTBinding ( ) ; definitions . getAnyTopLevelOptionalElement ( ) . add ( binding ) ; name = this . getControlProperty ( MessageControl . BINDING_NAME ) ; binding . setName ( name ) ; interfacens = this . getNamespace ( ) ; interfacename = this . getControlProperty ( MessageControl . INTERFACE_NAME ) ; qname = new QName ( interfacens , interfacename ) ; binding . setType ( qname ) ; org . xmlsoap . schemas . wsdl . soap . TBinding tBinding = soapFactory . createTBinding ( ) ; binding . getAny ( ) . add ( soapFactory . createBinding ( tBinding ) ) ; interfacens = this . getControlProperty ( SOAP_URI ) ; tBinding . setTransport ( interfacens ) ; tBinding . setStyle ( org . xmlsoap . schemas . wsdl . soap . TStyleChoice . DOCUMENT ) ; this . addBindingOperationTypes ( binding ) ; } | AddBindingsType Method . |
15,667 | public void addPort ( TDefinitions description ) { TPortType interfaceType = wsdlFactory . createTPortType ( ) ; description . getAnyTopLevelOptionalElement ( ) . add ( interfaceType ) ; String interfaceName = this . getControlProperty ( MessageControl . INTERFACE_NAME ) ; interfaceType . setName ( interfaceName ) ; this . addInterfaceOperationTypes ( interfaceType ) ; } | AddPort Method . |
15,668 | public void addMessageType ( String version , TDefinitions descriptionType , MessageProcessInfo recMessageProcessInfo ) { MessageInfo recMessageInfo = this . getMessageIn ( recMessageProcessInfo ) ; if ( recMessageInfo != null ) { String name = this . fixName ( recMessageInfo . getField ( MessageInfo . DESCRIPTION ) . toString ( ) ) ; if ( this . isNewType ( name ) ) { this . addMessage ( version , descriptionType , recMessageInfo ) ; } } recMessageInfo = this . getMessageOut ( recMessageProcessInfo ) ; if ( recMessageInfo != null ) { String name = this . fixName ( recMessageInfo . getField ( MessageInfo . DESCRIPTION ) . toString ( ) ) ; if ( this . isNewType ( name ) ) { this . addMessage ( version , descriptionType , recMessageInfo ) ; } } } | AddMessageType Method . |
15,669 | public void addMessage ( String version , TDefinitions descriptionType , MessageInfo recMessageInfo ) { TMessage messageType = wsdlFactory . createTMessage ( ) ; descriptionType . getAnyTopLevelOptionalElement ( ) . add ( messageType ) ; String strMessageName = this . fixName ( recMessageInfo . getField ( MessageInfo . DESCRIPTION ) . toString ( ) ) ; messageType . setName ( strMessageName ) ; TPart TPart = wsdlFactory . createTPart ( ) ; messageType . getPart ( ) . add ( TPart ) ; TPart . setName ( strMessageName ) ; String interfacens = this . getNamespace ( ) ; String interfacename = this . fixName ( recMessageInfo . getField ( MessageInfo . CODE ) . toString ( ) ) ; QName qname = new QName ( interfacens , interfacename ) ; TPart . setElement ( qname ) ; } | AddMessage Method . |
15,670 | public boolean isCellEditable ( int iRowIndex , int iColumnIndex ) { FieldList fieldList = this . makeRowCurrent ( iRowIndex , false ) ; if ( fieldList != null ) if ( fieldList . getEditMode ( ) == Constants . EDIT_NONE ) if ( ( m_iLastRecord == RECORD_UNKNOWN ) || ( iRowIndex != m_iLastRecord + 1 ) ) return false ; return true ; } | Is this cell editable . |
15,671 | public void setValueAt ( Object aValue , int iRowIndex , int iColumnIndex ) { try { this . updateIfNewRow ( iRowIndex ) ; boolean bPhysicallyLockRecord = true ; if ( this . getFieldInfo ( iColumnIndex ) == null ) bPhysicallyLockRecord = false ; FieldList fieldList = this . makeRowCurrent ( iRowIndex , bPhysicallyLockRecord ) ; boolean bFieldChanged = this . setColumnValue ( iColumnIndex , aValue , Constants . DISPLAY , Constants . SCREEN_MOVE ) ; if ( bFieldChanged ) { this . cacheCurrentLockedData ( iRowIndex , fieldList ) ; this . fireTableRowsUpdated ( iRowIndex , iRowIndex ) ; } int iRowCount = this . getRowCount ( false ) ; if ( ( this . isAppending ( ) ) && ( iRowIndex == m_iLastRecord + 1 ) && ( iRowCount == m_iLastRecord + 1 ) && ( m_iLastRecord != RECORD_UNKNOWN ) ) { bFieldChanged = this . isRecordChanged ( ) ; if ( ( fieldList . getEditMode ( ) == Constants . EDIT_CURRENT ) || ( fieldList . getEditMode ( ) == Constants . EDIT_IN_PROGRESS ) ) { m_iLastRecord ++ ; bFieldChanged = true ; } if ( bFieldChanged ) { this . setRowCount ( iRowCount + 1 ) ; this . fireTableRowsInserted ( iRowCount + 1 , iRowCount + 1 ) ; } } if ( this . getSelectedRow ( ) != iRowIndex ) this . updateIfNewRow ( this . getSelectedRow ( ) ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } } | Set the value at this location . |
15,672 | public BaseBuffer cacheCurrentLockedData ( int iRowIndex , FieldList fieldList ) { int iColumnCount = this . getColumnCount ( ) ; if ( ( m_buffCurrentLockedData == null ) || ( m_iCurrentLockedRowIndex != iRowIndex ) ) m_buffCurrentLockedData = new VectorBuffer ( null , BaseBuffer . ALL_FIELDS ) ; m_buffCurrentLockedData . fieldsToBuffer ( fieldList ) ; for ( int i = 0 ; i < iColumnCount ; i ++ ) { Field field = null ; if ( this . getFieldInfo ( i ) != null ) field = this . getFieldInfo ( i ) . getField ( ) ; if ( ( field != null ) && ( field . getRecord ( ) != fieldList ) ) m_buffCurrentLockedData . addNextString ( field . toString ( ) ) ; } m_iCurrentLockedRowIndex = iRowIndex ; return m_buffCurrentLockedData ; } | Get the array of changed values for the current row . I use a standard field buffer and append all the screen items which are not included in the field . |
15,673 | public void restoreCurrentRecord ( FieldList fieldList ) { m_buffCurrentLockedData . bufferToFields ( fieldList , Constants . DONT_DISPLAY , Constants . READ_MOVE ) ; int iColumnCount = this . getColumnCount ( ) ; for ( int i = 0 ; i < iColumnCount ; i ++ ) { Field field = null ; if ( this . getFieldInfo ( i ) != null ) field = this . getFieldInfo ( i ) . getField ( ) ; if ( ( field != null ) && ( field . getRecord ( ) != fieldList ) ) field . setString ( m_buffCurrentLockedData . getNextString ( ) , Constants . DONT_DISPLAY , Constants . READ_MOVE ) ; } } | Restore this fieldlist with items from the input cache . I use a standard field buffer and append all the screen items which are not included in the field . |
15,674 | public boolean setColumnValue ( int iColumnIndex , Object value , boolean bDisplay , int iMoveMode ) { Convert fieldInfo = this . getFieldInfo ( iColumnIndex ) ; if ( fieldInfo != null ) { Object dataBefore = fieldInfo . getData ( ) ; if ( ! ( value instanceof String ) ) fieldInfo . setData ( value , bDisplay , iMoveMode ) ; else fieldInfo . setString ( ( String ) value , bDisplay , iMoveMode ) ; Object dataAfter = fieldInfo . getData ( ) ; if ( dataBefore == null ) return ( dataAfter != null ) ; else return ( ! dataBefore . equals ( dataAfter ) ) ; } return false ; } | Set the value at the field at the column . Since this is only used by the restore current record method pass dont_display and read_move when you set the data . This is NOT a TableModel override this is my method . |
15,675 | public Object getValueAt ( int iRowIndex , int iColumnIndex ) { int iEditMode = Constants . EDIT_NONE ; try { if ( iRowIndex >= 0 ) { FieldList fieldList = this . makeRowCurrent ( iRowIndex , false ) ; if ( fieldList != null ) iEditMode = fieldList . getEditMode ( ) ; } } catch ( Exception ex ) { ex . printStackTrace ( ) ; } return this . getColumnValue ( iColumnIndex , iEditMode ) ; } | Get the value at this location . |
15,676 | public Object getColumnValue ( int iColumnIndex , int iEditMode ) { Convert fieldInfo = this . getFieldInfo ( iColumnIndex ) ; if ( fieldInfo != null ) return fieldInfo . getString ( ) ; return Constants . BLANK ; } | Get the value of the field at the column . This is NOT a TableModel override this is my method . |
15,677 | public void removeTableModelListener ( TableModelListener l ) { try { this . updateIfNewRow ( - 1 ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } super . removeTableModelListener ( l ) ; } | This is called when the model is no longer need by the JTable so update any current record . |
15,678 | public void resetTheModel ( ) { this . setRowCount ( START_ROWS ) ; m_iLastRecord = RECORD_UNKNOWN ; m_iLargestValidRecord = - 1 ; this . setCurrentRow ( - 1 ) ; m_iCurrentLockedRowIndex = - 1 ; this . fireTableChanged ( new TableModelEvent ( this ) ) ; } | The underlying query changed reset the model . |
15,679 | public void updateIfNewRow ( int iRowIndex ) throws DBException { if ( ( m_iCurrentLockedRowIndex != - 1 ) && ( m_iCurrentLockedRowIndex != iRowIndex ) ) if ( m_buffCurrentLockedData != null ) { { FieldList fieldList = this . makeRowCurrent ( m_iCurrentLockedRowIndex , false ) ; if ( this . isRecordChanged ( ) ) { synchronized ( this ) { DBException ex = null ; fieldList = this . makeRowCurrent ( m_iCurrentLockedRowIndex , true ) ; if ( ( this . isAppending ( ) ) && ( ( m_iCurrentLockedRowIndex == m_iLastRecord + 1 ) && ( m_iLastRecord != RECORD_UNKNOWN ) ) ) { m_table . add ( fieldList ) ; this . setCurrentRow ( - 1 ) ; if ( m_iLastRecord != RECORD_UNKNOWN ) m_iLastRecord ++ ; } else { if ( ( fieldList . getEditMode ( ) == Constants . EDIT_CURRENT ) || ( fieldList . getEditMode ( ) == Constants . EDIT_IN_PROGRESS ) ) { try { m_table . set ( fieldList ) ; } catch ( DBException e ) { ex = e ; } } this . setCurrentRow ( - 1 ) ; } m_iCurrentLockedRowIndex = - 1 ; m_buffCurrentLockedData = null ; if ( ex != null ) throw ex ; } } } } } | Update the currently updated record if the row is different from this row . |
15,680 | public void addMouseListenerToHeaderInTable ( JTable table ) { table . setColumnSelectionAllowed ( false ) ; MouseListener mouseListener = new MouseAdapter ( ) { public void mouseClicked ( MouseEvent e ) { if ( e . getSource ( ) instanceof JTableHeader ) { JTableHeader tableHeader = ( JTableHeader ) e . getSource ( ) ; TableColumnModel columnModel = tableHeader . getColumnModel ( ) ; int viewColumn = columnModel . getColumnIndexAtX ( e . getX ( ) ) ; int column = tableHeader . getTable ( ) . convertColumnIndexToModel ( viewColumn ) ; if ( e . getClickCount ( ) == 1 && column != - 1 ) { boolean order = Constants . ASCENDING ; if ( ( e . getModifiers ( ) & InputEvent . SHIFT_MASK ) != 0 ) order = ! order ; if ( ! ( tableHeader . getDefaultRenderer ( ) instanceof SortableHeaderRenderer ) ) tableHeader . setDefaultRenderer ( new SortableHeaderRenderer ( tableHeader . getDefaultRenderer ( ) ) ) ; if ( ( ( ( SortableHeaderRenderer ) tableHeader . getDefaultRenderer ( ) ) . getSortedByColumn ( ) == viewColumn ) && ( ( ( SortableHeaderRenderer ) tableHeader . getDefaultRenderer ( ) ) . getSortedOrder ( ) == order ) ) order = ! order ; column = columnToFieldColumn ( column ) ; boolean bSuccess = sortByColumn ( column , order ) ; if ( bSuccess ) setSortedByColumn ( tableHeader , viewColumn , order ) ; } } } } ; table . getTableHeader ( ) . addMouseListener ( mouseListener ) ; } | There is no - where else to put this . Add a mouse listener to the Table to trigger a table sort when a column heading is clicked in the JTable . |
15,681 | public void setSortedByColumn ( JTableHeader tableHeader , int iViewColumn , boolean bOrder ) { if ( ! ( tableHeader . getDefaultRenderer ( ) instanceof SortableHeaderRenderer ) ) tableHeader . setDefaultRenderer ( new SortableHeaderRenderer ( tableHeader . getDefaultRenderer ( ) ) ) ; ( ( SortableHeaderRenderer ) tableHeader . getDefaultRenderer ( ) ) . setSortedByColumn ( tableHeader , iViewColumn , bOrder ) ; } | Change the tableheader to display this sort column and order . |
15,682 | public boolean displayError ( Exception ex , Component panel ) { if ( panel != null ) { BaseApplet baseApplet = null ; if ( panel instanceof BaseApplet ) baseApplet = ( BaseApplet ) panel ; else { while ( ( panel = panel . getParent ( ) ) != null ) { if ( panel instanceof org . jbundle . thin . base . screen . JBasePanel ) { baseApplet = ( ( org . jbundle . thin . base . screen . JBasePanel ) panel ) . getBaseApplet ( ) ; break ; } } } if ( baseApplet != null ) { baseApplet . setStatusText ( ex . getMessage ( ) , Constants . WARNING ) ; if ( ex instanceof DBException ) return true ; } } return false ; } | Displayed this error code . |
15,683 | public SessionFactory provide ( ) { logger . trace ( "Creating hibernate session factory." ) ; SessionFactory factory = new MetadataSources ( serviceRegistry ) . buildMetadata ( ) . buildSessionFactory ( ) ; injectEventListeners ( ( ( SessionFactoryImpl ) factory ) . getServiceRegistry ( ) ) ; return factory ; } | Provide a singleton instance of the hibernate session factory . |
15,684 | public void dispose ( final SessionFactory sessionFactory ) { if ( sessionFactory != null && ! sessionFactory . isClosed ( ) ) { logger . info ( "Disposing of hibernate session factory." ) ; sessionFactory . close ( ) ; } } | Dispose of the hibernate session . |
15,685 | private void injectEventListeners ( final ServiceRegistry registry ) { EventListenerRegistry eventRegistry = registry . getService ( EventListenerRegistry . class ) ; List < PostInsertEventListener > postInsertEvents = locator . getAllServices ( PostInsertEventListener . class ) ; for ( PostInsertEventListener piEventListener : postInsertEvents ) { logger . trace ( "Registering PostInsert: " + piEventListener . getClass ( ) . getCanonicalName ( ) ) ; eventRegistry . appendListeners ( EventType . POST_INSERT , piEventListener ) ; } List < PostUpdateEventListener > postUpdateEvents = locator . getAllServices ( PostUpdateEventListener . class ) ; for ( PostUpdateEventListener puEventListener : postUpdateEvents ) { logger . trace ( "Registering PostUpdate: " + puEventListener . getClass ( ) . getCanonicalName ( ) ) ; eventRegistry . appendListeners ( EventType . POST_UPDATE , puEventListener ) ; } List < PostDeleteEventListener > postDeleteEvents = locator . getAllServices ( PostDeleteEventListener . class ) ; for ( PostDeleteEventListener pdEventListener : postDeleteEvents ) { logger . trace ( "Registering PostDelete: " + pdEventListener . getClass ( ) . getCanonicalName ( ) ) ; eventRegistry . appendListeners ( EventType . POST_DELETE , pdEventListener ) ; } List < PreInsertEventListener > preInsertEvents = locator . getAllServices ( PreInsertEventListener . class ) ; for ( PreInsertEventListener piEventListener : preInsertEvents ) { logger . trace ( "Registering PreInsert: " + piEventListener . getClass ( ) . getCanonicalName ( ) ) ; eventRegistry . appendListeners ( EventType . PRE_INSERT , piEventListener ) ; } List < PreUpdateEventListener > preUpdateEvents = locator . getAllServices ( PreUpdateEventListener . class ) ; for ( PreUpdateEventListener puEventListener : preUpdateEvents ) { logger . trace ( "Registering PreUpdate: " + puEventListener . getClass ( ) . getCanonicalName ( ) ) ; eventRegistry . appendListeners ( EventType . PRE_UPDATE , puEventListener ) ; } List < PreDeleteEventListener > preDeleteEvents = locator . getAllServices ( PreDeleteEventListener . class ) ; for ( PreDeleteEventListener pdEventListener : preDeleteEvents ) { logger . trace ( "Registering PreDelete: " + pdEventListener . getClass ( ) . getCanonicalName ( ) ) ; eventRegistry . appendListeners ( EventType . PRE_DELETE , pdEventListener ) ; } List < PostCommitInsertEventListener > pciEvents = locator . getAllServices ( PostCommitInsertEventListener . class ) ; for ( PostCommitInsertEventListener cpiEventListener : pciEvents ) { logger . trace ( "Registering PostCommitInsert: " + cpiEventListener . getClass ( ) . getCanonicalName ( ) ) ; eventRegistry . appendListeners ( EventType . POST_COMMIT_INSERT , cpiEventListener ) ; } List < PostCommitUpdateEventListener > pcuEvents = locator . getAllServices ( PostCommitUpdateEventListener . class ) ; for ( PostCommitUpdateEventListener cpuEventListener : pcuEvents ) { logger . trace ( "Registering PostCommitUpdate: " + cpuEventListener . getClass ( ) . getCanonicalName ( ) ) ; eventRegistry . appendListeners ( EventType . POST_COMMIT_UPDATE , cpuEventListener ) ; } List < PostCommitDeleteEventListener > pcdEvents = locator . getAllServices ( PostCommitDeleteEventListener . class ) ; for ( PostCommitDeleteEventListener cpdEventListener : pcdEvents ) { logger . trace ( "Registering PostCommitDelete: " + cpdEventListener . getClass ( ) . getCanonicalName ( ) ) ; eventRegistry . appendListeners ( EventType . POST_COMMIT_DELETE , cpdEventListener ) ; } } | This method automatically adds discovered hibernate event listeners into the hibernate service registry . |
15,686 | private void checkDescriptionVersion ( final Issue pIssue ) throws IssueParseException { final Matcher m = DESCRIPTION_VERSION_PATTERN . matcher ( pIssue . getDescription ( ) ) ; final int version ; if ( m . find ( ) ) { version = Integer . parseInt ( m . group ( 1 ) ) ; } else { version = 1 ; } if ( IssueDescriptionUtils . DESCRIPTION_VERSION != version ) { throw new IssueParseException ( String . format ( "Issue #%s has unsupported description: %d. Expected version %d " , pIssue . getId ( ) , version , IssueDescriptionUtils . DESCRIPTION_VERSION ) ) ; } } | Checks the description version tag . |
15,687 | private String getStacktraceMD5 ( final Issue pIssue ) throws IssueParseException { final int stackCfId = ConfigurationManager . getInstance ( ) . CHILIPROJECT_STACKTRACE_MD5_CF_ID ; final Predicate findStacktraceMD5 = new CustomFieldIdPredicate ( stackCfId ) ; final CustomField field = ( CustomField ) CollectionUtils . find ( pIssue . getCustomFields ( ) , findStacktraceMD5 ) ; if ( null == field ) { throw new IssueParseException ( String . format ( "Issue %d doesn't contains a custom_field id=%d" , pIssue . getId ( ) , stackCfId ) ) ; } return field . getValue ( ) ; } | Extracts the stacktrace MD5 custom field value from the issue . |
15,688 | private String parseStacktrace ( final String pDescription , final String pStacktraceMD5 ) throws IssueParseException { String stacktrace = null ; final String start = "<pre class=\"javastacktrace\">" ; final String qStart = Pattern . quote ( start ) ; final String end = "</pre>" ; final String qEnd = Pattern . quote ( end ) ; final Pattern p = Pattern . compile ( qStart + "(.*)" + qEnd , Pattern . DOTALL | Pattern . CASE_INSENSITIVE ) ; final Matcher m = p . matcher ( pDescription ) ; if ( m . find ( ) ) { stacktrace = m . group ( 1 ) ; if ( StringUtils . contains ( stacktrace , start ) || StringUtils . contains ( stacktrace , end ) ) { throw new IssueParseException ( "Invalid stacktrace block" ) ; } } else { throw new IssueParseException ( "0 stacktrace block found in the description" ) ; } return stacktrace ; } | Extracts the bug stacktrace from the description . |
15,689 | public void init ( ServletConfig config ) throws ServletException { World world ; String str ; try { world = World . create ( ) ; configure ( world , "http" ) ; configure ( world , "https" ) ; str = config . getInitParameter ( "docroot" ) ; docroot = Application . file ( world , str != null ? str : config . getServletContext ( ) . getRealPath ( "" ) ) ; docroot . checkDirectory ( ) ; LOG . info ( "home: " + world . getHome ( ) ) ; application = Application . load ( world , config , docroot ) ; LOG . info ( "docroot: " + docroot ) ; } catch ( RuntimeException | Error e ) { error ( null , "init" , e ) ; throw e ; } catch ( Exception e ) { error ( null , "init" , e ) ; throw new ServletException ( e ) ; } catch ( Throwable e ) { error ( null , "init" , e ) ; throw new RuntimeException ( "unexpected throwable" , e ) ; } } | creates configuration . |
15,690 | public static final < T > Stream < T > breadthFirst ( T root , Function < ? super T , ? extends Stream < T > > edges ) { return BreadthFirst . stream ( root , edges ) ; } | Returns stream for graph nodes starting with root . Function edges returns stream for each node containing nodes edges . Traversal is in breadth first order . |
15,691 | public static final < T > Stream < T > diGraph ( T root , Function < ? super T , ? extends Stream < T > > edges ) { return DiGraphIterator . stream ( root , edges ) ; } | Returns stream for graph nodes starting with root . Function edges returns stream for each node containing nodes edges . |
15,692 | public User withId ( final long id ) { return new User ( id , username , displayName , slug , email , createTimestamp , url , metadata ) ; } | Creates a user with a new id . |
15,693 | public User withMetadata ( final List < Meta > metadata ) { return new User ( id , username , displayName , slug , email , createTimestamp , url , metadata ) ; } | Creates a user with added metadata . |
15,694 | public static LinkedBindingBuilder < HttpClientObserver > bindNewObserver ( final Binder binder , final Annotation annotation ) { return Multibinder . newSetBinder ( binder , HttpClientObserver . class , annotation ) . addBinding ( ) ; } | Register a HttpClientObserver which observes only requests from a HttpClient with the given Guice binding annotation . |
15,695 | public static int findAvailablePort ( int maxRetries ) { int retries = 0 ; int randomPort ; boolean portAvailable ; do { randomPort = randomPort ( ) ; portAvailable = isPortAvailable ( randomPort ) ; retries ++ ; } while ( retries <= maxRetries && ! portAvailable ) ; assumeTrue ( "no open port found" , portAvailable ) ; return randomPort ; } | Finds an available port . |
15,696 | public static boolean isPortAvailable ( final int port ) { try ( ServerSocket tcp = new ServerSocket ( port ) ; DatagramSocket udp = new DatagramSocket ( port ) ) { return tcp . isBound ( ) && udp . isBound ( ) ; } catch ( Exception e ) { return false ; } } | Checks if the specified is available as listen port . |
15,697 | public Receiver open ( Receiver receiver ) { this . receiver = receiver ; Runtime rt = Runtime . getRuntime ( ) ; try { proc = rt . exec ( commandArray , null , workingDir ) ; } catch ( IOException e ) { throw new RuntimeException ( "can not start command shell [" + ArraySupport . format ( commandArray , "," ) + "] + in directory " + workingDir ) ; } errorForwarder = new Transponder ( proc . getErrorStream ( ) , new Pipe ( receiver , new NewLineFilter ( ) ) ) ; outputForwarder = new Transponder ( proc . getInputStream ( ) , new Pipe ( receiver , new NewLineFilter ( ) ) ) ; errorForwarder . start ( ) ; outputForwarder . start ( ) ; return receiver ; } | Opens permanent shell |
15,698 | public static int execute ( String [ ] commandArray , String [ ] alternativeEnvVars , File workingDir , Receiver outputReceiver ) throws IOException { Runtime rt = Runtime . getRuntime ( ) ; Process proc = null ; try { proc = rt . exec ( commandArray , alternativeEnvVars , workingDir ) ; } catch ( Exception e ) { System . out . println ( "unable to execute command: " + ArraySupport . format ( commandArray , ", " ) ) ; e . printStackTrace ( ) ; throw new RuntimeException ( "unable to execute command: " + ArraySupport . format ( commandArray , ", " ) , e ) ; } Transponder errorForwarder = new Transponder ( proc . getErrorStream ( ) , new Pipe ( outputReceiver ) ) ; Transponder outputForwarder = new Transponder ( proc . getInputStream ( ) , new Pipe ( outputReceiver ) ) ; errorForwarder . start ( ) ; outputForwarder . start ( ) ; try { int retval = proc . waitFor ( ) ; errorForwarder . stop ( ) ; outputForwarder . stop ( ) ; return retval ; } catch ( InterruptedException ie ) { } return - 1 ; } | execute particular command |
15,699 | public static void main ( String [ ] args ) { StdIODialog dialog = new StdIODialog ( System . in , System . out , new CommandShell ( new String [ ] { "cmd.exe" } , new File ( "./" ) ) ) ; try { dialog . open ( ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } } | Runs test dialog . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.