Defining enum with abstract method which returns a generic type

Is it possible to define an abstract method which returns an geneic type like below? Thanks
public enum Type{
     A{
          public List<Integer> getData(){}
     B{
          public Set<String> getData{}
     abstract<T> T getData();
}

vulee wrote:
Why not?
List<Integer> lst = Type.A.getData();Wonder, which compiler you use. Can't be Java6:
# javac Enums.java
Enums.java:23: incompatible types
found   : java.util.Collection<capture#376 of ?>
required: java.util.List<java.lang.Integer>
                List<Integer> data = Type.A.getData();
                                                   ^
1 errorEdit: Unless you do it the generic way as you proposed, which actually is a phoney. Because of the T being a generic method parameter, the compiler will infer it from the type of the variable it gets assigned to. Hence, both of the following will compile:
List<Integer> lst = Type.A.getData();
Set<String> lst2 = Type.A.getData(); // Runtime exceptionActually, javac is telling you that giving warnings on the enum constants redefined method return types.
Edited by: stefan.schulz on Sep 10, 2008 11:38 PM

Similar Messages

  • Enums with common method implementation.

    Working with JDK 1.4 , i had some typesafe enums with common methods in an abstract class. Because of some issues, i want to migrate them to 'enums' provided in JDK 5.
    As enum provided in JDK 5 can neither be extended or derived from any other class, i am unable to achieve my objective.
    Is there any way out, or should i continue to live with my old code?
    Thanks,
    Prabhaker

    Well, there's always this ugly pretend-you-have-multiple-inheritance sort of construct:
    public class CommonEnumUtilities
        // the following method is the actual implementation of method foo
        public static void foo(Enum e, Object... otherParams)
    public interface CommonEnumInterface
        // the following ensures that you have the method foo
        public void foo(Object... otherParams);
    public enum SomeEnum implements CommonEnumInterface
        public void foo(Object... otherParams)
            CommonEnumUtilities.foo(this, otherParams);
    }I personally find this approach revolting, but I guess it's better than nothing.

  • Function or method which returns the full PDC path of webdynpro iview

    Hi All,
    I have created a webdynpro application and created a webdynpro Iview in portal and attached this view to a role.  I am looking for any standard function module or method which returns the full PCD path of the webdynpro iview, when it executed from portal.
    Regards,
    H.K.Hayath Basha.

    Well in ABAP, we don't have portal APIs to access potal catalog info.
    The only available Portal Interface is IF_WD_PORTAL_INTEGRATION
    Abhi

  • J2me Mobile client calling method which return byte[] java.rmi.MarshalExcep

    J2me Mobile client calling method which return byte[]
    java.rmi.MarshalException: Expected Byte, received: SGVsbG8gV29ybGQ=
    WebService1_Stub ws=new WebService1_Stub();
    try {
    String s=ws.getStringHelloWorld();// works fine
    byte s[]=ws.helloWorld(); // error java.rmi.MarshalException: Expected Byte, received: SGVsbG8gV29ybGQ=
    }catch(Expception e){
    ex.printStackTrace();
    }This same ws working fine in java standalone application please guide me what can be a problem ??
    Regards
    Haroon Idrees

    clear your app. server logs ( or make copies of them if will you need them) and redo the whole process. check out the logs and you should see some reason for this. i do not know if Borland's logs will turn out helpful, but it did help me out in certain other situations.

  • Enum with abstract List K method

