Wildcards in type declarations or only methods?

Can you declare wildcards in type declarations such as:
public class ListManager<List<?>> {
}When I try this, I get the following compiler errror:
C:\dev\hcj\tiger\src>c:\j2sdk1.5.0\bin\javac -source 1.5 oreilly/hcj/tiger/*.java
oreilly/hcj/tiger/ListManager.java:21: > expected
public class ListManager<List<?>> {
                             ^
oreilly/hcj/tiger/ListManager.java:31: '{' expected
^
2 errorsWhat am I doing wrong [if anything]?
TIA
-- Kraythe

public class ListManager<List<?>> {
}When I try this, I get the following compiler errror:Hmm .. I was thinking about this. .. What i was trying to declare was a class that would use as a parameter any declaration of a List. So what I want is a class that will take List<Integer> and List<String> and so on. So the result would be to use it like this:
public void someMehtod() {
    ListManager<List<String>> strListMger = ...
    ListManager<List<Integer>> strListMger = ...
}So if not with the wildcard, how is this accoplished (if it can be accomplished at all).
I would also like to do something like:
public class ListManager<Type extends List<?>> {
}In this manner I would at least have access to the type. Except the extends is a misnomer since i want type to be any List<> type.

Similar Messages

  • Dynamic Data Type declaration from Parameter value

    Hi,
      I have a silly question..
    Is it possible to dynamically declare a variable based on the contents of a parameter...like:
    Tables: RSDUPD.
    Parameter: p_Daty like RSDUPD-DATU
    Data: l_last_day like (p_Daty)
    Thanks

    ok....thanks for the answer but its time to make the question harder. 
    I have the following code:
    DATA: it_query_results TYPE REF TO data.
    PARAMETER: prxy_cls(30).
    CREATE DATA it_query_results TYPE STANDARD TABLE OF (prxy_cls).
    ASSIGN it_query_results->* TO <l_it_query_result>.
    ....I do all sorts of processing with <l_it_query_result>.....then
    CALL METHOD o_query_result->execute_asynchronous
        EXPORTING
           output = <l_it_query_result>.
    only problem is method execute_asynchronous doesnt expect a type ref and only expects table type ZBWCOPA9030V00_QUERY_RESULT1...which is what I am entering in the parameter prxy_cls..
    need help badly..
    thanks

  • SAXParser type declaration not found - PLEASE HELP!!

    I am using XML to parse an incoming string of XML. I want to use an SAXParser to do this, but I cannot create an object of this type. I have the jar file jaxp.jar, xalan.jar, and crimson.jar in my classpath.
    Is there anything else that I need to do in order to get the parser to work.
    This is a very urgent need so any help is appreciated. Here is the error:
    Class SAXParser not found in type declaration;

    I have figured out the issue. Thanks for the help. I do have one more issue though. I am trying to parse a string of xml data and I need to pass my parse() method an InputSource object that I guess I will make from my incoming String.
    Any thoughts on how to do this?

  • Error:xml declaration may only begin enttties

    my problem is that the code by the name DomEcho01.java in this tutorial
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
    compiles fine but at run time it gives me an error saying
    "error:xml declaration may only begin enttties "
    can ne1 tell me y is this happenin
    thanx
    sam

    <?xml version='1.0' encoding='utf-8'?>
    <!--  A SAMPLE set of slides  -->
    <slideshow
        title="Sample Slide Show"
        date="Date of publication"
        author="Yours Truly"
        >
        <!-- TITLE SLIDE -->
        <slide type="all">
          <title>Wake up to WonderWidgets!</title>
        </slide>
        <!-- OVERVIEW -->
        <slide type="all">
          <title>Overview</title>
          <item>Why <em>WonderWidgets</em> are great</item>
          <item/>
          <item>Who <em>buys</em> WonderWidgets</item>
        </slide>
    </slideshow>i am using the same xml file that is given in the tutorial

  • Enum declaration in a method

    An enum can be declared inside or outside a class, but can't be declared in a method.
    Can anyone tell that what is the problem with it. for what reason this restriction exist?
    Thanks in advance

    Karanjit is right. Nested interfaces and enums both are implicitly static. And their Constants are always (also when defined in top level) implicitly static. As we can't have static types inside a method we can't define enum in a method.
    I read in "Sun Certified Programmer for Java 5 Study Guide" written by Bert Bates and Kathy Sierra that if we have following enum:
    enum CoffeeSize { BIG, HUGE, OVERWHELMING }then we can think of this enum as a kind of class, that looks something (but not exactly) like this:
    class CoffeeSize {
         public static final CoffeeSize BIG = new CoffeeSize("BIG", 0);
         public static final CoffeeSize HUGE = new CoffeeSize("HUGE", 1);
         public static final CoffeeSize OVERWHELMING = new CoffeeSize(
                   "OVERWHELMING", 2);
         public CoffeeSize(String enumName, int index) {
              // stuff here
         public static void main(String[] args) {
              System.out.println(CoffeeSize.BIG);
    }Also see this code which is compilable:
    class HaveEnum {
         enum Colours {
              BLACK, WHITE
         static class StaClass {
              public static final StaClass sc = new StaClass();
         class InstClass {
              public final InstClass ic = new InstClass(); // can't be declared static
    public class General {
         public static void main(String[] args) {
              HaveEnum.StaClass hes = HaveEnum.StaClass.sc; // (1)
              HaveEnum.Colours col = HaveEnum.Colours.BLACK; // (2)
              HaveEnum he = new HaveEnum(); // (3)
              HaveEnum.InstClass hei = he.new InstClass().ic; // (4)
    }We can have enum constant BLACK in General class (at (2)) in similar way as StaClass constant sc (at (1)). If enum Colours were instant type like InstClass inner class then for having BLACK constant in General we would have to first instantiate HaveEnum class (like at (3)) and then using its object reference we could get BLACK constant (something like this) (like for InstClass at (4)):
    HaveEnum he = new HaveEnum();
    HaveEnum.Colours col = he.new Colours().BLACK;Note that main() method will throw StackOverflowError at runtime because (4) tries to recursively create another InstClass object.

  • Declaring namespaces ONLY on root element during serialization

    I'm using JAXP 1.3 and I'd like to be able to serialize a document so that the namespace declarations are only specified once on the root element and not repeated throughout the document.
    I'm working on a journal publication system and the request came from our users (i.e., editors) who say the repeated declarations are distracting when editing the XML. They are using an XML editor (Arbortext), but when they have the view set to display tags all the namespace declarations really clutters up the screen. In particular, we use the MathML namespace:
    <m:math overflow="scroll" xmlns:m="http://www.w3.org/1998/Math/MathML">
    Can this be done?
    Thanks,
    Jeff Bailey

    It's just declared on on the root element on the input file.
    I just tried what you suggested and it worked great. The mathml namespace is only declared on the root element in my output file now.
    Odd that there's a difference between the two methods. For posterity, here's the code I used to serialize the XML:
    TransformerFactory transformerFactory = TransformerFactory
    .newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.METHOD, "xml");
    transformer.setOutputProperty(OutputKeys.ENCODING, "US-ASCII");
    transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC,
    doc.getDoctype().getPublicId());
    transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,
    doc.getDoctype().getSystemId());
    OutputStream outputStream = new FileOutputStream(new File(
    "C:\\temp\\foo.xml"));
    transformer.transform(new DOMSource(doc),
    new StreamResult(outputStream));
    Thanks very much for your help.
    Jeff

  • Adding XML Declaration and Document Type Declaration.

    I'm using Oracle's XML Class Generator C++ version 1.0.2.0.0. I can create classes from a defined external DTD and create my XML document. But the document does not contain the XML Declaration <?xml version='1.0?> nor does it contain the Document Type Declaration <!DOCTYPE root-element-name SYSTEM "system-identifier">. What do I need to do to get these as part of my XML document? Does the class generator have methods to do this? Could someone show me an example?

    If you invoke the print method on the top-level ELEMENT, you get
    just the body of the document with no DTD or XMLDecl. if you invoke
    print on the top level NODE (the DOCUMENT node), then the output
    document will contain the XMLDecl and DTD.
    So please try to print from DOCUMENT node.

  • Global Type declaration/definition of name duplicated error

    Hi, All,
    We have two EJB exposed as the Webservice , so WS-1 and WS2, When I insert these two WS into the SOA Application to used by BPEL process. I get the compile error from jdev(11.1.1.1.3) like this:
    Global Type declaration/definition of name '{http://mynamespace-here/oracle}SearchParameter' are duplicated at the following locations:
    EJB WS1 xsd line ***
    EJB WS2 xsd line ***
    SearchParameter is bean SearchRequest‘s property, this bean is shared using in two EJB method interfaces.
    Our class design like this:
    @XmlRootElement
    @XmlType(name = "SearchRequest",
    namespace = " http://mynamespace-here/oracle ")
    public class SearchRequest
    implements Serializable
    private SearchInterface searchCriteria;
    @XmlElements(value =
    { @XmlElement(name = "SearchParameter",
    type = SearchParameter.class) })
    public SearchInterface getSearchCriteria()
    return searchCriteria;
    At here SearchInterface is an empty interface and SearchParameter is a class implement this interface.
    I feel @XmlElement in fact cause this duplicated error.
    So in this case, how can we expose this SearchInterface/SearchParameter through the XML properly?
    Thanks .
    wayne
    Edited by: user782942 on Feb 8, 2011 11:37 PM

    If the message type in the external service and the one using in your local are using the same schema, could you check whether the external service has changed the schema in any way? Adding new fields, changing the field name, or changing the namespace? We had faced this issue before, and it was because the schema in our mds is different from the schema from OSB, which they changed it after we get the artifacts and we didn't have the updated schema in our mds.

  • Annotation Type Declaration

    Why in anno type declaration some types look like methods ?
    Example:
    public @interface MyAnnotation {
       String doSomething();                   //HERE
       int count; String date();                 // int is fine but , String , why its a method ?
    Usage:
    @MyAnnotation (doSomething="What to do", count=1,
                   date="09-09-2005")
    public void mymethod() {
    }

    ya ..
    it says
    "The annotation type definition looks somewhat like an interface definition where the keyword interface is preceded by the @ character (@ = "AT" as in Annotation Type). Annotation types are, in fact, a form of interface, which will be covered in a later lesson. For the moment, you do not need to understand interfaces.
    +The body of the annotation definition above contains annotation type element declarations, which look a lot like methods. Note that they may define optional default values.+ "
    But does not explain why they are metods , observe in the above example that ,
    primitive int is directly declared , not as a method ,
    Then all should be methods ..

  • Capturing packages with type declarations

    I have a lot of packages written in ddl files and want capture them with Designer 9i. However it seems not possible because type declarations are put not as Datastructures but as text in Package Specification field and therefore are generated after procedure declarations in package specification. Is there some methods to capture packages correctly?

    Hi,
    Can you send me an example of your problem so I can investigate it further?
    Rgds
    Susan
    Designer Product Management

  • Flex warning: variable has no type declaration

    I need to  dynamically create several Form or Panel, called MyForm1, MyForm2, MyPanel1, MyPanel2, ... They are different because of the children in the Form or Panel. I also added some addtional public methods (method1, method2 ...) to the <mx:Form> or <mx:Panel>.
    I have a function, called myFactory,  that returns the MyForm1, MyPanel1... for me according to the input parameters. It is defined something like:
    function myFactory(input:String):DisplayObject {
    I tried two ways to call myFactory.
    1.
    var myViewObj:DisplayObject = myFactory(input:String); // no error. no warning.
    myViewObj.method1(); // compilation error because DisplayObject dose not have method1
    2.
    var myViewObj = myFactory(input:String); // no error, but got warning: variable has no type declaration
    myViewObj.method1(); // it works fine.
    It looks like the type of myViewObj is the actual type of myFactory retures, which could be one of MyForm1, MyPanel1....
    My questions are
    1. Is there a way I can declara a type to myViewObj to get ride of  warning.
    2. what type myViewObj should be called? generic type?

    In case your custom Form and Panel components share same method names (with different functionality), you can create an Interface with the common methods declaration and have both components implement it.
    This way you can declare the new interface as the returned type and invoke the common methods that it have.
    Thia is sort of a Polymorphism technic, a subject where you can read more about in the following page -
    http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming
    Good luck!

  • How to use %Type declaration with table residing in a different database

    How can I use the %TYPE declaration if the table is from a different database.
    E.g
    v_business_unit ps_jrnl.header.business_unit%TYPE;
    In the above declaration statement,the table 'ps_jrnl_header' resides in a different database(Database A) from the one I am currently in( Database B).(This is because data needs to be extracted from Database A into Database B).

    1. Create a database link to the other database (this probably already exists since your proc is interacting with that database)
    2. Create a synonym for the table in the other database
    create synonym foo for ps_jrnl.header@database_a;3. Reference the synonym in your variable declaration:
    v_business_unit  foo.business_unit%TYPE;

  • I have a 16 year I support that lives in Haiti. He has a computer, but is not able to charge on a credit card.  If I purchase prepaid Itunes gift cards, is he able to set up a Itunes account and use these gift cards. That would be his only method of pay

    I have a 16 year I support that lives in Haiti. He has a computer, but is not able to charge on a credit card.  If I purchase prepaid Itunes gift cards, is he able to set up a Itunes account and use these gift cards. That would be his only method of pay

    Hi judifrom!
    I have some links for you that can help shed some light on the subject of gifting through iTunes and Apple IDs. The first can be found in this link:
    Gifting - Apple Store (U.S.)
    http://store.apple.com/us/help/gifting
    and the relevant information in that link can be found right here:
    Gift Cards and Certificates are valid for use only in the country in which they were purchased. Only residents of the U.S may redeem gift certificates purchased in the U.S.
    You can still help them set up an Apple ID without payment information so that they can download free items through the iTunes store though. The steps for performing that can be found in the following article:
    Creating an iTunes Store, App Store, iBookstore, and Mac App Store account without a credit card
    http://support.apple.com/kb/ht2534
    Thanks for using the Apple Support Communities!
    Cheers,
    Braden

  • Make "File name" and "Files of type" fields read-only in JFileChooser

    I try to make the "File name" and "Files of type" fields read-only in JFileChooser dialog. Anybody
    knows how to do? Thanks.

    You mean so the user can't choose the name of the file to open or save? Not much point in even using a JFileChooser, then, is there? Or did I misunderstand the question?

  • "Global Type declaration duplicated", cached xsd conflicting in jdeveloper?

    We're having problems recompiling a project after changing a schema in a second project on which it depends:
    Our HR composite app imports a schema from our FaultHandler app. I added 2 new elements to the FaultHandler schema and redeployed to the server - now our HR composite app won't recompile. It errors saying:
    [scac] error: in EmpTransformSynch.bpel(87): query "/ns9:HandleFaultRequest/ns9:TimestampeInit" is invalid, because Global Type declaration/definition of name '{http://mydomain.com/SOA/FaultHandler}HandleFaultRequestType' are duplicated at the following locations:
    [scac] http://mydomain.com:8001/soa-infra/services/default/FaultHandlerProject/xsd/FaultHandler.xsd [line#: 4]
    [scac] http://mydomaincom:8001/soa-infra/services/default/FaultHandlerProject/FaultHandler?XSD=xsd/FaultHandler.xsd [line#: 7]
    [scac] There are at least two of them looking different:
    [scac] http://mydomain.com:8001/soa-infra/services/default/FaultHandlerProject/xsd/FaultHandler.xsd [difference starting at line#:16]
    [scac] http://mydomain.com:8001/soa-infra/services/default/FaultHandlerProject/FaultHandler?XSD=xsd/FaultHandler.xsd [difference starting at line#:19]
    I can view the 2 URIs in my browser, and while they differ slightly in how they reference another schema, the schemas (and imported schema) are semantically equivalent.
    We've taken the following steps to try to resolve it:
    Undeploy the previous revision of Fault handler
    Restart soa server
    Redepoy Fault Handler
    Clean HR app
    Make HR app
    We have the issue in both jdeveloper 11.1.1.3.0 and 11.1.1.4.0
    This is surely something very simple, but it's blockiing us at the moment.
    Any help much appreciated.
    ..Garret
    Edited by: user10714498 on 09-Mar-2011 02:27

    If your schema contains any characters which will be escaped when parsed by a browser, then version present in the actual .xsd and the version referenced via HTTP server will be different causing the issue.
    If you can post the content of your actual schema (as you see it in jDev and not the one opened in the browser) here it will help identifying the issue if any.

Maybe you are looking for

  • Unable to insert date and time when using date datatype

    Hi I am hitting a bit of a problem when using the date datatype. When trying to save a row to the table where the field it throws an error ora 01830 and complains about converting the date format picture ends...etc. Now when I do the insert, I use th

  • Error while trying to deploy a cube

    I am getting an error message while trying to deploy a cube. OWB Client version is 10.2.0.1.31 and the repository version is 10.2.0.1.0 Below is the piece of code that generates the error: BEGIN CWM2_OLAP_CUBE.ADD_DIMENSION_TO_CUBE('EXPENSE_WH', 'REL

  • 30 gb shuts off when shuffling...

    Hello, I've had my 30gb for about a month now, and I've had just a few quirky issues with it. Mainly, when I set it to shuffle all songs, after a certain amount of time/songs, the thing shuts off, then turns back on. I'm not sure if this is something

  • My iMac screen is black

    When I turn on my iMac it starts fine but when it comes to showing the display screen all I get is a black screen.  I have run several troubleshooting tests and trials and nothing is helping. My iMac is from 2008 and has a 24" screen. Can anyone help

  • Problem when using SDO operations

    Hello everyone, I'm trying to execute some spatial SQL queries and I've come up with a problem: If I enter the following query, the spatial operation (in this case SDO_INSIDE) is executed perfectly and data is returned: SELECT SUM(fact.quant) as SUM_