Paint a map on Java

Hi, I'm begginer on Java.
I'm trying to paint a grid map on Java application. I build this map on a C++ library. This map is a bi-dimensional array of int.
I tried to get the array from C++ with JNI but not work fine.
Another problem is the paint method. I re-wrote a paint method of a Panel class that display this array, but I think it take much time.
Can anyone give ideas about this!
Thanks.
Paulo

post code pls

Similar Messages

  • XSLT Mapping with Java Enhancement

    Hi All
    I am working on XSLT Mapping with Java Enhancement.
    To do this scenario i have followed the following link.
    http://help.sap.com/saphelp_nw04/helpdata/en/55/7ef3003fc411d6b1f700508b5d5211/frameset.htm
    As per the above link I have created Source and Target Data Types , Message Types , Mesage Interfaces, XSLT Mapping (using the transaction XSLT_TOOL) and Interface Mapping part and configred a simple file to file scenario in the ID part.
    Apart from this I have wirte the java code, compile the java code, create the jar file using .java and .class file and after creating the jar file import the .jar file in the imported archive of the IR..
    when I am trying to execute the scenario I am getting the successful message in SXMB_MONI but the target file is having the payload as given below.
    <?xml version ="1.0" encoding="UTF-8"?>
    <name xmlns:javamap="java:com.company.group.MappingClass"/>
    And as per the XSLT mapping the payload should be as below
    <?xml version ="1.0" encoding="UTF-8"?>
    <person>
    <name>Rinku Gangwani</name>
    </person>
    I have also followed the following blog link but still i am getting the same issue
    /people/pooja.pandey/blog/2005/06/27/xslt-mapping-with-java-enhancement-for-beginners
    could you please tell me what can be the reason that i am getting the blank targt field values in the payload.
    Thanks
    Rinku Gangwani

    Hi,
      The Transaction code XSLT_TOOL for ABAP xslt mapping.But the Java Enhancement is used for normal xslt mapping which we created using Stylus Studio.You can not access the Java Enhancement in ABAP xslt mapping.
    If you want to use Java Enhancement in xslt mapping then create a xslt mapping using Stylus Studio and save the file as .xsl and zip the .xsl and import to import archive.
    Regards,
    Prakasu.M
    Edited by: prakasu on May 28, 2009 1:46 PM

  • XSLT Maps with Java enhancements - JCO_SYSTEM_FAILURE

    Hi,
    I have reviewed several postings regarding XSLT Maps with Java enhancements. I followed instructions and build a jar file and the XSLT document. I built one imported archive with the .jar and .xsl. For the class, The path get loaded properly.
    However, I still have a problem when and execute the interface.
    My xslt has the following information
    <xsl:transform version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:ns="http://xyz.abc.sap.def.com"
        xmlns:javamap="java:xyz.Date_Time">
    <xsl:param name="inputparam" />
        <xsl:template match="/">
            <test><xsl:value-of select="javamap:getDateValue($inputparam)"/></test>
        </xsl:template>
    </xsl:transform>
    In SXMB_Moni I get the following error...
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Request Message Mapping
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>XIServer</SAP:Category>
      <SAP:Code area="MAPPING">JCO_SYSTEM_FAILURE</SAP:Code>
      <SAP:P1>Exception in method processFunction.</SAP:P1>
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>"SYSTEM FAILURE" during JCo call. Exception in method processFunction.</SAP:Stack>
      <SAP:Retry>A</SAP:Retry>
      </SAP:Error>
    If i remove the line        
    <test><xsl:value-of select="javamap:getDateValue($inputparam)"/></test>
    The map ends successfuly.
    Comments would be appreciated.
    Regards,
    Sergio

    Stefan,
    Find the class and method definition below. The method is static and it returns the string.
    ==========
    package xyz;
    import java.util.Map;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import java.util.*;
    import java.text.*;
    public class Date_Time {
        private static AbstractTrace trace = null;
        public static String getDateValue(Map inputparam)
                trace = (AbstractTrace)inputparam.get(
                         StreamTransformationConstants.MAPPING_TRACE );
                Date now1 = new Date();
                SimpleDateFormat formatter = new SimpleDateFormat ("yyyyMMd");
                String dateString = formatter.format(now1);
                return dateString;

  • Java Error in RFC Lookup in XSLT Mapping usinf Java helper class

    Hi All,
    I am doing RFC Lookup in XSLT Mapping using Java Helper class.
    The Lookup works fine when called one RFC at a time However my requirement is I want to do 2 Lookups.
    Both Lookups works when done individually however when I call both lookups in one mapping I get following error "javax.xml.transform.TransformerException: DOMSource whose Node is null."
    Following is the code I have written in XSLT for the lookup:
         <xsl:template name="Lookup_1">
              <xsl:param name="STDPN"/>
                   <rfc:RFC_READ_TABLE>
                        <QUERY_TABLE>KNA1</QUERY_TABLE>
                        <OPTIONS><item><TEXT>
                                  <xsl:value-of select="$STDPN"/>
                             </TEXT></item>
                        </OPTIONS>
                        <FIELDS>
                             <item>
                                  <FIELDNAME>KUNNR</FIELDNAME>
                             </item>
                        </FIELDS>
                   </rfc:RFC_READ_TABLE>
              </xsl:variable>
              <xsl:variable name="response" xmlns:lookup="java:urn.mt.pi" select="lookup:execute($request, 'BS_D, 'cc_RfcLookup', $inputparam)"/>
              <xsl:element name="STDPN">
                   <xsl:value-of select="$response//DATA/item/WA"/>
              </xsl:element>
         </xsl:template>
         <xsl:template name="Lookup_2">
              <xsl:param name="BELNR"/>
                   <xsl:variable name="Query">AGMNT = '<xsl:value-of select="$BELNR"/>'</xsl:variable>
                   <xsl:variable name="request1">
                        <rfc:RFC_READ_TABLE>
                             <QUERY_TABLE>ZTABLE</QUERY_TABLE>
                             <OPTIONS><item><TEXT>
                                  <xsl:value-of select="$Query"/>
                                  </TEXT></item>
                             </OPTIONS>
                             <FIELDS>
                                  <item>
                                       <FIELDNAME>KUNAG</FIELDNAME>
                                  </item>
                             </FIELDS>
                        </rfc:RFC_READ_TABLE>
                   </xsl:variable>
                   <xsl:variable name="response1" xmlns:lookup="java:urn.mt.pi" select="lookup:execute($request1, 'BS_D','cc_RfcLookup', $inputparam)"/>
                   <xsl:element name="BELNR">
                        <xsl:value-of select="$response1//DATA/item/WA"/>
                   </xsl:element>
         </xsl:template>
    My Question: Am I doing anything wrong? Or Is it possible to call multiple lookups in one XSLT?
    Thanks and Regards,
    Atul

    Hi Atul,
    I had the same problem like you had.
    The main Problem is that with the example code the request variable is created as NodeList object. In XSLT a variable is somekind of a constant and can't be changed. As the request object is empty after the first request the programm fails at the following line:
    Source source = new DOMSource(request.item(0));
    So I've created a workaround for this problem.
    In the call of the template I've put the request as a parameter object at the template call:
    <xsl:with-param name="req">
    <rfc:PLM_EXPLORE_BILL_OF_MATERIAL xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
      <APPLICATION>Z001</APPLICATION>
      <FLAG_NEW_EXPLOSION>X</FLAG_NEW_EXPLOSION>
      <MATERIALNUMBER><xsl:value-of select="value"/></MATERIALNUMBER>
      <PLANT>FSD0</PLANT>
      <VALIDFROM><xsl:value-of select="//Recordset/Row[name='DTM-031']/value"/></VALIDFROM>
      <BOMITEM_DATA/>
    </rfc:PLM_EXPLORE_BILL_OF_MATERIAL>
    </xsl:with-param>
    With this change the request will be provided as a String object and not as a NodeList object.
    Afterwards the RfcLookup.java has to be changed to the following:
    package com.franke.mappings;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;
    import java.io.StringWriter;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import com.sap.aii.mapping.lookup.Channel;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.lookup.RfcAccessor;
    import com.sap.aii.mapping.lookup.LookupService;
    import com.sap.aii.mapping.lookup.XmlPayload;
    * @author Thorsten Nordholm Søbirk, AppliCon A/S
    * Helper class for using the XI Lookup API with XSLT mappings for calling RFCs.
    * The class is generic in that it can be used to call any remote-enabled
    * function module in R/3. Generation of the XML request document and parsing of
    * the XML response is left to the stylesheet, where this can be done in a very
    * natural manner.
    * TD:
    * Changed the class that request is sent as String, because of IndexOutOfBound-exception
    * When sending multiple requests in one XSLT mapping.
    public class RfcLookup {
         * Execute RFC lookup.
         * @param request RFC request - TD: changed to String
         * @param service name of service
         * @param channelName name of communication channel
         * @param inputParam mapping parameters
         * @return Node containing RFC response
         public static Node execute( String request,
                 String service,
                 String channelName,
                 Map inputParam)
              AbstractTrace trace = (AbstractTrace) inputParam.get(StreamTransformationConstants.MAPPING_TRACE);
              Node responseNode = null;
              try {
                  // Get channel and accessor
                  Channel channel = LookupService.getChannel(service, channelName);
                  RfcAccessor accessor = LookupService.getRfcAccessor(channel);
                   // Serialise request NodeList - TD: Not needed anymore as request is String
                   /*TransformerFactory factory = TransformerFactory.newInstance();
                   Transformer transformer = factory.newTransformer();
                   Source source = new DOMSource(request.item(0));
                   ByteArrayOutputStream baos = new ByteArrayOutputStream();
                   StreamResult streamResult = new StreamResult(baos);
                   transformer.transform(source, streamResult);*/
                    // TD: Add xml header and remove linefeeds for the request string
                    request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+request.replaceAll("[\r\n]+", ""); 
                    // TD: Get byte Array from request String to send afterwards
                    byte[] requestBytes = request.getBytes();
                   // TD: Not used anymore as request is String
                    //byte[] requestBytes = baos.toByteArray();
                    trace.addDebugMessage("RFC Request: " + new String(requestBytes));
                    // Create input stream representing the function module request message
                    InputStream inputStream = new ByteArrayInputStream(requestBytes);
                    // Create XmlPayload
                    XmlPayload requestPayload =LookupService.getXmlPayload(inputStream);
                    // Execute lookup
                    XmlPayload responsePayload = accessor.call(requestPayload);
                    InputStream responseStream = responsePayload.getContent();
                    TeeInputStream tee = new TeeInputStream(responseStream);
                    // Create DOM tree for response
                    DocumentBuilder docBuilder =DocumentBuilderFactory.newInstance().newDocumentBuilder();
                    Document document = docBuilder.parse(tee);
                    trace.addDebugMessage("RFC Response: " + tee.getStringContent());
                    responseNode = document.getFirstChild();
              } catch (Throwable t) {
                   StringWriter sw = new StringWriter();
                   t.printStackTrace(new PrintWriter(sw));
                   trace.addWarning(sw.toString());
              return responseNode;
         * Helper class which collects stream input while reading.
         static class TeeInputStream extends InputStream {
               private ByteArrayOutputStream baos;
               private InputStream wrappedInputStream;
               TeeInputStream(InputStream inputStream) {
                    baos = new ByteArrayOutputStream();
                    wrappedInputStream = inputStream;
               * @return stream content as String
               String getStringContent() {
                    return baos.toString();
              /* (non-Javadoc)
              * @see java.io.InputStream#read()
              public int read() throws IOException {
                   int r = wrappedInputStream.read();
                   baos.write(r);
                   return r;
    Then you need to compile and upload this class and it should work.
    I hope that this helps you.
    Best regards
    Till

  • XSLT Mapping with Java Enhancement - how to pass Java Errors

    Hi all,
    I plan to build a XSLT-Mapping and do a RFC-Call out of it. (Client order!) So, I have to call my selfwritten Java class from the XSLT mapping and therefore report Connection errors back to the XSLT mapping (from Java). Is there a definition for the interface between Java and XSLT I can use?
    Thanks and regards.
    Daniel

    hi,
    hope this one will be more appropriate link
    http://help.sap.com/saphelp_nw04s/helpdata/en/55/7ef3003fc411d6b1f700508b5d5211/frameset.htm
    and this link will also be useful
    http://help.sap.com/saphelp_nw04s/helpdata/en/4c/b2ad3de2d76b3be10000000a114084/frameset.htm
    regards,
    sundararamaprasad

  • About Java mapping and java proxy

    Hi
    Iam new to Xi and basically iam an ABAPER.When iam dooing mappinps or proxies i cant able to understand the java pari cant (javamapping and java proxies) .I need some notes on java mapping and java proxy which is easy to do.And why do we use this java mapping or java proxy particularly when we r having abap mappipng and abap proxy.
    thanks in advance

    Hi,
    refer
    Java Mapping
    SAP Network Blog: Java Mapping (Part I)
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    Java Mapping in XI
    https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=java+mapping&adv=false&sortby=cm_rnd_rankvalue#
    Runtime Environment (Java Mappings) (SAP Library - Partner Connectivity Kit)
    http://help.sap.com/saphelp_nw04/helpdata/en/bd/c91241c738f423e10000000a155106/frameset.htm
    Java Mapping (SAP Library - Partner Connectivity Kit)
    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm
    SAP Network Blog: Testing and Debugging Java Mapping
    /people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio
    SAP Network Blog: Implementing a Java Mapping in SAP PI
    /people/carlosivan.prietorubio/blog/2007/12/21/implementing-a-java-mapping-in-sap-pi
    "JAVA MAPPING", an alternate way of reading a CSV file
    /people/rahul.nawale2/blog/2006/07/18/java-mapping-an-alternate-way-of-reading-a-csv-file
    SAP Network Blog: XI Java Mapping Helper (DOM)
    /people/alessandro.guarneri/blog/2007/03/25/xi-java-mapping-helper-dom
    Java Proxy
    Java Proxy Objects (SAP Library - SAP Exchange Infrastructure)
    http://help.sap.com/saphelp_nw04/helpdata/en/c5/7d5e3c754e476ee10000000a11405a/frameset.htm
    Accessing Active Directory through Java Proxy on SAP Exchange Infrastructure 3.0
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10716e9f-23d7-2a10-8c8c-d2665615f8fc
    Thanks
    Swarup

  • XSL mapping with Java enhancment PI 7.1 - Dynamic configuration

    Scenario - IDOC -> File
    XSL Mapping using dynamic configuration to set file name.
    1. Ive included
    xmlns:javamap="java:packageName.DynamicFunctionClass">
    in the XSL header
    2.Ive call this method javamap:transform($input, $output)
    In the Java code.
    1. Package = packageName
    2. Class Name = DynamicFunctionClass
    3. Class Compiles and I have uploaded into the ESR for a particular scenario. (source and class)
    4. extends AbstractTransformation and implements the transform method.
    public class DynamicFunctionClass extends AbstractTransformation{ .....
          public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException {
    ISSUE -
    Essentially it looks as though PI cannot see the class file or is not able to reference it. I have created a static method in the class as well to access and this does not work.
    TRACE -
    Resource not found META-INF/Services/javax.xml.parsers.SAXParserFactory Thrown:
       com.sap.aii.ib.server.mapping.execution.MappingClassNotFoundException:

    Ive stumbled across the fact that JDK 1.5 does not allow for Mapping with Java enchanment it is a feature only in SAPXMLTOOL kit, I shall tick the little box in the Operational mapping ...

  • How to pass input parameter (parameterized mapping) to java mapping program

    Hello
    I have a question about the parameterized mapping with Java (PI 7.1).
    In the operation mapping (using Java-class) I defined a inputer parameter (string). I think I am supposed to retrieved the value using:
                    arg0.getInputParameters().getString("myInputParameterName");
    where arg0 is the TransformationInput object.
    However I am not able to get the value, I got runtime exception saying the inputer parameter doesn't exit.
    Then I figured out maybe I need to bind the OM input parameter to Java mapping parameter, just like in case of message mapping, you need to bind OM parameter to MM parameter. However there is no way to define input parameter for the java mapping program.
    Anybody has done java mapping with parameterized mapping?
    Anybody can give any hint for this?
    Thanks
    Jayson

    InputParameters params = container.getInputParameters();
    DynamicConfiguration conf = (DynamicConfiguration) params.getValue(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "Directory");
    http://help.sap.com/saphelp_nwpi71/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm
    Edited by: Anand on Dec 10, 2008 4:13 PM

  • Mapping using Java Coding

    I've got a big trouble. First, I'm trying to do mapping using Java Coding based on the TopLink Developer's Guide.
    I'm using a Employee's Table as usual, but here is the problem, I can not do inserting on the database after I do mapping. As a note, there is no error compile and also I can do the session login already.
    Employee.java
    public class Employee extends oracle.toplink.sessions.Project{
         private Long id;
         private String fnama;
         private String lnama;
    public Employee() {
    setName("ObjectTab");
    applyLogin();
    addDescriptor(empDesc());
    conformAllDescriptors();
    public String getFnama() {
         return this.fnama;
    public String getLnama() {
         return this.lnama;
    public void setFnama(String fnama) {
         this.fnama = fnama;
    public void setLnama(String lnama) {
         this.lnama = lnama;
    public void applyLogin() {
    DatabaseLogin login = new DatabaseLogin();
    // use platform appropriate for underlying database
    login.usePlatform(
    new oracle.toplink.platform.database.oracle.Oracle9Platform());
    login.setDriverClassName("oracle.jdbc.OracleDriver");
    login.setConnectionString("jdbc:oracle:thin:localhost:1521:pusat");
    login.setUserName("tryo");
    login.setEncryptedPassword("a, ENCRYPTED");
    // Configuration Properties
    setDatasourceLogin(login);
    public ClassDescriptor empDesc() {
    ObjectRelationalDescriptor descriptor = new ObjectRelationalDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setTableName("EMPLOYEES");
    descriptor.setStructureName("EMPLOYEE_T");
    descriptor.setPrimaryKeyFieldName("ID");
    descriptor.addFieldOrdering("ID");
    descriptor.addFieldOrdering("F_NAME");
    descriptor.addFieldOrdering("L_NAME");
    descriptor.addDirectMapping("id", "OBJECT_ID");
    descriptor.addDirectMapping("fnama", "F_NAME");
    descriptor.addDirectMapping("lnama", "L_NAME");
    return descriptor;
    Main Class:
    protected String getSessionsXmlPath() {
    return "sessions.xml";
    protected String getSessionName() {
    return "Session";
    protected void createSession() {
    XMLSessionConfigLoader loader = new XMLSessionConfigLoader(getSessionsXmlPath());
    SessionManager mgr = SessionManager.getManager();
    session = (DatabaseSession)mgr.getSession(loader, getSessionName(), Thread.currentThread().getContextClassLoader(), true, true);
    public static void closeSession(){
    SessionManager.getManager().destroyAllSessions();
    session = null;
    private void jButton1_actionPerformed(ActionEvent e) {
    Employee myEmp = new Employee();
    createSession();
    private void jButton2_actionPerformed(ActionEvent e) {
    Employee theEmp = new Employee();
    UnitOfWork uow = session.acquireUnitOfWork();
    try{
    theEmp.setFnama("A");
    theEmp.setLnama("B");
    uow.commit();
    }finally{
    uow.release();
    For everybody who already knows the solution, please reply as soon as possible. Because I really need this solution to finish my last final project.
    Thanks

    When you create a new instance you must register it with the UnitOfWork in order to have the new entity persisted.
    Employee theEmp = new Employee();
    UnitOfWork uow = session.acquireUnitOfWork();
    theEmp.setFnama("A");
    theEmp.setLnama("B");
    uow.registerObject(theEmp);
    uow.commit();
    Doug

  • Value Mapping in Java Mpping

    Hi All,
    How can we call a value mapping in Java mapping?
    Any of your inputs are welcome!
    Thank You,
    Mugdha Kulkarni

    Hi,
    of course we can - there are many examples on the forum on how to do that
    please do a little search first
    thank you,
    Regards,
    Michal Krawczyk

  • Java.util.Map and  java.util.HashMap samples

    Hi.
    Please, I need some code samples of java.util.Map and java.util.HashMap interfaces. I have problems to retreive objects in the map.
    Cheers,
    Cata

    Try the tutorial:
    http://java.sun.com/docs/books/tutorial/collections/index.html

  • The JNI defines a mapping of Java types and native (C/C++) types.

    As per the tutorial
    The JNI defines a mapping of Java types and native (C/C++) types.Does the above sentence mean that I can use dll written in C/C++ only and not dll written in Pearl.
    Could anyone please give me the solution.

    Please do tell me how can I call a dll file created in Perl ....And I will point out again that I doubt that it is possible to create a dll that has the following characteristics
    1. Is in fact a dll.
    2. Is in fact intended to run anywhere outside of the perl engine.
    Step 2 means that you run perl, not a "perl dll" via C.
    You can do that or at least in the past you could. And that has nothing to do with java nor JNI. So you would learn about it on a perl site.
    And I can only note that when I did that a number of years ago it was very difficult. Certainly much harder than getting JNI to work. And you had better have quite a bit of C/C++ experience before you attempt it.

  • IDL mapping to Java

    I just read a topic about IDL mapping to Java...I want to know ,does it have differences and similarities to the IDL mapping to Java?....

    that my point....i doesn't understand what it is? What don't you understand?
    CORBA and ORB?
    Java?
    Why you'd have to map one language to another?
    The details of the mapping?
    doesn't java forum is to expend my knowledge on java?Actually, the forum is a place for folks to ask and answer questions, but there's never a guarantee. I can't make you ask smart questions, and you can't make me give any answer, let alone a good one. We're all volunteers here. If nobody decides to bother with your question you're out of luck.
    So - do you want to start with CORBA? It's an OMG spec written in the 90s that would allow objects to communicate with each other over a network. The ORB is the Object Request Broker that marshalls, routes, and unmarshalls messages between objects running on different machines.
    %

  • Object-XML Binding: How do I map from java to enumerated xml tags

    Hi. I'm new to Object-XML binding and toplink. XML that I'm trying to model in a schema has enumerated elements, e.g. </module_0></module_1><module_n> instead of many </module> elements. To simplify the schema I've opted to use </module> anyway with unbounded cardinality and imported this into a new project.
    What I would like to know is if I can use Toplink to map the java object back to the enumerate element types and vice versa?
    Thanks for your help.
    GeePee

    Hi Geepee,
    Below is an approach you can use if you have a fixed number of moduleX elements. In the example below X=3.
    Assume a 2 object model Root & Module, where Root has a list of Module instances:
    @XmlRootElement(name="root")
    public class Root {
        private List<Module> module = new ArrayList<Module>(3);
        ...// Accessors omitted
    }It is currently not possible to map the items in the module list to the XML elements (module1-module3), but it would be possbile to map an object (see below) with 3 properties to those XML elements:
    public class AdaptedModuleList {
        private Module module1;
        private Module module2;
        private Module module3;
        ...// Accessors omitted
    }What is required is a means to convert the unmappable object to a mappable one. This is done using a Converter:
    import org.eclipse.persistence.mappings.DatabaseMapping;
    import org.eclipse.persistence.mappings.converters.Converter;
    import org.eclipse.persistence.sessions.Session;
    public class ModuleListConverter implements Converter {
        public void initialize(DatabaseMapping mapping, Session session) {}
        public Object convertDataValueToObjectValue(Object dataValue, Session session) {
            AdaptedModuleList adaptedModuleList = (AdaptedModuleList) dataValue;
            if(null == adaptedModuleList) {
                return null;
            List<Module> moduleList = new ArrayList<Module>(3);
            moduleList.add(adaptedModuleList.getModule1());
            moduleList.add(adaptedModuleList.getModule2());
            moduleList.add(adaptedModuleList.getModule3());
            return moduleList;
        public Object convertObjectValueToDataValue(Object objectValue, Session session) {
            List<Module> moduleList = (List<Module>) objectValue;
            if(null == moduleList) {
                return null;
            AdaptedModuleList adaptedModuleList = new AdaptedModuleList();
            int moduleListSize = moduleList.size();
            if(moduleListSize > 0) {
                adaptedModuleList.setModule1(moduleList.get(0));
            if(moduleListSize > 1) {
                adaptedModuleList.setModule2(moduleList.get(1));
            if(moduleListSize > 2) {
                adaptedModuleList.setModule3(moduleList.get(2));
            return adaptedModuleList;
        public boolean isMutable() {
            return true;
    }The converter is added to the mapping metadata through the use of a Customizer:
    import org.eclipse.persistence.config.DescriptorCustomizer;
    import org.eclipse.persistence.descriptors.ClassDescriptor;
    import org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping;
    import org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping;
    public class RootCustomizer implements DescriptorCustomizer {
        public void customize(ClassDescriptor descriptor) throws Exception {
            XMLCompositeCollectionMapping originalModuleMapping = (XMLCompositeCollectionMapping) descriptor.removeMappingForAttributeName("module");
            XMLCompositeObjectMapping newModuleMapping = new XMLCompositeObjectMapping();
            newModuleMapping.setAttributeName(originalModuleMapping.getAttributeName());
            newModuleMapping.setXPath(".");
            newModuleMapping.setReferenceClass(AdaptedModuleList.class);
            newModuleMapping.setConverter(new ModuleListConverter());
            descriptor.addMapping(newModuleMapping);
    }Part 1/2

  • Plotting a map in java

    Hello,
    I am busy with a project in which I have to create an applet where a map can be viewed.Actually I have finished creating the applet.My problem is I don't know how go about drawing the map in java.I have the coordinates but I don't know how I am going to plot them.When the map is zoomed the small towns within the map should seen.
    If anyone knows how to solve this please help me as soon as you can.
    Thank you.

    I think there are pretty nifty ways to plot polygons.. don't remember if they're only available in Java2D, or if they're available also without it.
    Anyhow - Java2D probably looks a lot better
    You can scale the map by modifying all your coordinates by dividing them with the current zoom-factor when they are drawn. I guess
    good luck!

Maybe you are looking for

  • T400 Motherboard replacement

    I have a T400 and I'm thinking the MOBO is bad, it boots up then after a little while (5-20 min) it will freeze up, then after a few minutes it shuts off on it's own and reboots. Whewn it starts the screen goes black then after a few minutes it reboo

  • How not to automatically resize updated images

    I'm stumped... I have all my images placed from illustrator at 100%. When I modify the illustrator files, and update the images in InDesign, not only does it resize (up or down), but it moves its x- and - placement coordinates, so I have to go back a

  • Function Module to get the data like in LS26

    Hi Gurus, We are designing a new program and we need to get information about the "available stock", "putaway stock" and "pick quantity" for some storage types. So this is exactly what the LS26 shows. Do you know any Function Module that can extract

  • RE: Currency objects (DecimalData vs float)

    The amount of precision in your database (and Forte code) depends on your clients requirements, no? If, for example, your client is a Swiss bank, I know they typically require precision 6 places to the right of the decimal - and 12 or 13 places to th

  • Continually getting Application Errof 0sc000007b.  How to solve?

    When trying to print off of CS6, I continually the CS6ServiceManager.exe-Application Error.  It says the application was unable to start correctly (0sc000007b).  Click OK to close the application.  When I click OK, nothing happens beyond that message