idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
12,200 | public static void addDeepLogger ( Object object , Level level ) { addDeepLogger ( object , m -> logger . log ( level , m ) ) ; } | Attaches a deep property change listener to the given object that generates logging information about the property change events and prints them as log messages . |
12,201 | public static void addDeepConsoleLogger ( Object object ) { addDeepLogger ( object , m -> System . out . println ( m ) ) ; } | Attaches a deep property change listener to the given object that generates logging information about the property change events and prints them to the standard output . |
12,202 | public static void addDeepLogger ( Object object , Consumer < ? super String > consumer ) { Objects . requireNonNull ( consumer , "The consumer may not be null" ) ; PropertyChangeListener propertyChangeListener = new PropertyChangeListener ( ) { public void propertyChange ( PropertyChangeEvent event ) { Object source = event . getSource ( ) ; String propertyName = event . getPropertyName ( ) ; Object oldValue = event . getOldValue ( ) ; String oldValueString = createLoggingString ( oldValue ) ; Object newValue = event . getNewValue ( ) ; String newValueString = createLoggingString ( newValue ) ; String message = "Property " + propertyName + " changed from " + oldValueString + " to " + newValueString + " in " + source ; consumer . accept ( message ) ; } } ; addDeepPropertyChangeListener ( object , propertyChangeListener ) ; } | Attaches a deep property change listener to the given object that generates logging information about the property change events and passes them to the given consumer . |
12,203 | private static String createLoggingString ( Object object ) { if ( object == null ) { return "null" ; } Class < ? extends Object > objectClass = object . getClass ( ) ; if ( ! objectClass . isArray ( ) ) { return String . valueOf ( object ) ; } StringBuilder sb = new StringBuilder ( ) ; int length = Array . getLength ( object ) ; sb . append ( "[" ) ; for ( int i = 0 ; i < length ; i ++ ) { if ( i > 0 ) { sb . append ( ", " ) ; } Object element = Array . get ( object , i ) ; sb . append ( createLoggingString ( element ) ) ; } sb . append ( "]" ) ; return sb . toString ( ) ; } | Create a string suitable for logging the given object |
12,204 | public static void removeDeepPropertyChangeListener ( Object object , PropertyChangeListener propertyChangeListener ) { Objects . requireNonNull ( object , "The object may not be null" ) ; Objects . requireNonNull ( propertyChangeListener , "The propertyChangeListener may not be null" ) ; removeRecursive ( object , propertyChangeListener ) ; } | Remove the given property change listener from the given object and all its sub - objects . |
12,205 | private static void removeRecursive ( Object object , PropertyChangeListener propertyChangeListener ) { removeRecursive ( object , propertyChangeListener , new LinkedHashSet < Object > ( ) ) ; } | Recursively remove the given property change listener from the given object and all its sub - objects |
12,206 | public Translator < T > copy ( ) { Translator < T > trans = new Translator < T > ( ) ; if ( isBundleBased ( ) ) { for ( Translation < T > t : values ( ) ) { Locale loc = t . getLocale ( ) ; trans . store ( loc , t . getData ( ) ) ; } } else { for ( String lang : translations . keySet ( ) ) { Map < String , Translation < T > > map = translations . get ( lang ) ; for ( String ctry : map . keySet ( ) ) { trans . store ( lang , ctry , map . get ( ctry ) ) ; } } } return trans ; } | Copies the current translator into a new translator object . Even if this translator is resource bundle based the copy will not be . |
12,207 | private void cut ( XYChartLabel label , double maxWidth , double maxHeight , double rotation ) { String text = label . getLabel ( ) . getText ( ) ; cutLabelText ( label , maxWidth - 5 , maxHeight - 5 , rotation ) ; String cutText = label . getLabel ( ) . getText ( ) ; if ( text . length ( ) != cutText . length ( ) ) { label . getLabel ( ) . setText ( label . getLabel ( ) . getText ( ) + "..." ) ; } label . getLabelContainer ( ) . moveToTop ( ) ; } | Formats the label Text shapes in the given axis by cutting text value . |
12,208 | public static Object newInstance ( Object obj ) { if ( MjdbcLogger . isSLF4jAvailable ( ) == true && MjdbcLogger . isSLF4jImplementationAvailable ( ) == false ) { return obj ; } else { if ( MjdbcConfig . isProfilerEnabled ( ) == true ) { return java . lang . reflect . Proxy . newProxyInstance ( obj . getClass ( ) . getClassLoader ( ) , obj . getClass ( ) . getInterfaces ( ) , new BaseInvocationHandler ( obj , MjdbcConfig . getProfilerOutputFormat ( ) ) ) ; } else { return obj ; } } } | Function wraps Object into Profiling Java Proxy . Used to wrap QueryRunner instance with Java Proxy |
12,209 | public FoxHttpResponse execute ( FoxHttpClient foxHttpClient ) throws FoxHttpException { verifyRequest ( ) ; foxHttpClient . getFoxHttpLogger ( ) . log ( "========= Request =========" ) ; foxHttpClient . getFoxHttpLogger ( ) . log ( "setFoxHttpClient(" + foxHttpClient + ")" ) ; this . foxHttpClient = foxHttpClient ; return executeHttp ( "https" . equals ( url . getProtocol ( ) ) ) ; } | Execute a this request |
12,210 | public String getCommand ( final ToastrSettings settings ) { final StringBuilder sb = new StringBuilder ( ) ; sb . append ( "toastr." ) ; sb . append ( settings . getToastrType ( ) . getValue ( ) . getValue ( ) ) ; sb . append ( "('" ) ; sb . append ( settings . getNotificationContent ( ) . getValue ( ) ) ; sb . append ( "'" ) ; if ( StringUtils . isNotEmpty ( settings . getNotificationTitle ( ) . getValue ( ) ) ) { sb . append ( ", '" ) ; sb . append ( settings . getNotificationTitle ( ) . getValue ( ) ) ; sb . append ( "'" ) ; } sb . append ( ")" ) ; return sb . toString ( ) ; } | Gets the command . |
12,211 | public Set < String > getVisibleQueues ( PermissionManager permissionManager ) { Set < String > ret = new HashSet < String > ( ) ; for ( QueueDefinition queueDefinition : m_queues ) { if ( permissionManager . hasPermission ( FixedPermissions . ADMIN ) ) { ret . add ( queueDefinition . getName ( ) ) ; continue ; } if ( ! ret . contains ( queueDefinition . getName ( ) ) ) { if ( permissionManager . hasPermission ( queueDefinition . getPermission ( ) ) || permissionManager . hasPermission ( queueDefinition . getReadPermission ( ) ) ) { ret . add ( queueDefinition . getName ( ) ) ; } } } return ret ; } | Get the list of queues visible to this user ie to the user with the permissions defined in the given permissions manager . ADMIN permission means all are visible . |
12,212 | public Filter getQueueFilter ( PermissionManager permissionManager ) { if ( permissionManager . hasPermission ( FixedPermissions . TECHSUPPORT ) || permissionManager . hasPermission ( FixedPermissions . ADMIN ) ) { return null ; } Set < String > visibleQueues = getVisibleQueues ( permissionManager ) ; Filter filters [ ] = new Filter [ visibleQueues . size ( ) ] ; int i = 0 ; for ( String queueName : visibleQueues ) { filters [ i ++ ] = new Compare . Equal ( "queueName" , queueName ) ; } Filter statusFilter [ ] = new Filter [ 2 ] ; statusFilter [ 0 ] = new Or ( filters ) ; statusFilter [ 1 ] = new Compare . Equal ( "status" , TaskStatus . WAIT ) ; Filter userFilter [ ] = new Filter [ 2 ] ; userFilter [ 0 ] = new Compare . Equal ( "lockedBy" , permissionManager . getCurrentUser ( ) ) ; userFilter [ 1 ] = new Compare . Equal ( "status" , TaskStatus . BUSY ) ; return new Or ( new And ( statusFilter ) , new And ( userFilter ) ) ; } | If we have the TECHSUPPORT or ADMIN permission then return null . Those users can see everything so no filter required . For the rest we only display queues they have permission to see and only processes in WAIT status . |
12,213 | public Set < ProcessDefinition > getVisibleProcesses ( PermissionManager permissionManager ) { Set < ProcessDefinition > ret = new HashSet < > ( ) ; Set < String > queues = getWriteableQueues ( permissionManager ) ; String lastProcessName = "" ; for ( ProcessDefinition processDefinition : m_processes ) { String processName = processDefinition . getName ( ) ; if ( ! processName . equals ( lastProcessName ) ) { String queueName = processDefinition . getQueueName ( ) ; if ( StringUtils . hasText ( queueName ) ) { if ( queues . contains ( queueName ) ) { ret . add ( processDefinition ) ; } } else { ret . add ( processDefinition ) ; } lastProcessName = processName ; } } return ret ; } | Get the list of queues visible to this user ie to the user with the permissions defined in the given permissions manager |
12,214 | public DataType < Boolean > getType ( String grp , Number idx , boolean ml , boolean mv , boolean req , String ... params ) { return new BooleanAttribute ( grp , idx , ml , mv , req ) ; } | Technically you can have a multi - lingual or multi - valued boolean but why would you? |
12,215 | public void joinThread ( long timeout ) { Thread local_thread_ref = thread ; if ( local_thread_ref != null ) { try { long millis = 0l ; if ( log . isDebugEnabled ( ) ) { log . debug ( "BackgroundProcess.joinThread() Waiting " + timeout + " millis for " + this + " to finish" ) ; millis = System . currentTimeMillis ( ) ; } if ( thread_pool != null ) { synchronized ( pool_mutex ) { pool_mutex . wait ( timeout ) ; } } else local_thread_ref . join ( timeout ) ; if ( log . isDebugEnabled ( ) ) { millis = System . currentTimeMillis ( ) - millis ; log . debug ( "BackgroundProcess.joinThread() Process " + this + " finished in " + millis + " millis" ) ; } } catch ( InterruptedException e ) { if ( log . isDebugEnabled ( ) ) log . debug ( "BackgroundProcess.joinThread() Timed out waiting " + timeout + " millis for " + this + " to finish" ) ; } } else { if ( log . isDebugEnabled ( ) ) log . debug ( "BackgroundProcess.joinThread() " + name + " was not running, thread was null" ) ; } } | Inactivively waits for the process to finish or until timeout occurs whichever is earlier . If the process was not running returns immediatelly . |
12,216 | public void addHeader ( Map < String , String > entries ) { for ( Map . Entry < String , String > entry : entries . entrySet ( ) ) { headerEntries . add ( new HeaderEntry ( entry . getKey ( ) , entry . getValue ( ) ) ) ; } } | Add a new map of header entries |
12,217 | public HeaderEntry getHeader ( String name ) { for ( HeaderEntry headerField : getHeaderEntries ( ) ) { if ( headerField . getName ( ) . equals ( name ) ) { return headerField ; } } return null ; } | Get a specific header based on its name |
12,218 | public static PropertyDescriptor [ ] propertyDescriptors ( Class < ? > clazz ) { BeanInfo beanInfo = null ; try { beanInfo = Introspector . getBeanInfo ( clazz ) ; } catch ( IntrospectionException ex ) { throw new IllegalArgumentException ( "Bean introspection failed: " + ex . getMessage ( ) ) ; } return beanInfo . getPropertyDescriptors ( ) ; } | Reads property descriptors of class |
12,219 | public static Map < String , PropertyDescriptor > mapPropertyDescriptors ( Class < ? > clazz ) { PropertyDescriptor [ ] properties = propertyDescriptors ( clazz ) ; Map < String , PropertyDescriptor > mappedProperties = new HashMap < String , PropertyDescriptor > ( ) ; for ( PropertyDescriptor property : properties ) { if ( "class" . equals ( property . getName ( ) ) == false ) { mappedProperties . put ( property . getName ( ) , property ) ; } } return mappedProperties ; } | Reads property descriptors of class and puts them into Map . Key for map is read from property descriptor . |
12,220 | public static Object callGetter ( Object target , PropertyDescriptor prop ) { Object result = null ; Method getter = prop . getReadMethod ( ) ; if ( getter == null ) { throw new RuntimeException ( "No read method for bean property " + target . getClass ( ) + " " + prop . getName ( ) ) ; } try { result = getter . invoke ( target , new Object [ 0 ] ) ; } catch ( InvocationTargetException e ) { throw new RuntimeException ( "Couldn't invoke method: " + getter , e ) ; } catch ( IllegalArgumentException e ) { throw new RuntimeException ( "Couldn't invoke method with 0 arguments: " + getter , e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( "Couldn't invoke method: " + getter , e ) ; } return result ; } | Invokes Property Descriptor Getter and returns value returned by that function . |
12,221 | public static List < QueryParameters > convertResultSet ( ResultSet rs ) throws SQLException { List < QueryParameters > result = new ArrayList < QueryParameters > ( ) ; String columnName = null ; while ( rs . next ( ) == true ) { QueryParameters params = new QueryParameters ( ) ; ResultSetMetaData rsmd = rs . getMetaData ( ) ; int cols = rsmd . getColumnCount ( ) ; for ( int i = 1 ; i <= cols ; i ++ ) { columnName = rsmd . getColumnLabel ( i ) ; if ( null == columnName || 0 == columnName . length ( ) ) { columnName = rsmd . getColumnName ( i ) ; } params . set ( columnName , rs . getObject ( i ) ) ; params . updatePosition ( columnName , i - 1 ) ; } result . add ( params ) ; } return result ; } | Converts java . sql . ResultSet into List of QueryParameters . Used for caching purposes to allow ResultSet to be closed and disposed . |
12,222 | public static < T > T newInstance ( Class < T > clazz ) throws MjdbcException { try { return clazz . newInstance ( ) ; } catch ( InstantiationException ex ) { throw new MjdbcException ( "Failed to create instance: " + clazz . getName ( ) + " - " + ex . getMessage ( ) ) ; } catch ( IllegalAccessException ex ) { throw new MjdbcException ( "Failed to create instance: " + clazz . getName ( ) + " - " + ex . getMessage ( ) ) ; } } | Creates new Instance of class specified . Default Constructor should be visible in order to create new Instance |
12,223 | public static boolean hasFunction ( Object object , String functionName , Class [ ] parameters ) { boolean result = false ; try { Method method = object . getClass ( ) . getMethod ( functionName , parameters ) ; if ( method != null ) { result = true ; } } catch ( NoSuchMethodException ex ) { result = false ; } return result ; } | Checks if Instance has specified function |
12,224 | public static boolean objectInstanceOf ( Object object , String className ) { AssertUtils . assertNotNull ( object ) ; boolean result = false ; Class clazz = object . getClass ( ) ; if ( clazz . getName ( ) . equals ( className ) == true ) { result = true ; } return result ; } | Checks if instance is of specified class |
12,225 | public static boolean objectAssignableTo ( Object object , String className ) throws MjdbcException { AssertUtils . assertNotNull ( object ) ; boolean result = false ; Class clazz = null ; try { clazz = Class . forName ( className ) ; } catch ( ClassNotFoundException ex ) { throw new MjdbcException ( ex ) ; } result = clazz . isAssignableFrom ( object . getClass ( ) ) ; return result ; } | Checks if instance can be cast to specified Class |
12,226 | public static Object returnStaticField ( Class clazz , String fieldName ) throws MjdbcException { Object result = null ; Field field = null ; try { field = clazz . getField ( fieldName ) ; result = field . get ( null ) ; } catch ( NoSuchFieldException ex ) { throw new MjdbcException ( ex ) ; } catch ( IllegalAccessException ex ) { throw new MjdbcException ( ex ) ; } return result ; } | Returns class static field value Is used to return Constants |
12,227 | public static Object returnField ( Object object , String fieldName ) throws MjdbcException { AssertUtils . assertNotNull ( object ) ; Object result = null ; Field field = null ; try { field = object . getClass ( ) . getField ( fieldName ) ; result = field . get ( object ) ; } catch ( NoSuchFieldException ex ) { throw new MjdbcException ( ex ) ; } catch ( IllegalAccessException ex ) { throw new MjdbcException ( ex ) ; } return result ; } | Returns class field value Is used to return Constants |
12,228 | public static boolean isPrimitive ( Object value ) { if ( value == null ) { return true ; } else if ( value . getClass ( ) . isPrimitive ( ) == true ) { return true ; } else if ( Integer . class . isInstance ( value ) ) { return true ; } else if ( Long . class . isInstance ( value ) ) { return true ; } else if ( Double . class . isInstance ( value ) ) { return true ; } else if ( Float . class . isInstance ( value ) ) { return true ; } else if ( Short . class . isInstance ( value ) ) { return true ; } else if ( Byte . class . isInstance ( value ) ) { return true ; } else if ( Character . class . isInstance ( value ) ) { return true ; } else if ( Boolean . class . isInstance ( value ) ) { return true ; } else if ( BigDecimal . class . isInstance ( value ) ) { return true ; } else if ( BigInteger . class . isInstance ( value ) ) { return true ; } return false ; } | Checks is value is of Primitive type |
12,229 | public static Builder running ( File executable ) { checkArgument ( executable . isFile ( ) , "file not found: %s" , executable ) ; checkArgument ( executable . canExecute ( ) , "executable.canExecute" ) ; return running ( executable . getPath ( ) ) ; } | Constructs a builder instance that will produce a program that launches the given executable . Checks that a file exists at the given pathname and that it is executable by the operating system . |
12,230 | @ SuppressWarnings ( "unchecked" ) public < T > T parseInterface ( final Class < T > serviceInterface , FoxHttpClient foxHttpClient ) throws FoxHttpException { try { Method [ ] methods = serviceInterface . getDeclaredMethods ( ) ; for ( Method method : methods ) { FoxHttpMethodParser foxHttpMethodParser = new FoxHttpMethodParser ( ) ; foxHttpMethodParser . parseMethod ( method , foxHttpClient ) ; FoxHttpRequestBuilder foxHttpRequestBuilder = new FoxHttpRequestBuilder ( foxHttpMethodParser . getUrl ( ) , foxHttpMethodParser . getRequestType ( ) , foxHttpClient ) . setRequestHeader ( foxHttpMethodParser . getHeaderFields ( ) ) . setSkipResponseBody ( foxHttpMethodParser . isSkipResponseBody ( ) ) . setFollowRedirect ( foxHttpMethodParser . isFollowRedirect ( ) ) ; requestCache . put ( method , foxHttpRequestBuilder ) ; } return ( T ) Proxy . newProxyInstance ( serviceInterface . getClassLoader ( ) , new Class [ ] { serviceInterface } , new FoxHttpAnnotationInvocationHandler ( requestCache , responseParsers ) ) ; } catch ( FoxHttpException e ) { throw e ; } catch ( Exception e ) { throw new FoxHttpRequestException ( e ) ; } } | Parse the given interface for the use of FoxHttp |
12,231 | public Queue < B > newQueue ( ) { return new Queue < B > ( parent_queue , queue_restriction , index , process_builder_class , process_server_class , default_occurence , default_visibility , default_access , default_resilience , default_output , implementation_options ) ; } | Create the new Queue using the currently set properties . |
12,232 | protected T updateBean ( T object , Map < String , Object > source ) { T clone = copyProperties ( object ) ; updateProperties ( clone , source ) ; return clone ; } | Updates bean with values from source . |
12,233 | private T createEmpty ( Class < ? > clazz ) { T emptyInstance = null ; if ( clazz . isInterface ( ) ) { throw new IllegalArgumentException ( "Specified class is an interface: " + clazz . getName ( ) ) ; } try { emptyInstance = ( T ) clazz . newInstance ( ) ; } catch ( InstantiationException ex ) { throw new IllegalArgumentException ( clazz . getName ( ) + ". Is it an abstract class?" , ex ) ; } catch ( IllegalAccessException ex ) { throw new IllegalArgumentException ( clazz . getName ( ) + "Is the constructor accessible?" , ex ) ; } return emptyInstance ; } | Creates new empty Bean instance |
12,234 | public static < C > Module configModuleWithOverrides ( final Class < C > configInterface , OverrideConsumer < C > overrideConsumer ) { checkNotNull ( configInterface ) ; checkNotNull ( overrideConsumer ) ; return configModuleWithOverrides ( configInterface , Optional . empty ( ) , Optional . ofNullable ( overrideConsumer ) ) ; } | Generates a Guice Module for use with Injector creation . THe generate Guice module binds a number of support classes to service a dynamically generate implementation of the provided configuration interface . This method further overrides the annotated defaults on the configuration class as per the code in the given overrideConsumer |
12,235 | public static < C > Module configModuleWithOverrides ( final Class < C > configInterface , Named name , OverrideConsumer < C > overrideConsumer ) { checkNotNull ( configInterface ) ; checkNotNull ( name ) ; checkNotNull ( overrideConsumer ) ; return configModuleWithOverrides ( configInterface , Optional . ofNullable ( name ) , Optional . ofNullable ( overrideConsumer ) ) ; } | Generates a Guice Module for use with Injector creation . The generate Guice module binds a number of support classes to service a dynamically generate implementation of the provided configuration interface . This method further overrides the annotated defaults on the configuration class as per the code in the given overrideConsumer |
12,236 | public static CompositeConfiguration getConfig ( ) { if ( config == null ) { config = new CompositeConfiguration ( ) ; String configFile = "bard.properties" ; if ( Util . class . getClassLoader ( ) . getResource ( configFile ) == null ) { return config ; } try { config . addConfiguration ( new PropertiesConfiguration ( "bard.properties" ) ) ; } catch ( ConfigurationException e ) { logger . error ( "Load Bard configuration \"bard.properties\" error: {}" , e ) ; } } return config ; } | Get the Bard config object . The properties is set in bard . properties . |
12,237 | public static String [ ] encrypt ( String password ) { SecureRandom random = new SecureRandom ( ) ; String salt = new BigInteger ( 130 , random ) . toString ( 32 ) ; String encryptPassword = encrypt ( password , salt ) ; return new String [ ] { encryptPassword , salt } ; } | Encrypt a password string with a random generated salt . |
12,238 | public static String encrypt ( String password , String salt ) { String saltPassword = password + salt ; return DigestUtils . sha256Hex ( saltPassword . getBytes ( ) ) ; } | Encrypt a password string with a given password . |
12,239 | @ SuppressWarnings ( "unused" ) private boolean checkSwf ( ) throws IOException { byte [ ] a = new byte [ 6 ] ; if ( read ( a ) != a . length ) { return false ; } format = FORMAT_SWF ; int bitSize = ( int ) readUBits ( 5 ) ; int minX = ( int ) readSBits ( bitSize ) ; int maxX = ( int ) readSBits ( bitSize ) ; int minY = ( int ) readSBits ( bitSize ) ; int maxY = ( int ) readSBits ( bitSize ) ; width = maxX / 20 ; height = maxY / 20 ; setPhysicalWidthDpi ( 72 ) ; setPhysicalHeightDpi ( 72 ) ; return ( width > 0 && height > 0 ) ; } | Written by Michael Aird . |
12,240 | public String getComment ( int index ) { if ( comments == null || index < 0 || index >= comments . size ( ) ) { throw new IllegalArgumentException ( "Not a valid comment index: " + index ) ; } return ( String ) comments . get ( index ) ; } | Returns the index th comment retrieved from the image . |
12,241 | public static synchronized Document getDefaultDocument ( ) { if ( defaultDocument == null ) { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder documentBuilder = null ; try { documentBuilder = documentBuilderFactory . newDocumentBuilder ( ) ; } catch ( ParserConfigurationException e ) { throw new XmlException ( "Could not create default document" , e ) ; } defaultDocument = documentBuilder . newDocument ( ) ; } return defaultDocument ; } | Returns a default XML document |
12,242 | private static void write ( Node node , Writer writer , int indentation , boolean omitXmlDeclaration ) { TransformerFactory transformerFactory = TransformerFactory . newInstance ( ) ; if ( indentation > 0 ) { transformerFactory . setAttribute ( "indent-number" , indentation ) ; } Transformer transformer = null ; try { transformer = transformerFactory . newTransformer ( ) ; } catch ( TransformerConfigurationException canNotHappen ) { throw new XmlException ( "Could not create transformer" , canNotHappen ) ; } transformer . setOutputProperty ( OutputKeys . STANDALONE , "yes" ) ; transformer . setOutputProperty ( OutputKeys . INDENT , propertyStringFor ( indentation > 0 ) ) ; transformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , propertyStringFor ( omitXmlDeclaration ) ) ; DOMSource source = new DOMSource ( node ) ; StreamResult xmlOutput = new StreamResult ( writer ) ; try { transformer . transform ( source , xmlOutput ) ; } catch ( TransformerException e ) { throw new XmlException ( "Could not transform node" , e ) ; } } | Writes a formatted String representation of the given XML node to the given writer . |
12,243 | public static Node read ( InputStream inputStream ) throws XmlException { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder documentBuilder = documentBuilderFactory . newDocumentBuilder ( ) ; Document document = documentBuilder . parse ( inputStream ) ; Node node = document . getDocumentElement ( ) ; return node ; } catch ( ParserConfigurationException canNotHappen ) { throw new XmlException ( "Could not create parser" , canNotHappen ) ; } catch ( SAXException e ) { throw new XmlException ( "XML parsing error" , e ) ; } catch ( IOException e ) { throw new XmlException ( "IO error while reading XML" , e ) ; } } | Creates an XML node by reading the contents of the given input stream . |
12,244 | public static String getAttributeValue ( Node node , String attributeName , String defaultValue ) { NamedNodeMap attributes = node . getAttributes ( ) ; Node attributeNode = attributes . getNamedItem ( attributeName ) ; if ( attributeNode == null ) { return defaultValue ; } String value = attributeNode . getNodeValue ( ) ; if ( value == null ) { return defaultValue ; } return value ; } | Returns the attribute with the given name from the given node . If the respective attribute could not be obtained the given default value will be returned |
12,245 | public static String getRequiredAttributeValue ( Node node , String attributeName ) { NamedNodeMap attributes = node . getAttributes ( ) ; Node attributeNode = attributes . getNamedItem ( attributeName ) ; if ( attributeNode == null ) { throw new XmlException ( "No attribute with name \"" + attributeName + "\" found" ) ; } String value = attributeNode . getNodeValue ( ) ; if ( value == null ) { throw new XmlException ( "Attribute with name \"" + attributeName + "\" has no value" ) ; } return value ; } | Returns the attribute with the given name from the given node . |
12,246 | static < T > T resolveAttributeFromMap ( Node node , String attributeName , Map < String , ? extends T > map ) { String id = XmlUtils . getAttributeValue ( node , attributeName , null ) ; if ( id == null ) { throw new XmlException ( "No attribute \"" + attributeName + "\" found" ) ; } T result = map . get ( id ) ; if ( result == null ) { throw new XmlException ( "Could not resolve value with id \"" + id + "\"" ) ; } return result ; } | Resolve the value in the given map whose key is the value of the specified attribute . |
12,247 | static int readInt ( Node node ) { if ( node == null ) { throw new XmlException ( "Tried to read int value from null node" ) ; } String value = node . getFirstChild ( ) . getNodeValue ( ) ; if ( value == null ) { throw new XmlException ( "Tried to read int value from null value" ) ; } try { return Integer . parseInt ( value ) ; } catch ( NumberFormatException e ) { throw new XmlException ( "Expected int value, found \"" + value + "\"" , e ) ; } } | Parse an int value from the first child of the given node . |
12,248 | static double readDouble ( Node node ) { if ( node == null ) { throw new XmlException ( "Tried to read double value from null node" ) ; } String value = node . getFirstChild ( ) . getNodeValue ( ) ; if ( value == null ) { throw new XmlException ( "Tried to read double value from null value" ) ; } try { return Double . parseDouble ( value ) ; } catch ( NumberFormatException e ) { throw new XmlException ( "Expected double value, found \"" + value + "\"" , e ) ; } } | Parse a double value from the first child of the given node . |
12,249 | static boolean readBoolean ( Node node ) { if ( node == null ) { throw new XmlException ( "Tried to read boolean value from null node" ) ; } String value = node . getFirstChild ( ) . getNodeValue ( ) ; return Boolean . parseBoolean ( value ) ; } | Parse a boolean value from the first child of the given node . |
12,250 | static < E extends Enum < E > > E readEnum ( Node node , Class < E > enumClass ) { if ( node == null ) { throw new XmlException ( "Tried to read " + enumClass . getSimpleName ( ) + " value from null node" ) ; } String value = node . getFirstChild ( ) . getNodeValue ( ) ; if ( value == null ) { throw new XmlException ( "Tried to read " + enumClass . getSimpleName ( ) + " value from null value" ) ; } try { return Enum . valueOf ( enumClass , value ) ; } catch ( IllegalArgumentException e ) { throw new XmlException ( "No valid " + enumClass . getSimpleName ( ) + ": \"" + value + "\"" ) ; } } | Parse an enum value from the first child of the given node . |
12,251 | public static int readIntChild ( Node node , String childNodeName , int defaultValue ) { if ( node == null ) { throw new XmlException ( "Tried to read int value from child of null node" ) ; } Node child = XmlUtils . getFirstChild ( node , childNodeName ) ; if ( child == null ) { return defaultValue ; } return XmlUtils . readInt ( child ) ; } | Read an int value from the first child of the given node with the given name . If no such child is found then the default value will be returned . |
12,252 | static double readDoubleChild ( Node node , String childNodeName , double defaultValue ) { if ( node == null ) { throw new XmlException ( "Tried to read double value from child of null node" ) ; } Node child = XmlUtils . getFirstChild ( node , childNodeName ) ; if ( child == null ) { return defaultValue ; } return XmlUtils . readDouble ( child ) ; } | Read a double value from the first child of the given node with the given name . If no such child is found then the default value will be returned . |
12,253 | public static boolean readBooleanChild ( Node node , String childNodeName , boolean defaultValue ) { if ( node == null ) { throw new XmlException ( "Tried to read boolean value from child of null node" ) ; } Node child = XmlUtils . getFirstChild ( node , childNodeName ) ; if ( child == null ) { return defaultValue ; } return XmlUtils . readBoolean ( child ) ; } | Read an boolean value from the first child of the given node with the given name . If no such child is found then the default value will be returned . |
12,254 | public static < E extends Enum < E > > E readEnumChild ( Node node , Class < E > enumClass , String childNodeName ) { if ( node == null ) { throw new XmlException ( "Tried to read enum value from child of null node" ) ; } Node child = XmlUtils . getFirstChild ( node , childNodeName ) ; return XmlUtils . readEnum ( child , enumClass ) ; } | Parse an enum value from the first child of the given node with the given name |
12,255 | protected void validateSqlString ( String originalSql ) { if ( originalSql == null ) { throw new IllegalArgumentException ( ERROR_SQL_QUERY_NULL ) ; } if ( processor . hasUnnamedParameters ( originalSql ) == true ) { throw new IllegalArgumentException ( ERROR_FOUND_UNNAMED_PARAMETER ) ; } } | Checks if original SQL string valid . If string contains some unnamed ? parameters - it is considered unvalid |
12,256 | public ProcessInstance lockProcessInstance ( final ProcessInstance processInstance , final boolean techSupport , final String userName ) { List < Lock > locks = ContextUtils . getLocks ( processInstance , getLockFactory ( ) , "nz.co.senanque.workflow.WorkflowClient.lock(ProcessInstance)" ) ; LockTemplate lockTemplate = new LockTemplate ( locks , new LockAction ( ) { public void doAction ( ) { String taskId = ProcessInstanceUtils . getTaskId ( processInstance ) ; ProcessInstance pi = getWorkflowDAO ( ) . refreshProcessInstance ( processInstance ) ; if ( ! techSupport ) { if ( ! ( taskId . equals ( ProcessInstanceUtils . getTaskId ( pi ) ) && ( ( pi . getStatus ( ) == TaskStatus . WAIT ) || ( ( pi . getStatus ( ) == TaskStatus . BUSY ) && userName . equals ( pi . getLockedBy ( ) ) ) ) ) ) { throw new RuntimeException ( "ProcessInstance is already busy" ) ; } } pi . setStatus ( TaskStatus . BUSY ) ; pi . setLockedBy ( userName ) ; TaskBase task = getCurrentTask ( pi ) ; Audit audit = createAudit ( pi , task ) ; getWorkflowDAO ( ) . mergeProcessInstance ( pi ) ; } } ) ; boolean weAreOkay = true ; try { weAreOkay = lockTemplate . doAction ( ) ; } catch ( Exception e ) { weAreOkay = false ; } if ( ! weAreOkay ) { return null ; } return getWorkflowDAO ( ) . refreshProcessInstance ( processInstance ) ; } | This manages the transition of the process instance from Waiting to Busy with appropriate locking and unlocking . Once it is busy it is ours but we have to check that it was not changed since we last saw it . The situation we are protecting against is that although the process instance looked to be in wait state in the table we might have sat on that for a while and someone else may have updated it meanwhile . In that case we reject the request unless we are TECHSUPPORT . Those guys can do anything . |
12,257 | protected TaskBase endOfProcessDetected ( ProcessInstance processInstance , Audit currentAudit ) { TaskBase ret = null ; TaskBase currentTask = getCurrentTask ( processInstance ) ; ProcessInstanceUtils . clearQueue ( processInstance , TaskStatus . DONE ) ; currentAudit . setStatus ( TaskStatus . DONE ) ; { List < Audit > audits = findHandlerTasks ( processInstance ) ; for ( Audit audit : audits ) { TaskBase taskBase = getTask ( audit ) ; audit . setHandler ( false ) ; if ( taskBase instanceof TaskTry ) { TaskTry taskTry = ( TaskTry ) taskBase ; if ( taskTry . getTimeoutValue ( ) > - 1 ) { getWorkflowDAO ( ) . removeDeferredEvent ( processInstance , taskTry ) ; } TaskBase nextTask = taskTry . getNextTask ( processInstance ) ; nextTask . loadTask ( processInstance ) ; } if ( taskBase instanceof TaskIf ) { TaskIf taskIf = ( TaskIf ) taskBase ; TaskBase nextTask = taskIf . getNextTask ( processInstance ) ; nextTask . loadTask ( processInstance ) ; } ret = getCurrentTask ( processInstance ) ; break ; } } tickleParentProcess ( processInstance , TaskStatus . DONE ) ; if ( ret == currentTask ) { processInstance . setStatus ( TaskStatus . DONE ) ; } getWorkflowDAO ( ) . mergeProcessInstance ( processInstance ) ; getWorkflowDAO ( ) . flush ( ) ; getWorkflowDAO ( ) . refreshProcessInstance ( processInstance ) ; return ret ; } | If this is just the end of the handler then return the next task after the handler If it is the end of the whole process then return null . |
12,258 | public void init ( ) { findBeans ( ) ; SAXBuilder builder = new SAXBuilder ( ) ; Document doc = null ; try { doc = builder . build ( getSchema ( ) . getInputStream ( ) ) ; SchemaParserImpl schemaParser = new SchemaParserImpl ( ) ; schemaParser . parse ( doc ) ; ParserSource parserSource = new InputStreamParserSource ( getProcesses ( ) ) ; ProcessTextProvider textProvider = new ProcessTextProvider ( parserSource , schemaParser , this ) ; ParsePackage parsePackage = new ParsePackage ( ) ; parsePackage . parse ( textProvider ) ; } catch ( Exception e ) { throw new WorkflowException ( e ) ; } HashIdLogger . log ( this , "postconstruct" ) ; } | Scan resources for workflow files and message definitions |
12,259 | public static int getFacetMarker ( OWLFacet facet ) { switch ( facet ) { case LENGTH : return 0 ; case MIN_LENGTH : return 1 ; case MAX_LENGTH : return 2 ; case PATTERN : return 3 ; case MIN_INCLUSIVE : return 4 ; case MIN_EXCLUSIVE : return 5 ; case MAX_INCLUSIVE : return 6 ; case MAX_EXCLUSIVE : return 7 ; case TOTAL_DIGITS : return 8 ; case FRACTION_DIGITS : return 9 ; case LANG_RANGE : return 10 ; default : throw new RuntimeException ( "Illegal state. Case not covered" ) ; } } | Gets the facet marker for a given facet . |
12,260 | public static String hash ( Serializable obj ) { if ( obj == null ) { return "" ; } StringBuilder hexString = new StringBuilder ( ) ; try { MessageDigest m = MessageDigest . getInstance ( "SHA1" ) ; m . update ( SerializationUtils . serialize ( obj ) ) ; byte [ ] mdbytes = m . digest ( ) ; for ( byte mdbyte : mdbytes ) { hexString . append ( Integer . toHexString ( 0xFF & mdbyte ) ) ; } } catch ( NoSuchAlgorithmException e ) { return "" ; } return hexString . toString ( ) ; } | Create a hash of a serializable object |
12,261 | public static < T > List < T > toList ( Iterable < T > iterable ) { Objects . requireNonNull ( iterable , "The iterable is null" ) ; return Iterables . toCollection ( iterable , new ArrayList < T > ( ) ) ; } | Drains all elements that are provided by the iterator of the given iterable into a list |
12,262 | public static < T > Set < T > toSet ( Iterable < T > iterable ) { Objects . requireNonNull ( iterable , "The iterable is null" ) ; return Iterables . toCollection ( iterable , new LinkedHashSet < T > ( ) ) ; } | Drains all elements that are provided by the iterator of the given iterable into a set |
12,263 | public static < T , C extends Collection < ? super T > > C toCollection ( Iterable < T > iterable , C collection ) { Objects . requireNonNull ( iterable , "The iterable is null" ) ; Objects . requireNonNull ( collection , "The collection is null" ) ; return Iterators . toCollection ( iterable . iterator ( ) , collection ) ; } | Drains all elements that are provided by the iterator of the given iterable into the given collection |
12,264 | public static < T > Iterable < T > iterableOverIterables ( final Iterable < ? extends Iterable < ? extends T > > iterablesIterable ) { Objects . requireNonNull ( iterablesIterable , "The iterablesIterable is null" ) ; return new Iterable < T > ( ) { public Iterator < T > iterator ( ) { return Iterators . iteratorOverIterables ( iterablesIterable . iterator ( ) ) ; } } ; } | Returns an iterator that combines the iterators that are provided by the iterables that are provided by the iterator of the given iterable . Fancy stuff he? |
12,265 | public static < S , T > Iterable < T > transformingIterable ( final Iterable < ? extends S > iterable , final Function < S , ? extends T > function ) { Objects . requireNonNull ( iterable , "The iterable is null" ) ; Objects . requireNonNull ( function , "The function is null" ) ; return new Iterable < T > ( ) { public Iterator < T > iterator ( ) { return new TransformingIterator < S , T > ( iterable . iterator ( ) , function ) ; } } ; } | Returns an iterable that provides iterators that are transforming the elements provided by the iterators of the given iterable using the given function |
12,266 | public static < T > Iterable < T > filteringIterable ( final Iterable < ? extends T > iterable , final Predicate < ? super T > predicate ) { Objects . requireNonNull ( iterable , "The iterable is null" ) ; Objects . requireNonNull ( predicate , "The predicate is null" ) ; return new Iterable < T > ( ) { public Iterator < T > iterator ( ) { return new FilteringIterator < T > ( iterable . iterator ( ) , predicate ) ; } } ; } | Returns an iterable that provides an iterator that only returns the elements provided by the iterator of the given iterable to which the given predicate applies . |
12,267 | @ SuppressWarnings ( "unchecked" ) public < T > T get ( ) { return ( T ) ( this . isString ? ( String ) this . value : ( Number ) this . value ) ; } | Returns the value of attribute |
12,268 | public void del ( final OnItemSnapshot onItemSnapshot , final OnError onError ) { TableMetadata tm = context . getTableMeta ( this . table . name ) ; if ( tm == null ) { this . table . meta ( new OnTableMetadata ( ) { public void run ( TableMetadata tableMetadata ) { _del ( onItemSnapshot , onError ) ; } } , onError ) ; } else { this . _del ( onItemSnapshot , onError ) ; } return ; } | Deletes an item specified by this reference |
12,269 | public ItemRef get ( final OnItemSnapshot onItemSnapshot , final OnError onError ) { TableMetadata tm = context . getTableMeta ( this . table . name ) ; if ( tm == null ) { this . table . meta ( new OnTableMetadata ( ) { public void run ( TableMetadata tableMetadata ) { _get ( onItemSnapshot , onError , false ) ; } } , onError ) ; } else { this . _get ( onItemSnapshot , onError , false ) ; } return this ; } | Gets an item snapshot specified by this item reference . |
12,270 | public ItemRef set ( final LinkedHashMap < String , ItemAttribute > item , final OnItemSnapshot onItemSnapshot , final OnError onError ) { TableMetadata tm = context . getTableMeta ( this . table . name ) ; if ( tm == null ) { this . table . meta ( new OnTableMetadata ( ) { public void run ( TableMetadata tableMetadata ) { _set ( item , onItemSnapshot , onError ) ; } } , onError ) ; } else { this . _set ( item , onItemSnapshot , onError ) ; } return this ; } | Updates the stored item specified by this item reference . |
12,271 | public ItemRef once ( StorageEvent eventType , final OnItemSnapshot onItemSnapshot ) { return once ( eventType , onItemSnapshot , null ) ; } | Attach a listener to run the callback only one the event type occurs for this item . |
12,272 | public ItemRef off ( StorageEvent eventType , OnItemSnapshot onItemSnapshot ) { Event ev = new Event ( eventType , this . table . name , this . primaryKeyValue , this . secondaryKeyValue , false , false , false , onItemSnapshot ) ; context . removeEvent ( ev ) ; return this ; } | Remove an event listener |
12,273 | public ItemRef incr ( final String property , final Number value , final OnItemSnapshot onItemSnapshot , final OnError onError ) { TableMetadata tm = context . getTableMeta ( this . table . name ) ; if ( tm == null ) { this . table . meta ( new OnTableMetadata ( ) { public void run ( TableMetadata tableMetadata ) { _in_de_cr ( property , value , true , onItemSnapshot , onError ) ; } } , onError ) ; } else { this . _in_de_cr ( property , value , true , onItemSnapshot , onError ) ; } return this ; } | Increments a given attribute of an item . If the attribute doesn t exist it is set to zero before the operation . |
12,274 | public ItemRef incr ( final String property , final OnItemSnapshot onItemSnapshot , final OnError onError ) { return this . incr ( property , null , onItemSnapshot , onError ) ; } | Increments by one a given attribute of an item . If the attribute doesn t exist it is set to zero before the operation . |
12,275 | public ItemRef disablePushNotifications ( ) { pushNotificationsEnabled = false ; Event ev = new Event ( null , this . table . name , this . primaryKeyValue , this . secondaryKeyValue , false , false , pushNotificationsEnabled , null ) ; ArrayList < String > channels = new ArrayList < String > ( ) ; channels . add ( ev . getChannelName ( ) ) ; context . disablePushNotificationsForChannels ( channels ) ; return this ; } | Disables mobile push notifications for current item reference . |
12,276 | public List < QueryParameters > subListCached ( int fromIndex , int toIndex ) { ArrayList < QueryParameters > result = new ArrayList < QueryParameters > ( ) ; result . addAll ( generatedCacheMap . values ( ) ) ; result . addAll ( resultSetCacheMap . values ( ) ) ; return result . subList ( fromIndex , toIndex ) ; } | Returns sublist of cached elements . |
12,277 | public Iterator < QueryParameters > iterator ( ) { final QueryParametersLazyList source = this ; return new Iterator < QueryParameters > ( ) { private LazyCacheIterator < QueryParameters > lazyCacheIterator = source . getLazyCacheIterator ( - 1 ) ; public boolean hasNext ( ) { return lazyCacheIterator . hasNext ( ) ; } public QueryParameters next ( ) { return lazyCacheIterator . getNext ( ) ; } public void remove ( ) { source . remove ( currentIndex ) ; } } ; } | Returns iterator of this lazy query output list implementation . First element returned - is header . Actual values are returned only starting from second element . |
12,278 | public QueryParameters set ( int index , QueryParameters element ) { QueryParameters params = null ; if ( getMaxCacheSize ( ) != - 1 ) { throw new MjdbcRuntimeException ( ERROR_NOT_ALLOWED + ". Cache update is allowed when Cache is not limited (used by Cached output handlers)" ) ; } if ( valueCached ( index ) == true ) { params = readCachedValue ( index ) ; updateCache ( index , element ) ; } else { throw new MjdbcRuntimeException ( ERROR_NOT_ALLOWED + ". Only cached(read) values can be replaced" ) ; } return params ; } | Sets value in cache . Please be aware that currently cache only is updated . No changes to Database are made |
12,279 | public QueryParameters update ( int index , QueryParameters params ) throws SQLException { AssertUtils . assertNotNull ( params , "Element cannot be null, but values inside of it - can" ) ; if ( this . type == Type . READ_ONLY_FORWARD || this . type == Type . READ_ONLY_SCROLL ) { throw new MjdbcSQLException ( "This Lazy query output cache is initialized as read-only - therefore cannot be updated." ) ; } QueryParameters result = get ( index ) ; if ( this . type == Type . UPDATE_FORWARD ) { if ( this . currentIndex == index ) { updateResultSetCurrentLine ( getCurrentResultSet ( ) , params ) ; } else if ( this . currentIndex + 1 == index ) { updateResultSetRow ( ( index + 1 ) - generatedCacheMap . size ( ) , params ) ; } else { throw new MjdbcRuntimeException ( "Only current/next element can be updated!" ) ; } getCurrentResultSet ( ) . updateRow ( ) ; this . currentIndex = index ; } else if ( this . type == Type . UPDATE_SCROLL ) { updateResultSetRow ( ( index + 1 ) - generatedCacheMap . size ( ) , params ) ; getCurrentResultSet ( ) . updateRow ( ) ; } else { throw new MjdbcSQLException ( "This Lazy query output cache was initialized with unknown type" ) ; } return result ; } | Updates specified row in ResultSet |
12,280 | public void insert ( QueryParameters params ) throws SQLException { getCurrentResultSet ( ) . moveToInsertRow ( ) ; updateResultSetCurrentLine ( getCurrentResultSet ( ) , params ) ; getCurrentResultSet ( ) . insertRow ( ) ; getCurrentResultSet ( ) . moveToCurrentRow ( ) ; } | Inserts new row into returned ResultSet |
12,281 | private void closeResultSet ( ResultSet rs ) { if ( closedResultSet . contains ( rs ) == false ) { MjdbcUtils . closeQuietly ( rs ) ; closedResultSet . add ( rs ) ; } } | Silently closes supplied result set |
12,282 | private StatementHandler getStatementHandler ( Class < ? extends StatementHandler > statementHandlerClazz ) { StatementHandler result = null ; Constructor < ? extends StatementHandler > constructor = null ; Class < ? extends StatementHandler > clazz = statementHandlerClazz ; try { constructor = clazz . getConstructor ( Overrider . class ) ; result = constructor . newInstance ( overrider ) ; } catch ( SecurityException e ) { throw new MjdbcRuntimeException ( ERROR_SH_INIT_FAILED , e ) ; } catch ( NoSuchMethodException e ) { throw new MjdbcRuntimeException ( ERROR_SH_INIT_FAILED , e ) ; } catch ( IllegalArgumentException e ) { throw new MjdbcRuntimeException ( ERROR_SH_INIT_FAILED , e ) ; } catch ( InstantiationException e ) { throw new MjdbcRuntimeException ( ERROR_SH_INIT_FAILED , e ) ; } catch ( IllegalAccessException e ) { throw new MjdbcRuntimeException ( ERROR_SH_INIT_FAILED , e ) ; } catch ( InvocationTargetException e ) { throw new MjdbcRuntimeException ( ERROR_SH_INIT_FAILED , e ) ; } return result ; } | Creates new StatementHandler instance |
12,283 | private static Integer checkQuietly ( final String name , final Integer value ) { Integer val = 50 ; try { val = Args . withinRange ( 0 , 100 , value , name ) ; } catch ( final IllegalArgumentException e ) { LOGGER . error ( String . format ( "Given argument '%s' must have a value within [%s,%s], but was %s. Default value 50% will be set." , name , 0 , 100 , value ) ) ; } return val ; } | Checks the given value if it is between 0 to 100 quietly . If not a default value from 50 will be set . |
12,284 | private Integer checkString ( final String value ) { Integer val = 50 ; if ( value != null && ! value . isEmpty ( ) ) { if ( value . endsWith ( "%" ) ) { final String sVal = value . substring ( 0 , value . length ( ) - 1 ) ; if ( StringUtils . isNumeric ( sVal ) ) { val = Integer . valueOf ( sVal ) ; } } else { if ( StringUtils . isNumeric ( value ) ) { val = Integer . valueOf ( value ) ; } } } return val ; } | Check string . |
12,285 | private String getPercentFormatted ( final Integer value ) { final Integer val = checkQuietly ( getName ( ) , value ) ; return NumberFormat . getPercentInstance ( ) . format ( ( double ) val / 100 ) ; } | Gets the percent formatted . |
12,286 | private void initializeProperties ( Class < ? > type , Object oldInstance , Encoder encoder ) { BeanInfo info = null ; try { info = Introspector . getBeanInfo ( type ) ; } catch ( IntrospectionException ie ) { encoder . getExceptionListener ( ) . exceptionThrown ( ie ) ; return ; } PropertyDescriptor [ ] pds = info . getPropertyDescriptors ( ) ; for ( int i = 0 ; i < pds . length ; ++ i ) { try { initializeProperty ( type , pds [ i ] , oldInstance , encoder ) ; } catch ( Exception e ) { encoder . getExceptionListener ( ) . exceptionThrown ( e ) ; } } } | Write all statements to initialize the properties of the given Java Bean Type based on the given instance using the given encoder |
12,287 | private void initializeProperty ( Class < ? > type , PropertyDescriptor pd , Object oldInstance , Encoder encoder ) throws Exception { Method getter = pd . getReadMethod ( ) ; Method setter = pd . getWriteMethod ( ) ; if ( getter != null && setter != null ) { Expression oldGetExpression = new Expression ( oldInstance , getter . getName ( ) , new Object [ ] { } ) ; Object oldValue = oldGetExpression . getValue ( ) ; Statement setStatement = new Statement ( oldInstance , setter . getName ( ) , new Object [ ] { oldValue } ) ; encoder . writeStatement ( setStatement ) ; } } | Write the statement to initialize the specified property of the given Java Bean Type based on the given instance using the given encoder |
12,288 | public List < RTMovie > getInTheaters ( String country ) throws RottenTomatoesException { return getInTheaters ( country , DEFAULT_PAGE , DEFAULT_PAGE_LIMIT ) ; } | Retrieves movies currently in theaters |
12,289 | public List < RTMovie > getUpcomingMovies ( String country ) throws RottenTomatoesException { return getUpcomingMovies ( country , DEFAULT_PAGE , DEFAULT_PAGE_LIMIT ) ; } | Retrieves upcoming movies |
12,290 | public List < RTMovie > getTopRentals ( String country , int limit ) throws RottenTomatoesException { properties . clear ( ) ; properties . put ( ApiBuilder . PROPERTY_URL , URL_TOP_RENTALS ) ; properties . put ( ApiBuilder . PROPERTY_LIMIT , ApiBuilder . validateLimit ( limit ) ) ; properties . put ( ApiBuilder . PROPERTY_COUNTRY , ApiBuilder . validateCountry ( country ) ) ; WrapperLists wrapper = response . getResponse ( WrapperLists . class , properties ) ; if ( wrapper != null && wrapper . getMovies ( ) != null ) { return wrapper . getMovies ( ) ; } else { return Collections . emptyList ( ) ; } } | Retrieves the current top DVD rentals |
12,291 | public List < RTMovie > getNewReleaseDvds ( String country ) throws RottenTomatoesException { return getNewReleaseDvds ( country , DEFAULT_PAGE , DEFAULT_PAGE_LIMIT ) ; } | Retrieves new release DVDs |
12,292 | public RTMovie getDetailedInfo ( int movieId ) throws RottenTomatoesException { properties . clear ( ) ; properties . put ( ApiBuilder . PROPERTY_ID , String . valueOf ( movieId ) ) ; properties . put ( ApiBuilder . PROPERTY_URL , URL_MOVIES_INFO ) ; return response . getResponse ( RTMovie . class , properties ) ; } | Detailed information on a specific movie specified by Id . |
12,293 | public List < RTCast > getCastInfo ( int movieId ) throws RottenTomatoesException { properties . clear ( ) ; properties . put ( ApiBuilder . PROPERTY_ID , String . valueOf ( movieId ) ) ; properties . put ( ApiBuilder . PROPERTY_URL , URL_CAST_INFO ) ; WrapperLists wrapper = response . getResponse ( WrapperLists . class , properties ) ; if ( wrapper != null && wrapper . getCast ( ) != null ) { return wrapper . getCast ( ) ; } else { return Collections . emptyList ( ) ; } } | Pulls the complete movie cast for a movie |
12,294 | public List < RTClip > getMovieClips ( int movieId ) throws RottenTomatoesException { properties . clear ( ) ; properties . put ( ApiBuilder . PROPERTY_ID , String . valueOf ( movieId ) ) ; properties . put ( ApiBuilder . PROPERTY_URL , URL_MOVIE_CLIPS ) ; WrapperLists wrapper = response . getResponse ( WrapperLists . class , properties ) ; if ( wrapper != null && wrapper . getClass ( ) != null ) { return wrapper . getClips ( ) ; } else { return Collections . emptyList ( ) ; } } | Related movie clips and trailers for a movie |
12,295 | public List < RTMovie > getMoviesSimilar ( int movieId , int limit ) throws RottenTomatoesException { properties . clear ( ) ; properties . put ( ApiBuilder . PROPERTY_ID , String . valueOf ( movieId ) ) ; properties . put ( ApiBuilder . PROPERTY_URL , URL_MOVIES_SIMILAR ) ; properties . put ( ApiBuilder . PROPERTY_LIMIT , ApiBuilder . validateLimit ( limit ) ) ; WrapperLists wrapper = response . getResponse ( WrapperLists . class , properties ) ; if ( wrapper != null && wrapper . getMovies ( ) != null ) { return wrapper . getMovies ( ) ; } else { return Collections . emptyList ( ) ; } } | Returns similar movies to a movie |
12,296 | public RTMovie getMoviesAlias ( String altMovieId , String type ) throws RottenTomatoesException { properties . clear ( ) ; properties . put ( ApiBuilder . PROPERTY_URL , URL_MOVIES_ALIAS ) ; if ( "imdb" . equalsIgnoreCase ( type ) && altMovieId . toLowerCase ( ) . startsWith ( "tt" ) ) { properties . put ( ApiBuilder . PROPERTY_ID , altMovieId . substring ( LENGTH_OF_IMDB_PREFIX ) ) ; } else { properties . put ( ApiBuilder . PROPERTY_ID , altMovieId ) ; } properties . put ( ApiBuilder . PROPERTY_TYPE , type ) ; return response . getResponse ( RTMovie . class , properties ) ; } | Provides a movie lookup by an id from a different vendor |
12,297 | public Map < String , String > getListsDirectory ( ) throws RottenTomatoesException { properties . clear ( ) ; properties . put ( ApiBuilder . PROPERTY_URL , URL_LISTS_DIRECTORY ) ; WrapperLists wrapper = response . getResponse ( WrapperLists . class , properties ) ; if ( wrapper != null && wrapper . getLinks ( ) != null ) { return wrapper . getLinks ( ) ; } else { return Collections . emptyMap ( ) ; } } | Displays the top level lists available in the API |
12,298 | void resolveUrl ( ) throws IOException , StorageException , KeyManagementException , NoSuchAlgorithmException { String tempUrl ; if ( context . isCluster ) { if ( this . context . lastBalancerResponse != null ) { tempUrl = this . context . lastBalancerResponse ; } else { String urlString = context . url + "?appkey=" + context . applicationKey ; URL url = new URL ( urlString ) ; String balancerResponse = urlString . startsWith ( "https:" ) ? secureBalancerRequest ( url ) : unsecureBalancerRequest ( url ) ; if ( balancerResponse == null ) { throw new StorageException ( "Cannot get response from balancer!" ) ; } JSONObject obj = ( JSONObject ) JSONValue . parse ( balancerResponse ) ; tempUrl = ( String ) obj . get ( "url" ) ; this . context . lastBalancerResponse = tempUrl ; } } else { tempUrl = context . url ; } tempUrl += tempUrl . substring ( tempUrl . length ( ) - 1 ) . equals ( "/" ) ? this . type . toString ( ) : "/" + this . type . toString ( ) ; this . requestUrl = new URL ( tempUrl ) ; } | will put the server url with rest path to this . requestUrl |
12,299 | public synchronized void complete ( ) { if ( logger . isInfoEnabled ( ) ) { logger . info ( "[" + this + "] Marking complete" ) ; } if ( loaded ) { return ; } loaded = true ; lastTouch = System . currentTimeMillis ( ) ; if ( waiting != null && waiting . isEmpty ( ) ) { waiting = null ; } notifyAll ( ) ; } | Marks the jiterator as complete . Once you call this method you cannot add any more items into the jiterator . If you fail to call this method any threads reading from this jiterator will ultimately hang until you call this method . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.