What types of sort performed by sort method of Array class ?

I use normal bubble sort and method Array.sort() to sort some given data of an Array and then count the time.But Array.sort() method takes more time then normal bubble sort.
Can anybody tell me what types of sort performed by sort method of Array class?

I'm pretty sure that in eariler versions (1.2, 1.3
maybe?) List.sort's docs said it used quicksort. Or I
might be on crack.You are actually both correct, and wrong :)
From the documentation of the sort methods hasn't changed in 1.2 -> 1.4 (as far as I can notice), and the documentation for sort(Object[]) says (taken from JDK 1.2 docs):
"This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists."
So, how could you be correct? The documentation for e.g. sort(int[]) (and all other primities) says:
"Sorts the specified array of ints into ascending numerical order. The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance."
Your memory serves you well :)
/Kaj

Similar Messages

  • What types of problems stem from high number of loaded classes?

    Currently we are in the process of testing our code for long-ish periods of time, between 4 hours and 24 hours+ non stop. The code is not interactive/user based. I first noticed that our garbage collection times were very high (about 15-25% of our total processing time). I then looked at loaded classes and there is a pretty steady rise over team of loaded classes. At the time of start up it is around 6-7k. After appproximately 4 hours its up around 25k loaded classes. Only 35 or so classes have been unloaded over this time. I'm wondering if the high number of loaded classes occurs because objects aren't fully dereferenced but then when a new object is created it reloads the class. My knowledge of class loading is fairly limited. Any help would be appreciated. Also, if you need more info let me know.
    Heap Size: ~2GB
    CMSPermGenSweepingEnabled
    CMSClassUnloadingEnabled

    Take a look at this example and the output:
    public class Example {
          * @param args
         public static void main(String[] args) {
              StaticBlocks a = new StaticBlocks();
              StaticBlocks b = new StaticBlocks();
              a = new StaticBlocks();
    class StaticBlocks {
         static {
              System.out.println("A static init block. Only happens when class is first loaded.");
              System.out.println("\tInstance init block. Happens every time a class is instantiated.");
         StaticBlocks(){
              System.out.println("\tYou instantiated a class!");
    }Output:
    A static init block. Only happens when class is first loaded.
         Instance init block. Happens every time a class is instantiated.
         You instantiated a class!
         Instance init block. Happens every time a class is instantiated.
         You instantiated a class!
         Instance init block. Happens every time a class is instantiated.
         You instantiated a class!I'm really not sure where to go from here... hopefully someone else that knows the JVM better can provide some insight.
    Take a look at this link. It gives some details on class loading... might help you out a little.
    [http://onjava.com/pub/a/onjava/2005/01/26/classloading.html?page=1|http://onjava.com/pub/a/onjava/2005/01/26/classloading.html?page=1]
    Edited by: mikeyfreake on Jul 29, 2009 9:40 AM

  • Calling a method in a class extended from thread

    I'm trying to use two threads of type ThreadTest to call the addNum method in the class below. I found that i couldnt call the addnum method with the instances I created but had to make the addnum method static and then call it with the class name ThreadTest.Is there anyway to get round this? i'm doing this exercise to try and understand synchronisation. Thanks
    import java.lang.Thread;
    import java.util.*;
    class ThreadTest extends Thread implements Runnable{
         private int x;
         private static ArrayList intnumbers = new ArrayList();
         public ThreadTest(int no)
              x=no;
         public void run()
              for (int i=0; i<x; i++)
                   try
                   System.out.println(i);
                   Thread.currentThread().sleep((long)(Math.random() * 1000));
              }catch(InterruptedException e ){e.getMessage();}
         public static void addNum(int n)
              synchronized(intnumbers){
                        intnumbers.add(new Integer(n));
    public static void main(String[] args)
         Thread  testThread = new Thread(new ThreadTest(50));
         Thread  testThreadb = new Thread(new ThreadTest(50));
         testThread.start();
         testThreadb.start();
              ThreadTest.addNum(10);
        //*** this gives an error
        //testThread.addNumber(10);
        //testThreadb.addNumber(10);
    }

    ok here goes again. ;).
    import java.lang.Thread;
    import java.util.*;
    class ThreadTest extends Thread implements Runnable{
         private int x;
         private static ArrayList intnumbers = new ArrayList();
         public ThreadTest(int no)
              x=no;
         public void run()
              for (int i=0; i<x; i++)
                   try
                   System.out.println(i);
                   Thread.currentThread().sleep((long)(Math.random() * 1000));
              }catch(InterruptedException e ){e.getMessage();}
         public static void addNum(int n)
              synchronized(intnumbers){
                        intnumbers.add(new Integer(n));
    public static void main(String[] args)
         Thread  testThread = new ThreadTest(50);
         testThread.start();
         //gives error so how can i create 2 instances of testThread and call addNum with them?
         //testThread.addNum(10);
    //works ok but I want to call addNum with 2 different threads
         ThreadTest.addNum(10);
    }

  • Invoking the main() method of a class within another

    Greetings -
    Can someone tell me what happens when you invoke the main() method of a class from within another class?
    I have a third-party class, designed to be invoked from a command line, that I want to invoke from within a separate class. What appears to be happening is that following the successful execution of the third-party class, the invoking class is terminated as well. That's not the intended behavior I had envisioned. ^_^
    Is there a better way than invoking the main() method? I still need the invoking class to continue executing.
    Thanks!

    Navigate yourself around pitfalls related to the Runtime.exec() method

  • What's the best way to sort query results?

    Hello All,
    I have a standard CRUD UI that now needs the results sorted, based on input from the UI. What's the best way to sort results by entity fields?
    I'm familiar with the conventional Java methodology using a TreeSet and comparator. Is this the best route, does BDB JE offer more convenient or performant alternatives?
    I looked through the documentation and saw how to change the indexes, but I'm just looking to change the order in the scope of the query.
    If my application were an address book, the UI would be sortable, ascending and descending, by date added, first name, last name, etc. based on which column the user clicked on.
    Thanks in advance,
    Steven
    Harvard Children's Hospital Informatics Program

    Hi Steven,
    Using standard Java collections is probably the best approach.
    One thing that may be useful is to get a SortedMap (Primary or SecondaryIndex.sortedMap) for the case where you have an index sorted the way you want, and then copy the primary index into a TreeMap (with a comparator) for other cases. That way, you always have a SortedMap to work with, whether you're copying the index or not.
    I haven't tried this myself, just a thought.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • What is the difference between standard,sorted and hash table

    <b>can anyone say what is the difference between standard,sorted and hash tabl</b>

    Hi,
    Standard Tables:
    Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.
    This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to
    the number of table entries.
    Sorted Tables:
    Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.
    This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of
    table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.
    Hashed Tables:
    Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
    This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and
    using internal tables that are similar to database tables.
    Regards,
    Ferry Lianto

  • [Microsoft][SQL Server Native Client 11.0][SQL Server]The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.  'Items' (OITM) (OITM)

    Dear Experts,
    i am getting the below error when i was giving * (Star) to view all the items in DB
    [Microsoft][SQL Server Native Client 11.0][SQL Server]The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.  'Items' (OITM) (OITM)
    As i was searching individually it is working fine
    can any one help me how to find this..
    Regards,
    Meghanath.S

    Dear Nithi Anandham,
    i am not having any query while finding all the items in item master data i am giving find mode and in item code i was trying to type *(Star) and enter while typing enter the above issue i was facing..
    Regards,
    Meghanath

  • Error in SQL Query The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. for the query

    hi Experts,
    while running SQL Query i am getting an error as
    The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. for the query
    select  T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
    T2.LineText
    from OQUT T0  INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
    QUT10 T2 ON T1.DocEntry = T2.DocEntry where T1.DocEntry='590'
    group by  T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
    ,T2.LineText
    how to resolve the issue

    Dear Meghanath,
    Please use the following query, Hope your purpose will serve.
    select  T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
    CAST(T2.LineText as nvarchar (MAX))[LineText]
    from OQUT T0  INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
    QUT10 T2 ON T1.DocEntry = T2.DocEntry --where T1.DocEntry='590'
    group by  T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
    ,CAST(T2.LineText as nvarchar (MAX))
    Regards,
    Amit

  • LinkedList, sort method with Comparable class

    I have created my own LinkedList class; named Linked (empty list) and LinkedNode. One of the method is sort() that use Comparable class. My problem is when I use my Linked class in my Library class (that uses Linked<Book> list = new Linked<Book>();) I face problem and the methods throw excpetion, and I discovered that this excpetion is from Comparable class.
    The sort() method in Linked class:
    public Linked<E> sort(){
              Linked<E> newList = new Linked<E>();
              System.out.println("Here is your prob");
              Comparable h = (Comparable)head;// head +compareTo
              System.out.println("Here is your prob");
              Linked<E> less = new Linked<E>();
              Linked<E> more = new Linked<E>();
              for(Linked<E> l = tail; !l.empty(); l=l.tail() ){
                   if(h.compareTo(l.head())>0)
                        less=less.add(l.head());
                   else
                        more=more.add(l.head());
              less=less.sort();
              more=more.sort();
              newList=less.join(more.add(head));
              return newList;
         }The sortCollection method in Library class:
    public void sortCollection()throws NullPointerException{
    list.sort();  } Also, I want to do my own Comparable class that switch between different sort modes.
    Hope my question is clear.
    Regards,

    The exception is
    java.lang.ClassCastException: Library.Book
         at Library.LinkedNode.sort(LinkedNode.java:58)
         at Library.BookLibrary.sortCollection(BookLibrary.java:145)
         at GUI.Projecc.actionPerformed(Projecc.java:351)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)

  • How to call a C sort function to sort a Java Array.

    My name is David, I'm interning this summer doing some High Performance Computing work. I'm significantly out of my comfort zone here; I am primarily a network/network security geek, not a programming guy. I took one Java based class called problem solving with programming where we wrote like 3 programs in Java and did everything else in pseudocode and using a program called Alice http://www.alice.org/ to do things graphically. Learned basically no actual programming syntax. Also have done some self-taught perl, but only through one book and I didn't finish it, I only got about half way through it. So my expertise in programming are pretty much null.
    That being said, I currently am tasked with having to figure out how to make JNI work... specifically at this time I am tasked with writing an array in Java, and designing a C program that can be called by means of JNI to sort the array. I have chosen to work with the Merge Sort algorithm. My method of coding is not one where I write the entire thing from scratch, I don't particularly have a need to master languages at this point, rather I just need to make them work. I am interested in learning, but time is of the essence for me right now. So thus far what I have done is take sample codes and tweak them to meet my purpose. However, I currently am unable to make things work. So I am asking for help.
    I am going to paste 3 codes here, the first one will be my basic self-written instructions for JNI (Hello World Instructions), the second one will be my Java Array, and the third one will be my MergeSort function. I am not asking for you to DO my work for me by telling me how to manipulate my code, but rather I am asking for you to send me in the direction of resources that will be of some aid to me. Links, books (preferrably e-books so I don't have to go to a library), anything that you can send my direction that may help will be deeply appreciated. Thanks so much!
    JNI Instructions:
    /*The process for calling a C function in Java is as follows:
    1)Write the Java Program name. Eg. HelloWorld.java
    2)Compile it: javac HelloWorld.java
    3)Create a header file: javah -jni HelloWorld
    4)Create a C program eg. HelloWorld.java
    5)Compile the C program creating a shared library eg. libhello.so (My specifc command is cc -m32 -I/usr/java/jdk1.7.0_05/include -I/usr/java/jdk1.7.0_05/include/linux -shared -o libhello.so -fPIC HelloWorld.c
    6) Copy the library to the java.library.path, or LD_LIBRARY_PATH (in my case I have set it to /usr/local/lib.
    7)Run ldconfig (/sbin/ldconfig)
    8)Run the java program: java HelloWorld. */
    //Writing the code:
    //For the HelloWorld program:
    //In java:
    //You need to name a class:
    class HelloWorld {
    //You then need to declare a native method:
    public native void displayHelloWorld();
    //You now need a static initializer:
    static {
    //Load the library:
    System.loadLibrary("hello");
    /*Main function to call the native method (call the C code)*/
    public static void main(String[] args) {
    new HelloWorld().displayHelloWorld();
    //In C:
    #include <jni.h> //JNI header
    #include "HelloWorld.h" //Header created by the javah -jni command parameter
    #include <stdio.h> //Standard input/output header for C.
    //Now we must use a portion of the code provided by the JNI header.
    JNIEXPORT void JNICALL
    Java_HelloWorld_displayHelloWorld(JNIENV *env, jobject obj)
    //Naming convention: Java_JavaProgramName_displayCProgramName
        printf("Hello World!\n");
        return;
    }Java Array:
    class JavaArray {
         private native int MergeSort(int[] arr);
         public static void main(String[] args)
             int arr[] = {7, 8, 6, 3, 1, 19, 20, 13, 27, 4};
         static
             System.loadLibrary("MergeSort");
    }Hacked and pieced together crappy C Merge Sort code:
    #include <jni.h>
    #include <stdio.h>
    #include "JavaArray.h"
    JNIEXPORT jint JNICALL
    Java_JavaArray_MergeSort(JNIEnv *env, jobject obj, jintArray arr[],jint low,jint mid,jint high)
       jint i,j,k,l,b[10];
    l=low;
    i=low;
    j=mid+1;
    while((l<=mid)&&(j<=high))
        if(arr[l]<=arr[j])
           b=arr[l];
    l++;
    else
    b[i]=arr[j];
    j++;
    i++;
    if(l>mid)
    for(k=j;k<=high;k++)
    b[i]=arr[k];
    i++;
    else
    for(k=l;k<=mid;k++)
    b[i]=arr[k];
    i++;
    for(k=low;k<=high;k++)
    arr[k]=b[k];
    void partition(jint arr[],jint low,jint high)
    jint mid;
    if(low<high)
    mid=(low+high)/2;
    partition(arr,low,mid);
    partition(arr,mid+1,high);
    sort(arr,low,mid,high);

    You're doing OK so far up to here:
    Java_JavaArray_MergeSort(JNIEnv *env, jobject obj, jintArray arr[],jint low,jint mid,jint high)This is not correct. It is not what was generated by javah. It would have generated this:
    Java_JavaArray_MergeSort(JNIEnv *env, jobject obj, jintArray arr,jint low,jint mid,jint high)A 'jintArray' is already an array, embedded in an object. You don't have an array of them.
    So you need to restore that, and the header file, the way 'javah' generated them, then adjust your code to call GetIntArrayElements() to get the elements out of 'arr' into a local int[] array, sort that, and then call ReleaseIntArrayElements() to put them back.

  • What is commandButton.action, if not a method?

    Gosh, I'm learning a lot of interesting things. First, the UIComponent.getAttributes().put() method simply uses Java reflection to find the appropriate setXXX() property method of the UIComponent itself, making UIComponent.getAttributes().put(propertyName, propretyValue) equivalent to UIComponent.setProperty(propertyValue)!
    Second, UICommand.setAction only takes a method binding argument, meaning that UICommand.getAttributes().put("action", value) only accepts a method binding as well.
    So how does <commandButton action="value"> work for literal values? That is, if the action action XML attribute value isn't a method-binding reference but a literal string value, how does CommandButtonTag store this value in UICommand?
    Garret

    OK, you've got a distinction between "method-signature
    binding", which is what MethodBinding actually is,
    and your new "method-value binding", which JSF doesn't
    offer.Right, and right! (The latter is the answer to the rhetorical question, "If I can get a value from a property, why can't I get a value from a method call?")
    I don't see anything in your proposal that
    provides method-signature binding via a ValueBinding
    class, nor can I imagine how you'd elegantly provide
    that.I don't want to! The reason why it's important to make the distinction between method-signature binding and method-value binding is that they are two different animals, for two different purposes. Method-signature binding is already served quite well, as you point out, by the existing MethodBinding. The "value" we want is a pointer to the method itself, not the value it produces. As you can't use a JSF EL (or even an extended JSF EL) expression or a method call to return a method-signature binding, there's no reason for method-signature binding to be part of the ValueBinding<?> (or Expression<?> or whatever we call it) hierarchy at all.
    Take the actionListener attribute, for instance. The value of this attribute is a method---not the value a method produces. It says in essence, "here is the method I want JSF to call later when an event is produced." We don't specify method argument objects, because we don't know them. (I'd like to see the JSF EL syntax explicitly specify the parameter types, but that's a wholly separate issue that doesn't affect this discussion.)
    The UICommand.actionListener attribute is like a string or integer attribute that doesn't support property-value binding. In fact, MethodBinding is a type just like String or Integer, and if Java supported returning method bindings we could in fact have an Expression<MethodBinding> that allowed the method binding to be literally specified (as it is now) or returned as the value of a property or a method invocation. But the Java language doesn't know about method-signature bindings, so "actionListener", "valueChangeListener", "validator", and other method-signature binding attributes should remain as they are now, and allow only a single MethodBinding as the valid object (parsed from the literal string method signature value in the XML attribute).
    I'm also not sure you addressed what I meant by
    "shadowing"; in JSF, if a ValueBinding is set, and
    then a static value is set, the static value "shadows"
    the binding; if the static value is nulled out, the
    ValueBinding becomes active again.Oh, I'm sorry, I didn't understand what you meant by "shadowing." I had assumed that you meant the same thing Mann was talking about when he described using a ConstantMethodBinding adapter class to pretend to be a MethodBinding when in reality a literal value is being stored.
    Rather, you're talking about, for example, UIParameter.name, which allows both a value-binding expression to be set, or just a literal string which if set makes UIParameter ignore the value-binding expression. Frankly, I didn't know this was a benefit---I thought it was an undesired consequence of UIComponent wanting to support both literal values and property-value binding expressions, and having one of these hidden if you happened to set both. My proposal didn't have this (what I thought to be) schizophrenia, and I thought that was a good thing.
    If it turns out you want to shadow variables (can you tell me why you'd want to?), then that's easier under my proposal than it currently is in JSF. In my proposal the logic is encapsulated in the Expression<?>, not the UIComponent.
    First, just add an Expression<T>.setShadowedValue() to the base value-binding interface. Adding this to the interface I defined above gives us:
    public interface Expression<T> //the base ValueBinding I describe above
    public T getValue(final FacesContext context);
    public Class getType(FacesContext context);
    public String getExpressionString();
    public void setValue(T value);
    public void setShadowedValue(Expression<T> expression);
    }(Note that I also added Expression<T>.setValue(). A MethodValueBindingExpression<T>.setValue(), of course, will function exactly like a PropertyValueBindingExpression<T>.setValue() for a property that is read-only, as will a LiteralExpression<T>.)
    Now you can shadow property-value bindings with literal values to your heart's content. Better yet, you can also shadow method-value bindings with a literal value. Even better, you don't have to care whether it's a property-value binding or a method-value binding (or even a literal value!) that you're shadowing with your literal value. (Maybe your use case calls for literal values to disallow shadowing---in that case LiteralExpression<T>.setShadowedValue() would call LIteralExpression<T>.setValue(), or maybe just throw away the value, depending on how you want it to work.)
    But it gets better! Why only shadow with literal values---why not shadow with a property-value binding? Why not shadow a property-value binding with a method-value binding? All of this is allowed, because Expression<T>.setShadowedValue() excepts another Expression<T> as its parameter. (And if you're using generics, it's even type-safe.) The internal logic of setShadowedValue() and getValue() function exactly as the current UIComponent code does for any arbitrary attribute, except now it's more elegant, more powerful, and encapsulated in a single place. It should be identically efficient.
    This all assumes that we even want shadowing. I'm sure you have a compelling use case...
    BTW, I entirely agree about the inelegance and
    inefficiency of the standard coding pattern for
    retrieving properties in JSF UIComponent classes, and
    know that it calls out for a better underlying storage
    architecture. That's why we don't duplicate it in the
    ADF Faces code!Yeah, I'm sure there are several ways to get around this ugly mess, and I'm sure most of them use some sort of refactoring to put common code in some other place than within UIComponent. I happen to like my proposal, which uses polymorphism to remove the need for if(){}else{} when retrieving values, and makes everything self-consistent, type-safe, extensible, elegant, and efficient. I'm sure your solution is pretty good, too. ;)
    All this, built entirely on top of the existing JSF
    spec. It can be done.Oh, yes, we can do all sorts of things on top of the existing JSF spec. In fact, the entire architecture I've proposed can be adapted to plug into the existing JSF architecture. Here's what I've done:
    First, I've created the whole Expression<T> interface hierarchy, implemented by PropertyValueBindingExpression<T>, MethodValueBindingExpression<T>, and LiteralExpression<T> hierarchy I outlined above. Now I have a nice interface that allows me to access values without caring how they are represented.
    But some existing UIComponent attributes (e.g. UIParameter.value) only allow property-value bindings (ignoring shadowing for the moment). So I have an ExpressionValueBinding that wraps any expression and adapts it as a subclass of ValueBinding.
    Some existing UIComponent attributes (e.g. UICommand.action) only allow method-value bindings. (In fact, UICommand.action may be the only place where JSF uses a method-value binding---without realizing it) Similarly, I have an ExpressionMethodValueBinding that wraps any expression and adapts it as a subclass of MethodBinding.
    I can now plug any expression (whether literal, property-value binding, or method-value binding) into any relevant exiting JSF component attribute, and things work---well and elegantly. It should be obvious by now that the mere fact that I can do this cries out that property-value binding, method-value binding, and literal values might as well have the same interface to begin with.
    Cheers,
    Garret

  • What types of logs should be kept on activities relating to DBA?

    What types of logs should be kept on activities relating to database administrator? How does the operating system assist in maintaining log? What alternatives are available to the IS-Auditor if the operating system does not maintain log?

    As has been pointed out in your duplicate thread, these are rather vague and generic questions, so there are no clearly right answers...
    What types of logs should be kept on activities
    relating to database administrator? That's a business decision, not a technical decision... It depends on government regulations, the type of data in the system, the types of threats that the organization is most concerned with, the performance overhead that is acceptable, etc.
    How does the
    operating system assist in maintaining log? This is very vague. I don't know how to answer it-- from a database standpoint, the operating system is just holding a file that the DBA (hopefully) cannot update.
    What
    alternatives are available to the IS-Auditor if the
    operating system does not maintain log?Perhaps you're thinking about Audit Vault here?
    I need this answer please..! anyone can help meIs this for a school assignment? Or for something in the real world? In the real world, I would expect a lot more information before making any sort of decision on something like this...
    Justin

  • What is the default optimization(CBO/RBO) method choose in Oracle 9i DB?

    What is the default optimization(CBO/RBO) method choose in Oracle 9i DB?
    Note : If we set the OPTIMIZER MODE as CHOOSE

    1) So you mean to say that, for all the tables if we are maintaining statistics, by default it will go for CBO, else RBO right?Yes, unless you dont specify a hint RULE to your queries. At least one table contains statsitics in a two or more table join select statement, oracle uses CBO and calculates statistics using their no. of blocks and other stuff, some internal calculations.
    Also, becarefull, old statistics can lead optimizer to choose very pool plan that impact query performance.
    2) If we are using CBO, then what will be the order of execution in the where clause, Is it from top to bottom, or reverse?If its a single table with where clause, then, oracle choose either full table scan, or index range scan depends upon the column mentioned in the where clause and availabl indexes.
    If query contains multiple tables, then, oracle has to decide between join methods, such as, nested loop, hash join, sort merge join and etc.
    3) And also If we are using RBO, then what will be the order of execution in the where clause, Is it from top to bottom, or reverse?
    RBO uses its internal calculation to produce the execution plan, more probably gives preference to indexes if a column has an index which appears in the where cluase.
    Jaffar

  • What is the next step after editing or triming a video ? What type of file format to save and what to do after that ?

    what is the next step after editing or triming a video?
    what type of file format should be save and what to do after that?

    In the early days of digital video editing, an export render could take hours!  Not many applications are as hard on system resources as video editing, and rendering the final edit is probably the most system intense action of all.  
    Head on over to the Premiere Pro Hardware forum to see what sort of computer hardware the pros use for NLE (non linear editing), or to the PPBM5 site for a better look.
    PPBM5 Benchmark
    Also check out the specs on the Video Guys website

  • How do I open a text file to sort using bubble sort?

    Hi,
    I have a text file, which is a list of #'s.. ex)
    0.001121
    0.313313
    0.001334
    how do you open a text file and read a list? I have the bubble sort code which sorts.. thanks

    I wrote this, but am getting a couple errors:
    import java.util.*;
    import java.io.*;
    public class sort
         public static void main(String[] args)
              String fileName = "numsRandom1024.txt";
              Scanner fromFile = null;
              int index = 0;
              double[] a = new double[1024];Don't use double. You should use something that implements Comparable, like java.lang.Double.
              try
                   fromFile = new Scanner(new File(fileName));
              catch (FileNotFoundException e)
    System.out.println("Error opening the file " +
    " + fileName);
                   System.exit(0);
              while (fromFile.hasNextLine())
                   String line = fromFile.nextLine();
                   a[index] = Double.parseDouble(line);Don't parse to a double, create a java.lang.Double instead.
                   System.out.println(a[index]);
                   index++;
              fromFile.close();
              bubbleSort( a, 0, a.length-1 );No. Don't use a.length-1: from index to a.length-1 all values will be null (if you use Double's). Call it like this:bubbleSort(a, 0, index);
    public static <T extends Comparable<? super T>> void
    d bubbleSort( T[] a, int first, int last )
              for(int counter = 0 ; counter < 1024 ; counter++)
    for(int counter2 = 1 ; counter2 < (1024-counter) ;
    ) ; counter2++)Don't let those counter loop to 1024. The max should be last .
                        if(a[counter2-1] > a[counter2])No. Use the compareTo(...) method:if(a[counter2-1].compareTo(a[counter2]) > 0) {
                             double temp = a[counter2];No, your array contains Comparable's of type T, use that type then:T temp = a[counter2];
    // ...Good luck.

Maybe you are looking for