Generic methods and inheritance

Hello,
I have a class structure like this:
A - - - - > IA (A implements IA)
C - - - - > IC -------> IB (C implements IC extends IB)
In IA I have a method create that returns <T extends IB<T>>:
public interface IA {
    public <T extends IB<T>> T create();
}IB:
public interface IB<T> {  
}IC extends IB like this:
public interface IC extends IB<IC> { 
}C implements IC:
public class C implements IC{
}Finally the problem: I wan to implement A in order to return an IC in the create method:
public class A implements IA{
    public IC create() {
        IC c = new C();
        return c;
}This compiles but I get this warning: 'A.java uses unchecked or unsafe operations.'
What is the proper way to create such a structure?
Thanks,
Miguel

you can try giving more horrible things, like giving the class you want in the method params, like :
create(Class<IB> clazz);and then use reflection to create the instance :
clazz.getInstance();But it's quite heavy, I think...

Similar Messages

  • Generic Collections and inheritance

    Hi all
    I have the following code:
    public class GenericTest {
         public static <T,C extends Collection<T>> C process(C collection){
              // do some stuff (using T)
              return collection; // just to make a complete methode
         public void main(String[] args){
              List<String> l1 = new ArrayList<String>();
              List<String> l2;
              l2 = process(l1); // does not compile
    }Compilation fails with message :
    Bound mismatch: The generic method process(C) of type GenericTest is not applicable for the arguments (List<String>) since the type List<String> is not a valid substitute for the bounded parameter <C extends Collection<T>>     
    My questions:
    why doesn't it work?
    How do I fix it?
    regards
    Spieler

    What Compiler are you using?
    Your code compiles just fine on the JDK 1.5 compiler (once I added an inport for java.util.*)
    If the error message is from your IDE, you should check your IDE's web site for an existing bug, and for assistance.
    This is not the correct forum since your code compiles on the SUN JDK.
    Bruce

  • Generic method and wildcards

    Suppose I have this simplified code to do dynamic mapping between specific classes. My question is: the addItem and getItem functions
    are pretty similar however addItem compiles fine and getItem raises compilation error:
    Type mismatch: cannot convert from Class<capture#5-of ? extends List<? extends Object>> to Class<P>
         private Map<Class<? extends Object>,
         Class<? extends List<? extends Object>>> map =
              new HashMap<Class<? extends Object>,
              Class<? extends List<? extends Object>>>();
         public Test() {
              getItem(Object.class);
         public <T extends Object, P extends List<T>> void addItem(Class<T> clz, Class<P> list) {
              map.put(clz, list);
         public <T extends Object, P extends List<T>> Class<P> getItem(Class<T> clz) {
              return map.get(clz);
         }

    Sergey_M. wrote:
    OK, thank you for the response. Then the actual question is how to achieve this functionality:
    1)Store mapping between two referenced classes, for example, Class<? extends MyClass> and Class<? extends List<? extends MyClass>>.
    I mean if we have class MyClass then pair will be (MyClass.class, MyList.class) where MyList implements List<MyClass>.The way you were doing it is fine.
    2)Provide generic method to get second class by supplying the first one.You can do this fine, but the exact type of list will of course be unknown by the calling code (if it knew the type of list it needed, why bother calling getItem in the first place?).
    Just change your method to:
    public <T extends Object> Class<? extends List<?>> getItem(Class<T> clz) {
              return map.get(clz);
         }And by then even the T is not needed, just use:
    public Class<? extends List<?>> getItem(Class<?> clz) {
       return map.get(clz);
    }I am fairly, but not fully sure that you never need <? extends Object>, as that is always just a more verbose way of saying <?>.

  • Generic classes and inheritance

    I am in the midst of converting some database object code over to split the data from the database functionality, and I am coming into issues with generics.
    I have three bean classes:
    abstract public class Payment {
      // common fields and their get/set methods
    public final class AU_Payment
    extends Payment {
      // extra fields and their get/set methods
    public final class US_Payment
    extends Payment {
      // extra fields and their get/set methods
    }The code to write these classes to the database used to be in those classes, now I am moving them out to their own classes. I need to have a similar hierarchy so I can obtain an instance of the right class (through a factory) to write these objects to the database.
    public interface PaymentDB<T extends Payment> {
      public Result load(Connection conn, T payment, ResultInfo resultInfo) throws SQLException;
      public Result loadAll(Connection conn, List<T> allPayments, ResultInfo resultInfo) throws SQLException;
    }If I have the code for the AU_PaymentDB as the following, it won't compile:
    public class AU_PaymentDB<AU_Payment> {
      public Result load(Connection conn, AU_Payment  payment, ResultInfo resultInfo) throws SQLException {
        return null;
      public Result loadAll(Connection conn, List<AU_Payment> payment, ResultInfo resultInfo) throws SQLException {
        return null;
    }the compiler complains that the class doesn't override the interface, and I need to recode it to the following to get it to compile:
    public class AU_PaymentDB<AU_Payment> {
      public Result load(Connection conn, Payment  payment, ResultInfo resultInfo) throws SQLException {
        return null;
      public Result loadAll(Connection conn, List payment, ResultInfo resultInfo) throws SQLException {
        return null;
    load now takes just a Payment in it's signature list, and loadAll takes an untyped List.
    This means I can actually call load() with a US_Payment and it works fine, which I don't want. Also, I cannot add an AU_Payment to the list in loadAll, because the list is of the wrong type.
    How do I fix this? I want the AU_PaymentDB class to only act upon AU_Payments, and I need the loadAll to be able to add new AU_Payments to the list that is passed in.
    I hope this all makes sense,
    Chris

    ok, I'm assuming that you just forgot to paste in that AU_PaymentDB implements PaymentDB :-)
    parameterize AU_PaymentDB as follows:
    public class AU_PaymentDB implements PaymentDB<AU_Payment> {
      public Result load(Connection conn, AU_Payment payment, ResultInfo resultInfo) throws SQLException {
        return null;
      public Result loadAll(Connection conn, List<AU_Payment> payment, ResultInfo resultInfo) throws SQLException {
        return null;
    }so the interface defines a looser parameter ( Payment ) and your implementation drills it down to more specifically AU_Payment
    Bob, I believe, is your uncle

  • Generic method and HashMap.

    I've the following code. The compiler throws error. for the following code. I need this in an project. My objective is to allow multiple type for the first parameter of the method "meth". One implementation of someInterface supports one type, another implementation of someInterface supports other types.
    Why the compiler throws error for the method that is shown as bolded.
    public interface someInterface<T>
    public<U> void meth(U param1, T param2);
    public class someClass implements someInterface<HashMap<Enum, Object>>
    public<HashMap<Enum, Object>> void meth(HashMap<Enum, Object> param1, HashMap<Enum, Object> param2)
    If i implement the method in the following way no compilation error is showing up. Why is this?
    public<String> void meth(String param1, HashMap<Enum, Object> param2)
    null

    Hi dannyyates, thanks for your response. Here is the following code that produces compilation error. Can you help me to know why this error is coming. It will be of great help to me.
    It is strange to me the method generic works for String, but not working for HashMap<Contact, Object>.
    My objective is to allow multiple type for the first parameter of the method "meth". One implementation of someInterface supports one type, another implementation of someInterface supports other types.
    I'm getting the following error for the below code:
    "gen.java": > expected at line 31, column 15
    "gen.java": illegal start of type at line 34, column 1
    "gen.java": <identifier> expected at line 33, column 2
    "gen.java": '(' expected at line 34, column 1
    gen.java
    import java.util.HashMap;
    interface someInterface<T>
    public<U> void meth(U param1, T param2);
    enum Contact
      NAME, NUMBER
    // This class need first parameter for meth as HashMap<Contact, Object>
    class someClass1 implements someInterface<HashMap<Contact, Object>>
    public<HashMap<Contact, Object>> void meth(HashMap<Contact, Object> param1, HashMap<Contact, Object> param2)
    // This class need first parameter for meth as String
    class someClass2 implements someInterface<HashMap<Contact, Object>>
    public<String> void meth(String param1, HashMap<Contact, Object> param2)
    public class gen
      public static void main(String args[])
    }Message was edited by:
    mkumar180875
    Message was edited by:
    mkumar180875
    null
    Message was edited by:
    mkumar180875

  • Generic and Inheritance, how to use them together?

    Hi guys, I am trynig to design some components, and they will use both Generics and Inheritance.
    Basically I have a class
    public class GModel <C>{
        protected C data;
        public C getData(){return data;}
    }//And its subclass
    public class ABCModel <C> extends GModel{
    }//On my guess, when I do
    ABCModel abcModel = new ABCModel<MyObject>();The data attribute should be from MyObject type, is it right?
    So, usign the netbeans when I do
    MyObject obj = abcModel.getData();I should not use any casting, since the generics would tell that return object from getDta would be the MyObject.
    Is this right? If yes; did someone try to do that on netbeans?
    Thanks and Regards

    public class GModel <C>{
    public class ABCModel <C> extends GModel{public class ABCModel <C> extends GModel<C>{
    ABCModel abcModel = new ABCModel<MyObject>();ABCModel<MyObject> abcModel = new ABCModel<MyObject>();

  • Hiding methods and attributes while inheriting

    Hello All,
    This is kinda urgent. While making a subclass I want to block access to methods and attributes of super class when anone creates an object of sub-class. In my particular situation I cannot override the methods.
    Let me explain it with an example:
    I have a class A which contains an attribute of type Object. All the methods accept Object type parameters and act accordingly. Now I want to create a sub-class B which acts on Strings only. I can create a wrapper to class A but I want to add some behavior which is specific to strings and use rest of the behavior as in class A. I cannot override the methods of class A because they take Objects as parameters whereas in class B the same methods take string as parameters.
    I hope you have understood the problem. Please reply ASAP.
    Thanks in advance

    Sorry the diagram turned out wrong. ObjectClass and StringClass are both supposed to be derived
    from the AbstractBaseClass.
    This method is one way to achieve what you want. You make an AbstractBaseList class that has only
    protected methods that take objects.
    To implement a generic Object version of this class you extend it and override the protected methods in
    the AbstractBaseList class to make them public.
    To implement a String list you extend the AbstractBaseList class and override the protected methods to
    make them public (but change the type of the parameters).
    The only problem with this approach is that the return types of the methods cannot be changed. Therefore
    I recommend the AbstractBaseList implement a method called
    protected Object getByIndex(int i) {
    // do list type stuff in here
    Then the ObjectList can implement
    public Object get(int i) {
    return super.getByIndex(i);
    and the StringList can implement
    public String get(int i) {
    return (String) super.getByIndex(i);
    In effect all you need to do is to implement wrapper classes that enforce type casting on the Object based
    set/get values.
    Another option is to use JDK1.5 with its generics classes. These effectivly allow you to specify which type of
    object an instance of a class accepts.
    Another question. What is the matter with the Collections classes provided in the JDK?
    matfud

  • Redefination of Method in Inherited Class

    dear Gurrus i am facing an issu.
    I have defined and implimented 2 classes A and B,
    B is inherited by A and B has also redefined an inherited method of A. at runtime i have created an  object of B and called a redifined method. and its working properly, but i have a requirment that i want to get result of the method orginally defined by class A and also at the same time i also want to see the result of redefined method by B.
    can i access the method of A class althoug i have redefiend the same method in B class using the object of B?
    Edited by: Shadab Ali on Jun 4, 2009 8:55 PM

    I spent a while looking into this after reading your question, and came to much the same conclusion you had. Here's the best I could come up with, but it suffers from all the flaws you mentioned:
         public static Type report(Method method, Class contextClass) {
              Type grt = method.getGenericReturnType();
              Class dc = method.getDeclaringClass();
              TypeVariable[] tva = dc.getTypeParameters();
              Class directDescendent = contextClass;
              while( !directDescendent.getSuperclass().equals(dc)) {
                   directDescendent = directDescendent.getSuperclass();
              Type t = directDescendent.getGenericSuperclass();
              if( t instanceof ParameterizedType ) {               
                   ParameterizedType pt = (ParameterizedType)t;
                   int index = 0;
                   for( Type ta : pt.getActualTypeArguments() ) {
                        if( tva[index++].equals(grt) ) return ta;
              return null;
         }Might be worth asking this again in the Generics forum.

  • First Try with JE BDB - Indexes and Inheritance troubles... (FIXED)

    Hi Mark,
    Mark wrote:
    Hi, I'm a newbie here trying some stuff on JE BDB. And now I'm having
    I am happy to help you with this, but I'll have to ask you to re-post this question to the BDB JE forum, which is...
    Sorry for the mistake. I know now that here is the place to post my doubts.
    I'm really interested in JE BDB product. I think it is fantastic!
    Regarding my first post about "Indexes and Inheritance" on JE BDB, I found out the fix for that and actually, it wasn't about "Indexes and Inheritance" but "*Inheritance and Sequence*" because I have my "@Persistent public abstract class AbstractEntity" with a "@PrimaryKey(sequence = "ID_SEQ") private Long id" property.
    This class is extended by all my business classes (@Entity Employee and @Entity Department) so that my business classes have their PrimaryKey autoincremented by the sequence.
    But, all my business classes have the same Sequence Name: "ID_SEQ" then, when I start running my JE BDB at first time, I start saving 3 new Department objects and the sequence for these department objects star with "#1" and finishes with #3.
    Then I continue saving Employee objects (here was the problem) I thought that my next Sequence number could be #4 but actually it was #101 so when I tried to save my very first Employee, I set the property "managerId=null" since this employee is the Manager, then, when I tried to save my second Employee who is working under the first one (the manager employee), I got the following exception message:
    TryingJEBDBApp DatabaseExcaption: com.sleepycat.je.ForeignConstraintException: (JE 4.0.71) Secondary persist#EntityStoreName#com.dmp.gamblit.persistence.BDB.store.eployee.Employee#*managerId*
    foreign key not allowed: it is not present in the foreign database
    persist#EntityStoreName#com.dmp.gamblit.persistence.BDB.store.eployee.Employee
    The solution:
    I fixed it modifying the managerId value from "4" to "101" and it works now!
    At this moment I'm trying to understand the Sequence mechanism and refining concerns about Cursors manipulation...
    Have you any good material about these topics, perhaps a link where I can find more detailed information on these?
    Thanks in advance Mark, thanks for your attention on this and I will post more doubts in the future for sure ;0)
    Regards,
    Diego

    Hi Diego,
    I fixed it modifying the managerId value from "4" to "101" and it works now!I'm glad you found the problem. It is usually best to get the assigned ID from the entity object after you call put(), and then use that value to fill in related fields in other entities. The primary key field (assigned from the sequence) is set by the put() method.
    At this moment I'm trying to understand the Sequence mechanism and refining concerns about Cursors manipulation...Have you any good material about these topics, perhaps a link where I can find more detailed information on these? >
    To find documentation, start at the first message in the forum, the Welcome message:
    http://forums.oracle.com/forums/ann.jspa?annID=250
    This refers to the main JE doc page, the JE FAQ and a white paper on DPL queries. The FAQ has a section on the DPL, which refers to the javadoc. The DPL javadoc has lots of info on using cursors along with indexes (see EntityIndex, PrimaryIndex, SecondaryIndex). The white paper will be useful to you if you're accustomed to using SQL.
    I don't know of any doc on sequences other than the javadoc:
    http://www.oracle.com/technology/documentation/berkeley-db/je/java/com/sleepycat/persist/model/PrimaryKey.html#sequence()
    This doc will point you to info on configuring the sequence, if that's what you're interested in.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to create a generic method?

    Hi,
      I am using a std task TS01200205 to create instance for a BOR object. There are 2 key fields. I want to pass these 2 to the ObjectKey field.
    As for as I know, we have to concatenate these two Keyfields and assign it to 'Object Key' parameter.
      How can I concatenate the 2 strings in my Workflow? Is there any std way of doing it?
    Also what is a generic method? How to create it? Can I make use of generic method to achieve this?
    Thanks,
    Sivagami

    If you want to use it in different workflows the best solution is probably to define an interface and define and implement the method there (a nice thing about BOR interfaces is that you can provide an implementation and not just the definition).
    All you then need to do is let your object type(s) implement that interface, which only requires adding the interface since the implementation has been done already.
    However, I am not saying this is a good way of approaching things, I'm just telling you how you can implement what you suggest.

  • Abstract method and class

    I'm a beginner in Java and just learn about abstract method and class.
    However, i am wondering what is the point of using abstract method/class?
    Because when I delete the abstract method and change the class name to public class XXXX( changed from "abstract class XXXX), my program still runs well, nothing goes different.
    Is it because I haven't encountered any situation that abstract method is necessary or ?
    Thanks!

    Yes - you probably haven't encountered a situation where you need an abstract.
    Abstract classes are not designed to do anything on their own. They are designed to provide a template for other classes to extend by inheritance. What you have build sounds like a concrete class - one which you are creating instances of. Abstract classes are not designed to be ever instantiated in their pure form - they act like a partial building block, which you will complete in a class which extends the abstract.
    An example might be a button class, which provides some core functionality (like rollover, rollout etc) but has an empty action method which has to be overwritten by a relevant subclass like 'StartButton'. In general, abstract classes may not be the right answer, and many people would argue that it is better to use an interface, which can be implemented instead of extended, meaning that you can ADD instead of REPLACING.
    Not sure if that helps.. there are whole chapters in books on this kind of thing, so it's hard to explain in a couple of paragraphs. Do some google searches to find out more about how they work.

  • EclipseLink + JPA + Generic Entity + SINGLE_TABLE Inheritance

    I was wondering if it's possible in JPA to define a generic entity like in my case PropertyBase<T> and derive concrete entity classes like ShortProperty and StringProperty and use them with the SINGLE_TABLE inheritance mode? If I try to commit newly created ElementModel instances (see ElementModelTest) over the EntityManager I always get an NumberFormatException that "value" can't be properly converted to a Short. Strangely enough if I define all classes below as inner static classes of my test case class "ElementModelTest" this seems to work. Any ideas what I need to change to make this work?
    I'm using EclipseLink eclipselink-2.6.0.v20131019-ef98e5d.
    public abstract class PersistableObject
        implements Serializable {
        private static final long serialVersionUID = 1L;
        private String id = UUID.randomUUID().toString();
        private Long version;
        public PersistableObject() {
               this(serialVersionUID);
        public PersistableObject(final Long paramVersion) {
              version = paramVersion;
        public String getId() {
    return id;
        public void setId(final String paramId) {
      id = paramId;
        public Long getVersion() {
    return version;
        public void setVersion(final Long paramVersion) {
      version = paramVersion;
        public String toString() {
      return this.getClass().getName() + "[id=" + id + "]";
    public abstract class PropertyBase<T> extends PersistableObject {
        private static final long serialVersionUID = 1L;
        private String name;
        private T value;
        public PropertyBase() {
    this(serialVersionUID);
        public PropertyBase(final Long paramVersion) {
      this(paramVersion, null);
        public PropertyBase(final Long paramVersion, final String paramName) {
      this(paramVersion, paramName, null);
        public PropertyBase(final Long paramVersion, final String paramName, final T paramValue) {
      super(paramVersion);
      name = paramName;
      value = paramValue;
        public String getName() {
    return name;
        public void setName(final String paramName) {
      name = paramName;
        public T getValue() {
    return value;
        public void setValue(final T paramValue) {
      value = paramValue;
    public class ShortProperty extends PropertyBase<Short> {
        private static final long serialVersionUID = 1L;
        public ShortProperty() {
    this(null, null);
        public ShortProperty(final String paramName) {
      this(paramName, null);
        public ShortProperty(final String paramName, final Short paramValue) {
      super(serialVersionUID, paramName, paramValue);
    public class StringProperty extends PropertyBase<String> {
        private static final long serialVersionUID = 1L;
        protected StringProperty() {
    this(null, null);
        public StringProperty(final String paramName) {
      this(paramName, null);
        public StringProperty(final String paramName, final String paramValue) {
      super(serialVersionUID, paramName, paramValue);
    public class ElementModel extends PersistableObject {
        private static final long serialVersionUID = 1L;
        private StringProperty name = new StringProperty("name");
        private ShortProperty number = new ShortProperty("number");
        public ElementModel() {
    this(serialVersionUID);
        public ElementModel(final Long paramVersion) {
      super(paramVersion);
        public String getName() {
      return name.getValue();
        public void setName(final String paramName) {
      name.setValue(paramName);
        public Short getNumber() {
      return number.getValue();
        public void setNumber(final Short paramNumber) {
      number.setValue(paramNumber);
    <?xml version="1.0" encoding="UTF-8" ?>
    <entity-mappings version="2.1"
    xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd">
    <mapped-superclass
      class="PersistableObject">
      <attributes>
      <id name="id">
      <column name="id" />
      </id>
      <version name="version" access="PROPERTY">
      <column name="version" />
      </version>
      </attributes>
    </mapped-superclass>
    <entity class="PropertyBase">
      <table name="PropertyBase" />
      <inheritance />
      <discriminator-column name="type"/>
      <attributes>
      <basic name="name">
      <column name="name" />
      </basic>
      <basic name="value">
      <column name="value" />
      </basic>
      </attributes>
    </entity>
    <entity class="StringProperty">
      <discriminator-value>StringProperty</discriminator-value>
    </entity>
    <entity class="ShortProperty">
      <discriminator-value>ShortProperty</discriminator-value>
    </entity>
    <entity class="ElementModel">
      <table name="ElementModel" />
      <inheritance />
      <discriminator-column name="type"/>
      <attributes>
      <one-to-one name="name">
      <join-column name="name" referenced-column-name="id" />
      <cascade>
      <cascade-all />
      </cascade>
      </one-to-one>
      <one-to-one name="number">
      <join-column name="number" referenced-column-name="id" />
      <cascade>
      <cascade-all />
      </cascade>
      </one-to-one>
      </attributes>
    </entity>
    </entity-mappings>
    public class ElementModelTest extends ModelTest<ElementModel> {
        public ElementModelTest() {
      super(ElementModel.class);
        @Test
        @SuppressWarnings("unchecked")
        public void testSQLPersistence() {
      final String PERSISTENCE_UNIT_NAME = getClass().getPackage().getName();
      new File("res/db/test/" + PERSISTENCE_UNIT_NAME + ".sqlite").delete();
      EntityManagerFactory factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
      EntityManager em = factory.createEntityManager();
      Query q = em.createQuery("select m from ElementModel m");
      List<ElementModel> modelList = q.getResultList();
      int originalSize = modelList.size();
      for (ElementModel model : modelList) {
          System.out.println("name: " + model.getName());
      System.out.println("size before insert: " + modelList.size());
      em.getTransaction().begin();
      for (int i = 0; i < 10; ++i) {
          ElementModel device = new ElementModel();
          device.setName("ElementModel: " + i);
        device.setNumber((short) i);
          em.persist(device);
      em.getTransaction().commit();
      modelList = q.getResultList();
      System.out.println("size after insert: " + modelList.size());
      assertTrue(modelList.size() == (originalSize + 10));
      em.close();

    This was answered in a cross post here java - EclipseLink + JPA + Generic Entity + SINGLE_TABLE Inheritance - Stack Overflow
    Short answer: No, it shouldn't work as the underlying database field type would be constant.  So either the Short or the String would have problems converting to the database type if they both mapped to the same table field. 

  • StartDrag using Generic method in Actionscript 3

    Hi,
    AS3:
    How to get general id (or) name from xml loaded images. bcoz, i want to drag and drop that images in generic method. Now, i currently used the event.target.name for each one.
    So, code length was too large. See my code below.
    /*********loading images through xml********/
    var bg_container_mc:MovieClip
    var bg_bg_myXMLLoader:URLLoader = new URLLoader();
    bg_bg_myXMLLoader.load(new URLRequest("xml/backgroundimages.xml"));
    bg_bg_myXMLLoader.addEventListener(Event.COMPLETE, processXML_bg);
    function processXML_bg(e:Event):void {
              var bg_myXML:XML=new XML(e.target.data);
              columns_bg=bg_myXML.@COLUMNS;
              bg_my_x=bg_myXML.@XPOSITION;
              bg_my_y=bg_myXML.@YPOSITION;
              bg_my_thumb_width=bg_myXML.@WIDTH;
              bg_my_thumb_height=bg_myXML.@HEIGHT;
              bg_my_images=bg_myXML.IMAGE;
              bg_my_total=bg_my_images.length();
              bg_container_mc = new MovieClip();
              bg_container_mc.x=bg_my_x;
              bg_container_mc.y=bg_my_y;
              ContentHead.addChild(bg_container_mc);
              for (var i:Number = 0; i < bg_my_total; i++) {
                       var bg_thumb_url=bg_my_images[i].@THUMB;
                        var bg_thumb_loader = new Loader();
                       bg_thumb_loader.load(new URLRequest(bg_thumb_url));
                       bg_thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded_bg);
                       bg_thumb_loader.name="bg_load"+i;
                       bg_thumb_loader.addEventListener(MouseEvent.MOUSE_DOWN, bg_down)
                       bg_thumb_loader.x = (bg_my_thumb_width-18)*bg_x_counter;
                       bg_thumb_loader.y = (bg_my_thumb_height-45)*bg_y_counter;
                       if (bg_x_counter+1<columns_bg) {
                                 bg_x_counter++;
                       } else {
                                 bg_x_counter=0;
                                 bg_y_counter++;
    function thumbLoaded_bg(e:Event):void {
              var my_thumb_bg:Loader=Loader(e.target.loader);
             var sprite:Sprite = new Sprite();
              var shape:Shape = new Shape();
              shape.graphics.lineStyle(1, 0x0098FF);
              shape.graphics.drawRect(e.target.loader.x-2, e.target.loader.y-2, e.target.loader.width+4, e.target.loader.height+4);
              sprite.addChild(shape);
              sprite.addChild(my_thumb_bg);
              sprite.x=4;
              bg_container_mc.addChild(sprite);
              my_thumb_bg.contentLoaderInfo.removeEventListener(Event.COMPLETE, thumbLoaded_bg);
    //  get name for each image. 
    I want to change this code in generic method. do needful.
    function bg_down(event:MouseEvent):void {
              var bg_name:String=new String(event.currentTarget.name);
              var bg_load:MovieClip=event.currentTarget as MovieClip;
              if (event.currentTarget.name=="bg_load0") {
                      var alaska_mc:alaska_png=new alaska_png();
                       addChild(alaska_mc);
                       alaska_mc.x=stage.mouseX;
                       alaska_mc.y=stage.mouseY;
                       alaska_mc.name="alaska_duplicate"+alaska_inc;
                       alaska_inc++;
                       alaska_mc.startDrag(false);
                      alaska_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
                       alaska_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load1") {
                       var lake_mc:lake_png=new lake_png();
                       addChild(lake_mc);
                       lake_mc.x=lake_mc.mouseX;
                       lake_mc.y=lake_mc.mouseY;
                       lake_mc.name="lake_duplicate"+lake_inc;
                       lake_inc++;
                       lake_mc.startDrag(false);
                       lake_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load2") {
                       var mountn_mc:mountn_png=new mountn_png();
                       addChild(mountn_mc);
                       mountn_mc.x=mountn_mc.mouseX;
                       mountn_mc.y=mountn_mc.mouseY;
                       mountn_mc.name="mountn_duplicate"+mountn_inc;
                       mountn_inc++;
                       mountn_mc.startDrag(false);
                       mountn_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load3") {
                       var town_mc:town_png=new town_png();
                       addChild(town_mc);
                       town_mc.x=town_mc.mouseX;
                       town_mc.y=town_mc.mouseY;
                       town_mc.name="town_duplicate"+town_inc;
                       town_inc++;
                       town_mc.startDrag(false);
                       town_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load4") {
                       var water_mc:water_png=new water_png();
                       addChild(water_mc);
                       water_mc.x=water_mc.mouseX;
                       water_mc.y=water_mc.mouseY;
                       water_mc.name="water_duplicate"+water_inc;
                       water_inc++;
                       water_mc.startDrag(false);
                      water_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load5") {
                       var city_mc:city_png=new city_png();
                       addChild(city_mc);
                       city_mc.x=city_mc.mouseX;
                       city_mc.y=city_mc.mouseY;
                       city_mc.name="city_duplicate"+city_inc;
                       city_inc++;
                       city_mc.startDrag(false);
                      city_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load6") {
                        var citywide_mc:citywide_png=new citywide_png();
                       addChild(citywide_mc);
                       citywide_mc.x=citywide_mc.mouseX;
                       citywide_mc.y=citywide_mc.mouseY;
                       citywide_mc.name="citywide_duplicate"+citywide_inc;
                       citywide_inc++;
                       citywide_mc.startDrag(false);
                      citywide_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load7") {
                       var downtown_mc:downtown_png=new downtown_png();
                       addChild(downtown_mc);
                       downtown_mc.x=downtown_mc.mouseX;
                       downtown_mc.y=downtown_mc.mouseY;
                       downtown_mc.name="downtown_duplicate"+downtown_inc;
                       downtown_inc++;
                       downtown_mc.startDrag(false);
                      downtown_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load8") {
                       var powerlines_mc:powerlines_png=new powerlines_png();
                       addChild(powerlines_mc);
                       powerlines_mc.x=powerlines_mc.mouseX;
                       powerlines_mc.y=powerlines_mc.mouseY;
                       powerlines_mc.name="powerlines_duplicate"+powerlines_inc;
                       powerlines_inc++;
                       powerlines_mc.startDrag(false);
                      powerlines_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load9") {
                       var tropical_mc:tropical_png=new tropical_png();
                       addChild(tropical_mc);
                       tropical_mc.x=tropical_mc.mouseX;
                       tropical_mc.y=tropical_mc.mouseY;
                       tropical_mc.name="tropical_duplicate"+tropical_inc;
                       tropical_inc++;
                       tropical_mc.startDrag(false);
                      tropical_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load10") {
                       var waters_mc:waters_png=new waters_png();
                       addChild(waters_mc);
                       waters_mc.x=waters_mc.mouseX;
                       waters_mc.y=waters_mc.mouseY;
                       waters_mc.name="waters_duplicate"+waterthumb_inc;
                       waterthumb_inc++;
                       waters_mc.startDrag(false);
                      waters_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
    Please suggest me if any  one.
    Regards,
    Viji. S

    Post AS3 questions in the AS3 forum, not the AS1/2 forum.

  • Business scenarios on SD and MM modules for generic datasources and enhance

    Hi,
      Can anybody send some documents on SD and MM module on generic datasource and on enhancements.Pl send it to my MailID:[email protected]
    Thanks,
    Chinna

    Hi,
    MM Process flow:
    The typical procurement cycle for a service or material consists of the following phases:
    1. Determination of Requirements
    Materials requirements are identified either in the user departments or via materials planning and control. (This can cover both MRP proper and the demand-based approach to inventory control. The regular checking of stock levels of materials defined by master records, use of the order-point method, and forecasting on the basis of past usage are important aspects of the latter.) You can enter purchase requisitions yourself, or they can be generated automatically by the materials planning and control system.
    2. Source Determination
    The Purchasing component helps you identify potential sources of supply based on past orders and existing longer-term purchase agreements. This speeds the process of creating requests for quotation (RFQs), which can be sent to vendors electronically via SAP EDI, if desired.
    3. Vendor Selection and Comparison of Quotations
    The system is capable of simulating pricing scenarios, allowing you to compare a number of different quotations. Rejection letters can be sent automatically.
    4. Purchase Order Processing
    The Purchasing system adopts information from the requisition and the quotation to help you create a purchase order. As with purchase requisitions, you can generate Pos yourself or have the system generate them automatically. Vendor scheduling agreements and contracts (in the SAP System, types of longer-term purchase agreement) are also supported.
    5. Purchase Order Follow-Up
    The system checks the reminder periods you have specified and - if necessary - automatically prints reminders or expediters at the predefined intervals. It also provides you with an up-to-date status of all purchase requisitions, quotations, and purchase orders.
    6. Goods Receiving and Inventory Management
    Goods Receiving personnel can confirm the receipt of goods simply by entering the Po number. By specifying permissible tolerances, buyers can limit over- and underdeliveries of ordered goods.
    7. Invoice Verification
    The system supports the checking and matching of invoices. The accounts payable clerk is notified of quantity and price variances because the system has access to PO and goods receipt data. This speeds the process of auditing and clearing invoices for payment.
    Common Tables used by SAP MM:
    Below are few important Common Tables used in Materials Management Modules:
    EINA Purchasing Info Record- General Data
    EINE Purchasing Info Record- Purchasing Organization Data
    MAKT Material Descriptions
    MARA General Material Data
    MARC Plant Data for Material
    MARD Storage Location Data for Material
    MAST Material to BOM Link
    MBEW Material Valuation
    MKPF Header- Material Document
    MSEG Document Segment- Material
    MVER Material Consumption
    MVKE Sales Data for materials
    RKPF Document Header- Reservation
    T023 Mat. groups
    T024 Purchasing Groups
    T156 Movement Type
    T157H Help Texts for Movement Types
    MOFF Lists what views have not been created
    A501 Plant/Material
    EBAN Purchase Requisition
    EBKN Purchase Requisition Account Assignment
    EKAB Release Documentation
    EKBE History per Purchasing Document
    EKET Scheduling Agreement Schedule Lines
    EKKN Account Assignment in Purchasing Document
    EKKO Purchasing Document Header
    EKPO Purchasing Document Item
    IKPF Header- Physical Inventory Document
    ISEG Physical Inventory Document Items
    LFA1 Vendor Master (General section)
    LFB1 Vendor Master (Company Code)
    NRIV Number range intervals
    RESB Reservation/dependent requirements
    T161T Texts for Purchasing Document Types
    Transaction Codes:
    RFQ to Vendor - ME41
    Raising Quotation - ME47
    Comparison of Price - ME49
    Creation of PO - ME21N
    Goods Receipt - MIGO
    Invoice (Bill PAssing) - MIRO
    Goods Issue - MB1A
    Physical Inventory - MI01( Create doc)
    MI04 (Enter Count)
    MI07 (Post)
    Also please check this links.
    http://www.sapgenie.com/sapfunc/mm.htm
    http://www.sap-basis-abap.com/sapmm.htm
    SD Process Flow:
    The sales documents you create are individual documents but they can also form part of a chain of inter-related documents. For example, you may record a customer’s telephone inquiry in the system. The customer next requests a quotation, which you then create by referring to the inquiry. The customer later places an order on the basis of the quotation and you create a sales order with reference to the quotation. You ship the goods and bill the customer. After delivery of the goods, the customer claims credit for some damaged goods and you create a free-of-charge delivery with reference to the sales order. The entire chain of documents – the inquiry, the quotation, the sales order, the delivery, the invoice, and the subsequent delivery free of charge – creates a document flow or history. The flow of data from one document into another reduces manual activity and makes problem resolution easier. Inquiry and quotation management in the Sales Information System help you to plan and control your sales.
    Transaction Codes:
    Inquiry - VA11/VA12/VA13
    Quotation - VA21/VA22/VA23
    Sales Order - VA01/VA02/VA03
    Delivery - VL01N/VL02N/VL03N
    Billing/Invoicing - VF01/VF02/VF03
    Also please check this links.
    http://www.sapgenie.com/sapfunc/sd.htm
    http://www.sap-basis-abap.com/sapsd.htm
    http://www.sapgenie.com/abap/tables_sd.htm
    Production Planning:
    For example, consider a pump manufacturing plant, based on the customer requirement, planning is done for future months ( we plan for a qty on particular
    date). Pump is an assembly - were main component would be manufactured in the plant and others would be procured. As PP, we are concerned only in the inhouse
    manufacturing but the final assembly (considering BOM) can be done only if the procured components are available. MRP helps in planning the shortage, on
    particular date based on the planned date. Work center (ex. lathe) place the components are machined/assembled (were the operation is done). Sequence of
    operation is routing (lead time scheduling data is got from routing). In the MRP Run,basic or lead time scheduling (need to know when to start/finish date)
    is done. On creation of the production order, system checks for which BOM and routing to be picked up (if there are many routings or BOM for that particular
    finished product). Availabilty checks for material,PRT and capacity needs to be done. on release of the order, confirmation of the order can be done (on
    completion of the order or after manufacturing the quantities). GI and GR have to be done.PP flow ends here
    step 1: creation of master data (Material master,BOM,Work center,Routing)
    step 2: Planning - can be done by Planned independent requirement (MD61), Independent requirement (MD81).
    we plan for a quantity, on which date (it would be finish date).
    step 3: MD04 -stock/requirement lsit (plan made can be viewed in MD04)
    step 4: MRP run - MD02, PIR is converted into Planned order
    step 5:Planned order to be converted production order - CO40, CO41
    step 6: production order to be released - CA02
    step 7: confirm the production order (order confirmation-CO15 (after which GI and GR is done)
    assign pts if helpful...

  • Doubt about generic method

    i have a generic method has shown below
    public static <E extends Number> <E>process(E list){
    List<Interger> output = new ArrayList<Interger>(); or List<Number> output = new ArrayList<Number>();
    return output ;
    if delcare the output variable using Interger or Number . when i am returning the output . it is showing me compiler error and it suggests me to add cast List<E>. Why i not able understand. please clarify my doubt.
    Thanks
    Sura.Maruthi
    Edited by: sura.maruthi on Sep 21, 2008 9:48 PM

    Your method declaration is garbled; there can be only one <...> clause, eg
    public static <E extends Number> E process(E list);This declaration says that for any subclass E of Number, the method process takes a single E instance (called list!?) and returns a single E instance. A valid implementation would be
    return list;I'm guessing you want the parameter to have type List<E>?. Like this:
    public static <E extends Number> E process(List<E> list);This declaration says that for any subclass E of Number, the method process takes a list of E's and returns a single E instance. A valid implementation would be
    return list.get(0);Or perhaps you also want to return a list of numbers?
    public static <E extends Number> List<E> process(List<E> list);This declaration says that for any subclass E of Number, the method process takes a list of E's and returns another list of E's. A valid implementation would be
    return list;Note that you cannot just return a list of Integers or Floats, because your generic method must work for any subclass of Number, and you're promising to return back a list of the same type as the argument passed in.
    Edited by: nygaard on Sep 22, 2008 10:05 AM

Maybe you are looking for

  • ITunes Match will no longer let me add my PC... Help?

    iTunes Match will no longer let me add my PC.  As it is, about 50% of the time that I have opened iTunes for the last year, I've gotten an error stating that iTunes Match has encountered an error and I would need to re-login.  This is on my main PC,

  • Firefox page images do not display only text and links

    New desktop (not this one) with windows 8.1 Pro, Firefox 29, Norton Internet security. When I go to many of the Firefox pages images do not display, only text and links. This is true for the "get add-ons" page. I can search for add-ons, but when I tr

  • Oracle function in stored procedure to retreive particular table name

    Hi, I need to delete a table 'xxsys_dram_flatproperties' from database given model name as 'dram-model'. the model name can be any thing.corresponding table name will be[i] 'xxsys_<modelname>_flatproperties'. I wrote stored procedure .I am able to re

  • Missing document number and premium

    I have one barrier currency option (Down&in) as attached, it is expired, but I can't see any premium posted, why posting carried out but no accounting document also I remember for barrier option, two strike price will be used, but when I see in "stru

  • Control a generator with a control volage by serial port RS232

    Hello everybody, I would like to control a generator thanks to a control voltage. This last one would be sent to a switch wich turns on the generator. To do that, I want to link the switch and the computer with a serial port RS232 by using NI-USN 232