    Hi,
    I have an ENUM which does have a abstract method
    public enum CustomerType {
    private final List<K> customerList = null;
    Business {
              @Override
              public <K> List<K>retrieve (ICustomerService processor) {
                   customerList = processor.processBusinessCustomer(Constants.BUSINESS);
         Home {
              @Override
              public <K> List<K>retrieve (ICustomerService processorType) {
                   customerList = processor.processHomeCustomer(Constants.BUSINESS);
    abstract <K> List<K> retrieve (ICustomerService service);
    The CustomerService implements ICustimerService and
    have methods
    public <K> List<K> processBusinessCustomer(String type)
    public <K> List<K> processHomeCustomer(String type)
    In the ENUM i am getting an error every where , like in the
    private final List<K> customerList = null;
    Business {
    Home {
    saying syntax error in token? delete this token?
    What I am doing wrong here? I hope the <K> List<K> with generics can be defined like this in ENUM as well?
    Please correct me where i am going wrong.

    public enum CustomerType {
    private final List<K> customerList = null;The <K> in this field declaration refers to a type parameter of the enclosing type. There are two problems with this: 1) Your enclosing type has no type parameter <K>. 2) Your enclosing type can't have a type parameter, because it is an enum, and enum types can't have type parameters anyway.
    public <K> List<K>retrieve (ICustomerService processorType) {
    customerList = processor.processHomeCustomer(Constants.BUSINESS);
    abstract <K> List<K> retrieve (ICustomerService service);These method declarations are ok, because they are generic methods where the type parameter is a parameter of the method, not of the enclosing type. Although I expect that's not what you really wanted, because the type parameter serves no purpose in these declarations since it isn't made use of anywhere within the method.

  • How do I deal with a Java method which returns a class object?

    Hi, I am using JNI to talk to some Java code from c++;
    I have a java method in class B that is defined as
    class B{
    A[] As;
    A getA(int i){
    return As(i);
    where A is one of my classes.
    I would like to know the code to deal with a returned object of type A and then how to access the variables in A from c++.
    I have defined my method pointer as :
    env->GetMethodID(B, "getA", "(I)A;");and have the jclass object of type A.
    Would I do something like jclass A_CLASS = env->FindClass("A");
    jobject A_OBJECT = (A_CLASS)env->CallObjectMethod(B,getA, i) ; If so, how do I then access the fields in A_OBJECT? Please let me know, thanks.

    ilganeli wrote:
    Thanks but this doesn't really help. I know how this is done in Java (see below).Presumably you also understand how that code will fail. At least based on what you have posted here.
    I do not understand the syntax to do the equivalent thing in JNI, specifically, how to cast the returned object from the CallObjectMethod function to be of the appropriate type, namely A, and then how to access those fields. You don't cast it. Didn't do so in your java code either.
    But you define how you are going to attempt to access any object in JNI. If you mess up it fails.

  • Autotype ant task and java source file having method which  returns hashmap

    Hi Friends,
    I am using autotype ant task to generate types.xml and supporting java classes.
    The task is defined as follows .
    <target name="std">
    <source2wsdd javaSource="HelloWorld.java"
    typesInfo="types.xml"
    ddFile="ddfiles/web-services.xml"
    serviceURI="/HelloWorldService"/>
    </target>
    In my java source i have method which is returning an HashMap. In this scenario I am getting error when i run the task. The error is as follows
    C:\test-ws\javaclass>ant auto
    Buildfile: build.xml
    auto:
    [autotype] Autotyping for javaTypes TestBean
    [autotype] weblogic.xml.schema.binding.BindingException: Invalid class received
    : interface java.util.Map loaded from file:/C:/bea/jdk142_05/jre/lib/rt.jar!/jav
    a/util/Map.class. All classes that will be serialized or deserialized must be n
    on-interface, non-abstract classes that provide a public default constructor
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.en
    sureValidClass(JavaInspector.java:1050)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.fi
    llDescriptor(JavaInspector.java:174)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.ge
    tDescriptor(JavaInspector.java:139)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.cr
    eateBeanProperty(JavaInspector.java:927)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.cr
    eateBeanProperty(JavaInspector.java:905)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.ad
    dPropertiesToScalar(JavaInspector.java:834)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.fi
    llDescriptor(JavaInspector.java:209)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.ge
    tDescriptor(JavaInspector.java:139)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.cr
    eateDescriptorForClass(JavaInspector.java:106)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.Compiler.compile
    (Compiler.java:106)
    [autotype] at weblogic.xml.schema.binding.internal.XSDTypeMappingBuilder.ma
    pClass(XSDTypeMappingBuilder.java:89)
    [autotype] at weblogic.xml.schema.binding.internal.XSDTypeMappingBuilder.ma
    pClass(XSDTypeMappingBuilder.java:102)
    [autotype] at weblogic.xml.schema.binding.internal.TypeMappingBuilderBase.a
    ddMapping(TypeMappingBuilderBase.java:180)
    [autotype] at weblogic.webservice.tools.build.internal.Java2SchemaImpl.doTy
    peMapping(Java2SchemaImpl.java:267)
    [autotype] at weblogic.webservice.tools.build.internal.Java2SchemaImpl.run(
    Java2SchemaImpl.java:167)
    [autotype] at weblogic.ant.taskdefs.webservices.javaschema.JavaSchema.doJav
    a2Schema(JavaSchema.java:302)
    [autotype] at weblogic.ant.taskdefs.webservices.javaschema.JavaSchema.execu
    te(JavaSchema.java:184)
    [autotype] at org.apache.tools.ant.Task.perform(Task.java:341)
    [autotype] at org.apache.tools.ant.Target.execute(Target.java:309)
    [autotype] at org.apache.tools.ant.Target.performTasks(Target.java:336)
    [autotype] at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
    [autotype] at org.apache.tools.ant.Project.executeTargets(Project.java:1255
    [autotype] at org.apache.tools.ant.Main.runBuild(Main.java:609)
    [autotype] at org.apache.tools.ant.Main.start(Main.java:196)
    [autotype] at org.apache.tools.ant.Main.main(Main.java:235)
    BUILD FAILED
    file:C:/test-ws/javaclass/build.xml:62: weblogic.webservice.tools.build.WSBuildE
    xception: Failed to do type mapping - with nested exception:
    [weblogic.xml.schema.binding.BindingException: Invalid class received: interface
    java.util.Map loaded from file:/C:/bea/jdk142_05/jre/lib/rt.jar!/java/util/Map.
    class.  All classes that will be serialized or deserialized must be non-interfac
    e, non-abstract classes that provide a public default constructor]
    Can any one provide the solution for this
    Thanks
    Anantha

    Hi Friends,
    I am using autotype ant task to generate types.xml and supporting java classes.
    The task is defined as follows .
    <target name="std">
    <source2wsdd javaSource="HelloWorld.java"
    typesInfo="types.xml"
    ddFile="ddfiles/web-services.xml"
    serviceURI="/HelloWorldService"/>
    </target>
    In my java source i have method which is returning an HashMap. In this scenario I am getting error when i run the task. The error is as follows
    C:\test-ws\javaclass>ant auto
    Buildfile: build.xml
    auto:
    [autotype] Autotyping for javaTypes TestBean
    [autotype] weblogic.xml.schema.binding.BindingException: Invalid class received
    : interface java.util.Map loaded from file:/C:/bea/jdk142_05/jre/lib/rt.jar!/jav
    a/util/Map.class. All classes that will be serialized or deserialized must be n
    on-interface, non-abstract classes that provide a public default constructor
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.en
    sureValidClass(JavaInspector.java:1050)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.fi
    llDescriptor(JavaInspector.java:174)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.ge
    tDescriptor(JavaInspector.java:139)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.cr
    eateBeanProperty(JavaInspector.java:927)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.cr
    eateBeanProperty(JavaInspector.java:905)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.ad
    dPropertiesToScalar(JavaInspector.java:834)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.fi
    llDescriptor(JavaInspector.java:209)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.ge
    tDescriptor(JavaInspector.java:139)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.JavaInspector.cr
    eateDescriptorForClass(JavaInspector.java:106)
    [autotype] at weblogic.xml.schema.binding.internal.codegen.Compiler.compile
    (Compiler.java:106)
    [autotype] at weblogic.xml.schema.binding.internal.XSDTypeMappingBuilder.ma
    pClass(XSDTypeMappingBuilder.java:89)
    [autotype] at weblogic.xml.schema.binding.internal.XSDTypeMappingBuilder.ma
    pClass(XSDTypeMappingBuilder.java:102)
    [autotype] at weblogic.xml.schema.binding.internal.TypeMappingBuilderBase.a
    ddMapping(TypeMappingBuilderBase.java:180)
    [autotype] at weblogic.webservice.tools.build.internal.Java2SchemaImpl.doTy
    peMapping(Java2SchemaImpl.java:267)
    [autotype] at weblogic.webservice.tools.build.internal.Java2SchemaImpl.run(
    Java2SchemaImpl.java:167)
    [autotype] at weblogic.ant.taskdefs.webservices.javaschema.JavaSchema.doJav
    a2Schema(JavaSchema.java:302)
    [autotype] at weblogic.ant.taskdefs.webservices.javaschema.JavaSchema.execu
    te(JavaSchema.java:184)
    [autotype] at org.apache.tools.ant.Task.perform(Task.java:341)
    [autotype] at org.apache.tools.ant.Target.execute(Target.java:309)
    [autotype] at org.apache.tools.ant.Target.performTasks(Target.java:336)
    [autotype] at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
    [autotype] at org.apache.tools.ant.Project.executeTargets(Project.java:1255
    [autotype] at org.apache.tools.ant.Main.runBuild(Main.java:609)
    [autotype] at org.apache.tools.ant.Main.start(Main.java:196)
    [autotype] at org.apache.tools.ant.Main.main(Main.java:235)
    BUILD FAILED
    file:C:/test-ws/javaclass/build.xml:62: weblogic.webservice.tools.build.WSBuildE
    xception: Failed to do type mapping - with nested exception:
    [weblogic.xml.schema.binding.BindingException: Invalid class received: interface
    java.util.Map loaded from file:/C:/bea/jdk142_05/jre/lib/rt.jar!/java/util/Map.
    class.  All classes that will be serialized or deserialized must be non-interfac
    e, non-abstract classes that provide a public default constructor]
    Can any one provide the solution for this
    Thanks
    Anantha

  • Abstract method which when implemented will have different parameters

    Hello to all,
    I have an assignment but not looking for someone to do it for me. I am only searching for a suggestion on how to do the following.
    Imagine having an application that needs to provide an estimate of the rent for different buildings.
    Basically I start with by having a class name Building. This class has an abstract method called estimateRent.
    I then create two classes that extend the class Building which are named Apartment and House. Both need to have the method estimateRent.
    However the problem is that the rent for the Apartment is calculated on the nights passed in the flat and the people in it, while the rent for the House is just calculated on a month bases.
    This means the estimateRent method requires to have different parameters depending if it is implemented inside the Apartment class or the House class.
    Now I only know of two options.
    The first option is to not declare the estimateRent method as an abstract method inside the Building class and just implemented inside the Apartment and House with different parameters. I do not like this option since in the future if a new Building comes in then I would like to impose the fact that that object needs to have a calculate method.
    The second option is to make the estimateRent method as abstract inside the Building class however takes a parameter of either a String array or else a Map. Then the estimateRent within the Apartment class would search for the elements tagged as nights and people, and the House class would only search for the elements tagged as months!
    However do not know if there are any other, better ways on how to do this. I am using Java 1.4 however if you only have answers for Java 5.0 then please post them again since I always like to learn something new :)
    Thank You for any comments.
    tx

    The implementation changes, yes.Yes that I could understand in the Strategy Pattern (in the document I read it was being compared with the Template Pattern).
    Then you need to refactor your design.I tought about that, however if you read my first post you will notice that I have different criteria on which the costs need to be estimated. While the costs for a flat are estimated on the people staying in and nights slept there, the costs for the house are based only on the months stayed there regardless of the people living in. Now for me I feel that it is bad programming practice to create one method that can have all the parameters required for any scenario. I mean the following is NOT something I am going to do:
    estimateCosts(int nights, int people, int months ... etc);
    That's not a very elegant way of going about it.
    What is the "Context" going to have?Yep I agree, but so far my limited brain has only come up with that! I am open to any other sugestion! always if i understand it first!
    Basically the Context would better be named as Criteria and it would be an interface as follows:
    interface Criteria{}
    Then I would create two classes that implement the Criteria object as follows:
    class AppartmentCriteria implements Criteria{
    public Result estimateCosts(int nights, int people);
    class HouseCriteria implements Criteria{
    public Result estimateCosts(int months);
    Now when I recieve the inputs, depending on the scenario the Criteria is typecasted and the correct parameters passed and we recieve the Result.
    I feel the above sucks since I am not seeing it as an object oriented way of doing this out! Is there any other sugestions! The refactoring thing I am intrested in! however really I can not see how such a call to that method could be refectored!
    Thank You,
    tx.
    PS: Sun has blocked my other account as well, and this time they did not even send me an email to confirm that I was registered successfuully :( Is there someone I can contact on this? I guess next time I will reply with tx53m :)

  • Enforce setting private variable in subclass with abstract method

    Hi,
    Is this something that is common usage/practice?:
    public abstract class Base {
        private int importantPrivateVariable = setImportantPrivateVariable();
        protected abstract int setImportantPrivateVariable();
    }I would like to enforce the extender of the class to set a private variable, but as there is no abstract variable in java, I can only use a method for it.
    Thanks,
    lemonboston
    Edit: the variable could be protected as well, I suppose this is not important here, but correct me if I am wrong

    lemonboston wrote:
    Hi,
    Is this something that is common usage/practice?:I don't think that's so common, but that's code easily understandable. However there are several problems with this approach:
    public abstract class Base {
    private int importantPrivateVariable = setImportantPrivateVariable();
    protected abstract int setImportantPrivateVariable();
    }I would like to enforce the extender of the class to set a private variableThat's no what your code implements: your base class forces the subclasses to return an int value, and the Base class uses that value to assign it to the variable.
    Therefore the method should be called get<Something> (e.g. <TT>getInitialValueOfImportantVariable()</TT>+ to have a naming consistent with its signature (it returns a value, whereas a regular setter method should declare a void return type: <TT>protected abstract void setImportantPrivateVariable(int someValue);</TT>).
    Edit: the variable could be protected as well, I suppose this is not important here,Well, yes, this is "important" - at least, there a noticeable difference: the variable being private, the base class is free to handle it as it sees fit (e.g., assign the value at construction time and never modify it afterwards). If the variable was protected, the subclass could modify in ways and at times not known by the base class.
    but correct me if I am wrongThere's a trap in this construct: the method is called in the variable initializer, that is, behind the scenes, approximately during the execution of the Base class constructor, so before the subclass constructor. So, you are calling a method on an object that is not fully initialized (e.g. some of its attributes may still be <TT>null</TT> at this stage). There is a rule that discourages such situations, that goes something like "don't call non-private and non-final methods from a constructor".
    To avoid this trap, two options:
    - require an int argument in the Base class's constructor , as was suggested above
    - don't get and set the value of the important variable in the initializer or constructor code, but from a special method in the base class instead:
    public abstract class Base {
        private int importantPrivateVariable; // default value is zero
    // or alternatively:
    //    private int importantPrivateVariable = ...; // Some default value
        protected abstract int getImportantPrivateVariable();
        public void initializeImportantPrivateVariable() {
            importantPrivateVariable = getImportantPrivateVariable();
    }That construct is a degenerate form of a common design pattern known under the name of Template Method (where a base class method calls generally several subclass methods in a specified order and with a specified chaining, leaving it to the subclass to implement the details of the methods).
    The drawback is that the client code (the one that uses the Base instance) has to know when to call that initialization method, whereas the constructor-based initialization lets the client code free to not care at all.
    Much luck,
    J.

  • Looping over method which returns a query

    HI,
    I have a method that returns a query, I pass into this method
    a ID number, which the query uses in the where clause. Now I have
    another query which returns a list of ID numbers that I loop
    through calling the first method and passing in the ID number, for
    example
    methodA
    loop through methodA results
    call methodB passing in methodA.ID
    get results from methodB
    close loop
    now the problem I'm having is that methodB returns a query
    and I want to be able to return the results from methodB as one
    single query structure. I'm not sure how many times I will loop
    through the results from methodA, it could be twice, it could by
    ten time. So the results from calling methodB could be very large.
    How can I add the results from methodB into one single query
    structure?

    how about creating an empty query with cfset newQuery =
    QueryNew([list of columns]);
    and then on each loop through method B add a new row to this
    new query, and then return that query as result?

  • Proces chain decision with formula method: which proces chain is performing

    I want to know which chain is processing while i am in a decision. I made a decision in a proces chain. From that decision i call a formula. In that formula i call a method which i defined myself (client specific fomula/method). Now i want to know from which proces chain this method has been called. I tried the following ABAP statements in this method:
    IMPORT instance TO l_instance
    log_id TO l_logid
    chain_id TO l_chainid
    FROM DATABASE rspc_buffer(ab)
    ID i_chain.
    I found this statements in another SDN thread and from experience i know it works fine when you process normal ABAP in your proces chain.
    Unfortunately this does not work in a method from a decision. Maybe i need to access another table?
    Any suggestions?

    Ok, if you worry about that, let's do it in series...
    you create a local chain per IP/DTP (with link "if succesfull")...so you will have 10 local chains
    then create a big chain with these 10 local chain (with link "always")
    so, if a IP (eg of loacl chain 1) fails the DTP will not be triggered, the local chain 1 will go to status red, but as you put between the local chain option "always", the local chain 2 will start...and so on
    For inforamtion, I would put the attribute change run for the specific attribute in the local chain...this way you will only activate data of succesfull IP/DTP's...
    this way you should achieve what you aim for...
    M.

  • Ajax call method which return json Data

    Hi, I make one function , which i want to return json value , for this which return type i mention in function:
    This is javascript which call Retrieve method.
    <script>
    debugger;
             var remoteDatasource = new kendo.data.DataSource({
                 transport: {
                     read: {
      type:"POST",
      url: "Controllers/Home.cfc",
      dataType: "json",
                         data: {
      method: "Retrieve",
                             dataLists: JSON.stringify(request)
    </script>
    Home.cfc
    component
    remote   function Retrieve(string dataLists)
      try
                q = new Query();
                q.setsql("SELECT * FROM Product");
                qResult = q.execute().getresult();
                col_len = ListLen(qResult.Columnlist);
                dataArray = ArrayNew(1);
                row = 0;
                col = 0;
                for(row = 1; row <= len; row++)
                     for(col = 1; col <= col_len; col++)
                          FieldName = ListGetAt(qResult.Columnlist, col);
                          dataArray[row][col] = qResult[FieldName][col];
          jsonvar=serializeJSON(dataArray);
      catch(any e)
    return jsonvar;

    One can see immediately that you have to make the following corrections, at least:
    Give the query a name;
    Point the query to a datasource;
    Define the variable 'len' (even better, use a different, less confusing, name for the variable).

  • Handling Methods which return Objects

    I have a class called GenericObjectQueue, which essentially maintains a queue of objects.There is a method called getTopObject() which returns the first Object in the queue.
    I use this class to maintain a queue "CustomerQ" of objects of the class "Customers ".Now when i write the following statements i get an error
    customer firstcust= new customer();
    firstcust= CustomerQ.getTopObject();
    The compiler says incompatible types,
    found : java.lang.Object
    required: customer
    How do I deal with this?
    Thanks...RJ2

    method called getTopObject() which returns the first
    Object in the queue.Another way is to set the return type as 'Customer' in place of Object and return a Custome

  • To_date function in procedure which returns a cursor type

    Hi All
    When i execute the following query ,it runs fine and i get required result also
    select *from a where adate>to_date('31-dec-2001')
    But When i use the same query in a procedure which returns a cursor i get a error
    "non numeric character was found where a numeric value was expected".
    Then i changed the query to
    select *from a where adate>to_date('31-dec-2001','dd-mon-yyyy') and it worked fine.
    As i know default date format is 'dd-mon-yyyy' and no need to give the date format
    explicitly in to_date function if the date(string) is in default format.
    Can any body tell me the reason behind it?
    Thanks
    Satya

    Given a comparison between a date and a string Oracle will convert the string to a date. This means that if you have an index on a string column and compare it to a date the index will not be available, but if you have an index ona date column and compare it to a string column the index will be available.
    create table t (string varchar2(30), d  date);
    insert into t values (to_char(sysdate), sysdate);
    commit;
    create index t_n1 on t(string);
    create index t_n2 on t(d);
    SQL> set autotrace traceonly
    SQL> select /*+ index t_n1 */
      2         *
      3    from t
      4   where string = sysdate;
    no rows selected
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE
       1    0   TABLE ACCESS (FULL) OF 'T'
    SQL> select /*+ index t_n2 */
      2         *
      3    from t
      4   where d = to_char(sysdate);
    no rows selected
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE
       1    0   TABLE ACCESS (BY INDEX ROWID) OF 'T'
       2    1     INDEX (RANGE SCAN) OF 'T_N2' (NON-UNIQUE)
    SQL>

  • Overriding abstract methods with generic argument

    Hi,
    This post is similar to the one posted just before it :
    [http://forum.java.sun.com/thread.jspa?threadID=5281500|http://forum.java.sun.com/thread.jspa?threadID=5281500]
    I am trying to override an abstract method which has a generic argument and a problem occurs. I would like to find out whether what I am trying to do is not legal. The point of interest here is that the overriding class reduces the scope of the abstract class.
    The Abstract class AbstractAdapter defines accessors for a collection containing objects derived from AbstractPort. (<? extends AbstractPort>)
    The overriding class Adapter overrides these accessors but reduces the scope of the collection objects from <? extends AbstractPort> to <Port>. Port
    Here is my abstract class:
    public abstract class AbstractAdapter {
         public abstract Collection<? extends AbstractPort> getPorts();
         public abstract void setPorts(Collection<? extends AbstractPort> ports);
    }And here is the class that overrides it:
    public class Adapter extends AbstractAdapter {
         public Collection<Port> getPorts() {
              return null;
         public void setPorts(Collection<Port> ports) {
    }The Port class is shown here:
    public class Port extends AbstractPort {
    }Edited by: BenDave on Apr 2, 2008 4:39 AM

    It's not really the same.
    I don't have a compiler to hand, so this is off the top of my head. I expect you want something like this:
    public abstract class AbstractAdapter<T extends AbstractPort> {
         public abstract Collection<T> getPorts();
         public abstract void setPorts(Collection<T> ports);
    public class Adapter extends AbstractAdapter<Port> {
         public Collection<Port> getPorts() {
              return null;
         public void setPorts(Collection<Port> ports) {
    }

Maybe you are looking for

  • Itunes no longer imports calendars into my ipod

    My first problem was that iTunes would only transfer over certain calendars, not all that I had selected. On top of that, some, but not all, of the start times were an hour later than my iCal calendars. And, I've been having issues with disappearing

  • Photoshop CC 2014 3D menu functions greyed out

    I can't seem to get 3D options enabled in CC 2014.  I'm using a 2012 Macbook Pro Retina with 16gb of ram & a 1GB 650m running 10.9.3 and that well exceeds the system requirements. I have "Use graphics processor" selected in the performance tab and th

  • Illustrator CS2 Font Error

    I am able to create an artwork using the tools etc. and save successfully. Although when I add text to the artwork and attempt to save, I receive the message "An unknown error" and the program either freezes or refuses to save. I believe the problem

  • Problem synch mp4 videos with n95 and noki photos

    I have a problem with synchronising mp4 video's I have the following error: Nokia M Platform 1.5.128 (NLib 0.7.337) File is corrupt. errorcode: 51030 Filename: C:\Users\Giovanni\AppData\Local\Temp\SyncMLTemp\19​032008071.mp4 Item: MItem GUID: {020c25

  • Aperture/iphoto missing masters

    I'm praying that someone can help me.  I use iPhoto and Aperture both.  I have about a 60GB library that hold approaximately 22,000 images.  I run my programs on the OSX Drive which is an 128GB SSD and I store the photos on a separate internal 750GB