Simple java date related question

Hi Friends,
I have written this custom date class that compares two dates. The user can enter any number of days,and it should calculate the next date,is that possible???
public class Date implements Comparable {
     private int month, day, year;
     public Date(int m, int d, int y) {
          month = m;
          day = d;
          year = y;
     public int compareTo(Object o) {
          Date a = this;
          Date b = (Date) o;
          if (a.year < b.year) return -1;
          if (a.year > b.year) return 1;
          if (a.month < b.month) return -1;
          if (a.month > b.month) return 1;
          if (a.day < b.day) return -1;
          if (a.day > b.day) return 1;
          return 0;
     public String toString() {
          return month + "/" + day + "/" + year;
     public static void main(String[] args) {
          Date d1 = new Date(21, 03, 2007);
          int days = Integer.parseInt(args[0]);
          System.out.println("New date is:"); // Need to print new date
Expected output:
java Date 30
New date is: 04/20/2007If this is not possible with this class,how can we do this, any ideas.
Your help would be appreciated.
Thanks

Hi,
Try this code out:
import java.text.DateFormat;
import java.util.*;
import javax.swing.JOptionPane;
public class SimpleDate {
     private int month, day, year;
     public SimpleDate() {
          Date date = new Date();
         String myString = DateFormat.getDateInstance().format(date);
         StringTokenizer tokens = new StringTokenizer(myString, "/");
         day = Integer.parseInt(tokens.nextToken());
         month = Integer.parseInt(tokens.nextToken());
         year = Integer.parseInt(tokens.nextToken());
     public SimpleDate(String stdate) {
          try {
               StringTokenizer tokens = new StringTokenizer(stdate, "/");
               day = Integer.parseInt(tokens.nextToken());
               month = Integer.parseInt(tokens.nextToken());
               year = Integer.parseInt(tokens.nextToken());
          catch(Exception e) {
               Date date = new Date();
              String myString = DateFormat.getDateInstance().format(date);
              StringTokenizer tokens = new StringTokenizer(myString, "/");
              day = Integer.parseInt(tokens.nextToken());
              month = Integer.parseInt(tokens.nextToken());
              year = Integer.parseInt(tokens.nextToken());
               JOptionPane.showMessageDialog(null, "Invalid String,\nDate set to current", "Invalid String", JOptionPane.ERROR_MESSAGE);
     public SimpleDate(int d, int m, int y) {
          month = m;
          day = d;
          year = y;
     public int compareTo(Object o) {
          SimpleDate a = this;
          SimpleDate b = (SimpleDate) o;
          if (a.year < b.year) return -1;
          if (a.year > b.year) return 1;
          if (a.month < b.month) return -1;
          if (a.month > b.month) return 1;
          if (a.day < b.day) return -1;
          if (a.day > b.day) return 1;
          return 0;
     private int getNumOfDaysInMonth() {
          boolean leap = false;
          int days = 30;
          if (year % 4 == 0) leap = true;
          if ((month == 1) | (month == 3) | (month == 5) | (month == 7) |
                    (month == 8) | (month == 10) | (month == 12)) {
               days = 31;
          if ((month == 4) | (month == 6) | (month == 9) | (month == 11)) {
               days = 30;
          if (month == 2) {
               if (leap) {
                    days = 29;
               else days = 28;
          return days;
     public void addDays(int nums) {
          while (nums > getNumOfDaysInMonth()) {
               nums = nums - getNumOfDaysInMonth();
               addMonths(1);
          day = day + nums;
          while (day > getNumOfDaysInMonth()) {
               day = day - getNumOfDaysInMonth();
               addMonths(1);
     public void addMonths(int nums) {
          while (nums > 12) {
               nums = nums - 12;
               addYears(1);
          month = month + nums;
          while (month > 12) {
               month = month - 12;
               addYears(1);
     public void addYears(int nums) {
          year = year + 1;
     public int getDay() {
          return day;
     public int getMonth() {
          return month;
     public int getYear() {
          return year;
     public String toString() {
          return day + "/" + month + "/" + year;
}I have swapped the day and month around from mm/dd/yyyy to dd/mm/yyyy
but otherwise its still the same basic code

Similar Messages

  • Simple Java Network Programming Question

    import java.io.*;
    import java.net.*;
    public class ConsumerClient
         private static InetAddress host;
         private static final int PORT = 1234;
         private static Socket link;
         private static Resource item;
         private static BufferedReader in;
         private static PrintWriter out;
         private static BufferedReader keyboard;
         public static void main(String[] args)     throws IOException
              try
                   host = InetAddress.getLocalHost();
                   link = new Socket(host, PORT);
                   in = new BufferedReader(new InputStreamReader(link.getInputStream()));
                   out = new PrintWriter(link.getOutputStream(),true);
                   keyboard = new BufferedReader(new InputStreamReader(System.in));
                   String message, response;
                   do
                        System.out.print("Enter 1 for resource or 0 to quit: ");
                        message = keyboard.readLine();
         if(message.equals("1")**
                             item.takeOne();**
                        //Send message to server on
                        //the socket's output stream...
                        out.println(message);
                        //Accept response from server on
                        //the socket's input stream...
                        response = in.readLine();
                        //Display server's response to user...
                        System.out.println(response);
                   }while (!message.equals("0"));
              catch(UnknownHostException uhEx)
                   System.out.println("\nHost ID not found!\n");
              catch(IOException ioEx)
                   ioEx.printStackTrace();
              finally
                   try
                        if (link!=null)
                             System.out.println("Closing down connection...");
                             link.close();
                   catch(IOException ioEx)
                        ioEx.printStackTrace();
    }

    georgemc wrote:
    BlueNo yel-- Auuuuuuuugh!
    But the real question is: What is the air-speed velocity of an unladen swallow?

  • Date related question

    I am trying to get the events from this (date,month,year) to this (date,month,year) but unable to write sql statement
    My tables:
    SQL> desc event
    Name Null? Type
    E_ID NOT NULL NUMBER(14)
    EVENT VARCHAR2(3110)
    SQL> desc event_time
    Name Null? Type
    E_ID NUMBER(14)
    EYEAR NUMBER(5) //e.g. 2008
    EMONTH NUMBER(3) //e.g. 1 to 12
    SDATE NUMBER(3) //Start day e.g. 1 to 31
    EDATE NUMBER(3) //End day e.g. 1 to 31
    select
         eyear,emonth,event
    from
         event a, event_time b
    where
         a.e_id=b.e_id
    and
         ?????????????? //Her I am facing problems
    Kindly help me
    Thanks & best regards

    Grrr. IT is not a good way to design dates ...
    But anyway, the missing condition could be as:
    and to_date(eyear||emonth||sdate','yyyymmdd') > YOURDATE
    and to_date(eyear||emonth||edate','yyyymmdd') < YOURDATE
    This to look for the records being within the YOURDATE. If you want to look for the records that start at YOURDATE1 and finish at YOURDATE2 Put this:
    and to_date(eyear||emonth||sdate','yyyymmdd') = YOURDATE 1
    and to_date(eyear||emonth||edate','yyyymmdd') = YOURDATE2
    Otherwise, deal with these examples.....

  • Simple java.lang.IndexOutOfBoundsException Question

    Hi, I'm trying to be able to put data into a vector or arraylist without filling the previous spots. Take this for example:
    ArrayList temp=new ArrayList(10);
    temp.ensureCapacity(10);
    temp.set(5, new Integer(5));
    I declaired the size to be 10 twice, why can't I input into the 5th element directly? Is there a way to? I would use normal arrays, but I need to be able to dynamically change the size. I'm having this exact same problem with vectors also. Any ideas? Thank you!

    according to the API specification, the set method of ArrayList:
    Throws:
    IndexOutOfBoundsException - if index out of range (index < 0 || index >= size()).
    size() is the number of elements already inserted.
    Size is not the same as capacity.
    With temp.ensureCapacity(10) you ensure that your ArrayList will be
    able to fit 10 elements without resizing the internal Array, but the
    actual size of the List remains as it was (in your case 0 because you
    haven't inserted anything yet).
    the set method is intended to allow you to change the element at the
    specified index, provided that it has already been inserted in the list.

  • Simple chart data tip question

    Hi,
    If i have a graph with let's say month names on x-axis and some numeric values on y-axis, when over specific chart item tooltip displays both month name and numeric value. How can i achive that tooltip displays only let's say numeric value (y-axis value) and not also month name (x-axis value)?
    Thanks in advance,
    Best regards

    Yes as above and as below.  Calling you dataTipFunction from the Chart tag, whatever type of chart it may be.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" >
        <mx:Script>
            <![CDATA[
            import mx.charts.HitData;
    import mx.collections.ArrayCollection;
            [Bindable]
            private var expensesAC:ArrayCollection = new ArrayCollection( [
                { Month: "Jan", Profit: 2000, Expenses: 1500, Amount: 450 },
                { Month: "Feb", Profit: 1000, Expenses: 200, Amount: 600 },
                { Month: "Mar", Profit: 1500, Expenses: 500, Amount: 300 },
                { Month: "Apr", Profit: 1800, Expenses: 1200, Amount: 900 },
                { Month: "May", Profit: 2400, Expenses: 575, Amount: 500 } ]);
                 private function myDataTipFxn(hd:HitData):String {
                        var dt:String = "Profit = " + hd.item.Profit;
                        return dt;
            ]]>
        </mx:Script>
        <mx:LineChart id="linechart" color="0x323232" height="259"
           showDataTips="true" dataProvider="{expensesAC}"
           dataTipFunction="myDataTipFxn" x="88.5" y="63">
           <mx:horizontalAxis>
               <mx:CategoryAxis categoryField="Month"/>
           </mx:horizontalAxis>
           <mx:series>
               <mx:LineSeries yField="Profit" form="curve" displayName="Profit"/>
               <mx:LineSeries yField="Expenses" form="curve" displayName="Expenses"/>
               <mx:LineSeries yField="Amount" form="curve" displayName="Amount"/>
           </mx:series>
        </mx:LineChart>
    </mx:Application>

  • Ipod Touch 4G simple battery charging related question

    If the Ipod touch 4g battery is fully charged and I keep it connected to the PC and use the Ipod (apps and such), will it use the power from the battery and recharge it all the time or will it completely run over external power? Because I want to maximize battery life, and when I want to play a game or such which needs lots of power the battery is usually empty within 2-3 hours. It would be nice for the battery I guess when I keep the Ipod connected to PC and if it would use the power which comes from the USB. Or does it go "through" the battery first? Because that wouldn't be good for the battery life, since Li-po batteries wear out faster when you keep them at high charge. So I'm just wondering what I should do

    So when my Ipod is fully charged and connected it will get all the power straight from the USB and the battery will be completely untouched? I've looked through the support but I didn't found anything which says that. Could you please show me some links?

  • Efficiency Question: Simple Java DC vs Used WD Component

    Hello guys,
    The scenario is - I want to call a function that returns a FileInputStream object so I can process it on my WD view. I can think of two approaches - one is to simply write a simple Java DC that does so and just use it as a used DC so I can call the functionality from there. Or create another WD DC that exposes the value (as binary) via component interface.
    I'm leaning on the simple Java DC approach - its easier to create. But I'm just curious on what would be the Pro-side (if there's any) if I use the WD Component interface approach? Is there a plus for the efficiency? (Though I doubt) Or is it just a 'best/recommended practice' approach?
    Thanks!
    Regards,
    Jan

    Hi Jan
    >one is to simply write a simple Java DC that does so and just use it as a used DC so I can call the functionality from there
    Implemented Java  API for the purpose mentioned in your question is the right way, I think. The Java API can be even located in the same WebDynpro DC as your WebDynpro components. There is not strongly necessity to put it into separate Java DC.
    >Or create another WD DC that exposes the value (as binary) via component interface
    You should not do this because in general WD components' purpose is UI, not API. Implementing WD component without any UI, but with some component interface has very-very restricted use cases. Such WD component shall only be a choice in the cases when the API is WebDynpro based and if you have to strongly use WebDynpro Runtime API in order to implement your own API.
    If your API does not require WebDynpro Runtime API invocations or anything else related to WebDynpro then your choice is simple Java API.
    >But I'm just curious on what would be the Pro-side (if there's any) if I use the WD Component interface approach? Is there a plus for the efficiency?
    No. Performance will be better in simple Java API then in WebDynpro component interface. The reason is the API will not pass thought heavy WebDynpro engine.
    BR, Siarhei

  • Two related questions:  ColdFusion 10/Java applications and J2EE supported servers

    I have two related questions:
    1.  CF10 and integration with Java Web applications
    We have a couple of Java applications running on JRun and interfacing with CF9 applications.  The JRun clusters were created through the JRun Admin and, apart from lack of Axis 2.0 support, have served us well for years now.  And, as would be the case, the ColdFusion9/Java/Flash application is a critical public-facing application that the business uses for bidding on projects.
    It appears that with ColdFusion 10 on Tomcat, we will not be able to run those Java applications on a Tomcat-CF10 JVM cluster.  Is this correct?  IF so, what are our options? 
    2.  J2EE Application Servers supported by Adobe for CF10
    Which of these is correct?
    A.  This URL (http://www.adobe.com/products/coldfusion-enterprise/faq.html) states "ColdFusion 10 supports IBM® WebSphere, Oracle® WebLogic, Adobe JRun, Apache Tomcat, and JBoss."
    B.  This URL (http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/coldfusion/pdfs/cf1 0/coldfusion10-support-matrix.pdf) states:
    "J2EE application servers: WebLogic Server 10.3, 11.1, WebSphere Application Server 7, ND 7 JBoss 5.1, 6.0, 7.1.0"
    I *think* "A" above is wrong re. support for Adobe JRun.  It does not specify a version of Apache Tomcat unless it is simply referring to the custom version the comes with CF10.
    Option "B" above shows no support of Adobe JRun or 'standard' Apache Tomcat.
    Thanks,
    Scott

    Question 1 above was answered:  "No support for Java web applications under CF10's custom version of Tomcat"
    Question 2:  No answer yet:  Is Apache Tomcat (NOT Adobe's customized version) supported for CF10 J2EE deployment?  I do not see any installation instructions on how to install CF10 on Apache Tomcat 6 or 7.
    Is anybody using Apache Tomcat as their J2EE app servers and, again, NOT Adobe's customized/limited version? 
    Thanks,
    Scott

  • Problem while executing simple java program

    Hi
    while trying to execute a simple java program,i am getting the following exception...
    please help me in this
    java program :import java.util.*;
    import java.util.logging.*;
    public class Jump implements Runnable{
        Hashtable activeQueues = new Hashtable();
        String dbURL, dbuser, dbpasswd, loggerDir;   
        int idleSleep;
        static Logger logger = Logger.getAnonymousLogger();      
        Thread myThread = null;
        JumpQueueManager manager = null;
        private final static String VERSION = "2.92";
          public Jump(String jdbcURL, String user, String pwd, int idleSleep, String logDir) {
            dbURL = jdbcURL;
            dbuser = user;
            dbpasswd = pwd;
            this.idleSleep = idleSleep;
            manager = new JumpQueueManager(dbURL, dbuser, dbpasswd);
            loggerDir = logDir;
            //preparing logger
            prepareLogger();
          private void prepareLogger(){      
            Handler hndl = new pl.com.sony.utils.SimpleLoggerHandler();
            try{
                String logFilePattern = loggerDir + java.io.File.separator + "jumplog%g.log";
                Handler filehndl = new java.util.logging.FileHandler(logFilePattern, JumpConstants.MAX_LOG_SIZE, JumpConstants.MAX_LOG_FILE_NUM);
                filehndl.setEncoding("UTF-8");
                filehndl.setLevel(Level.INFO);
                logger.addHandler(filehndl);
            catch(Exception e){
            logger.setLevel(Level.ALL);
            logger.setUseParentHandlers(false);
            logger.addHandler(hndl);
            logger.setLevel(Level.FINE);
            logger.info("LOGGING FACILITY IS READY !");
          private void processTask(QueueTask task){
            JumpProcessor proc = JumpProcessorGenerator.getProcessor(task);       
            if(proc==null){
                logger.severe("Unknown task type: " + task.getType());           
                return;
            proc.setJumpThread(myThread);
            proc.setLogger(logger);       
            proc.setJumpRef(this);
            task.setProcStart(new java.util.Date());
            setExecution(task, true);       
            new Thread(proc).start();       
         private void processQueue(){       
            //Endles loop for processing tasks from queue       
            QueueTask task = null;
            while(true){
                    try{
                        //null argument means: take first free, no matters which queue
                        do{
                            task = manager.getTask(activeQueues);
                            if(task!=null)
                                processTask(task);               
                        while(task!=null);
                    catch(Exception e){
                        logger.severe(e.getMessage());
                logger.fine("-------->Sleeping for " + idleSleep + " minutes...hzzzzzz (Active queues:"+ activeQueues.size()+")");
                try{
                    if(!myThread.interrupted())
                        myThread.sleep(60*1000*idleSleep);
                catch(InterruptedException e){
                    logger.fine("-------->Wakeing up !!!");
            }//while       
        public void setMyThread(Thread t){
            myThread = t;
        /** This method is only used to start Jump as a separate thread this is
         *usefull to allow jump to access its own thread to sleep wait and synchronize
         *If you just start ProcessQueue from main method it is not possible to
         *use methods like Thread.sleep becouse object is not owner of current thread.
        public void run() {
            processQueue();
        /** This is just another facade to hide database access from another classes*/
        public void updateOraTaskStatus(QueueTask task, boolean success){
            try{         
                manager.updateOraTaskStatus(task, success);
            catch(Exception e){
                logger.severe("Cannot update status of task table for task:" + task.getID() +  "\nReason: " + e.getMessage());       
        /** This is facade to JumpQueueManager method with same name to hide
         *existance of database and SQLExceptions from processor classes
         *Processor class calls this method to execute stored proc and it doesn't
         *take care about any SQL related issues including exceptions
        public void executeStoredProc(String proc) throws Exception{
            try{
                manager.executeStoredProc(proc);
            catch(Exception e){
                //logger.severe("Cannot execute stored procedure:"+ proc + "\nReason: " + e.getMessage());       
                throw e;
         *This method is only to hide QueueManager object from access from JumpProcessors
         *It handles exceptions and datbase connecting/disconnecting and is called from
         *JumpProceesor thread.
        public  void updateTaskStatus(int taskID, int status){       
            try{
                manager.updateTaskStatus(taskID, status);
            catch(Exception e){
                logger.severe("Cannot update status of task: " + taskID + " to " + status + "\nReason: " + e.getMessage());
        public java.sql.Connection getDBConnection(){
            try{
                return manager.getNewConnection();
            catch(Exception e){
                logger.severe("Cannot acquire new database connection: " + e.getMessage());
                return null;
        protected synchronized void setExecution(QueueTask task, boolean active){
            if(active){
                activeQueues.put(new Integer(task.getQueueNum()), JumpConstants.TH_STAT_BUSY);
            else{
                activeQueues.remove(new Integer(task.getQueueNum()));
        public static void main(String[] args){
                 try{
             System.out.println("The length-->"+args.length);
            System.out.println("It's " + new java.util.Date() + " now, have a good time.");
            if(args.length<5){
                System.out.println("More parameters needed:");
                System.out.println("1 - JDBC strign, 2 - DB User, 3 - DB Password, 4 - sleeping time (minutes), 5 - log file dir");
                return;
            Jump jump = new Jump(args[0], args[1], args[2], Integer.parseInt(args[3]), args[4]);
            Thread t1= new Thread(jump);
            jump.setMyThread(t1);      
            t1.start();}
                 catch(Exception e){
                      e.printStackTrace();
    } The exception i am getting is
    java.lang.NoClassDefFoundError: jdbc:oracle:thin:@localhost:1521:xe
    Exception in thread "main" ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
    JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820] Please help me.....
    Thanks in advance.....sathya

    I am not willing to wade through the code, but this portion makes me conjecture your using an Oracle connect string instead of a class name.
    java.lang.NoClassDefFoundError: jdbc:oracle:thin:@localhost:1521:xe

  • How to do sorting/filtering on custom java data source implementation

    Hi,
    I have an entity driven view object whose data should be retrieved and populated using custom java data source implementation. I've done the same as said in document. I understand that Query mode should be the default one (i.e. database tables) and createRowFromResultSet will be called as many times as it needs based on the no. of data retrieved from service, provided we should write the logic for hasNextForCollection(). Implementation sample code is given below.
    protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams) {      
    Iterator datumItr = retrieveDataFromService(qc, params);
    setUserDataForCollection(qc, datumItr);
    hasNextForCollection(qc);
    super.executeQueryForCollection(qc, params, noUserParams);
    protected boolean hasNextForCollection(Object qc) {
    Iterator datumItr = (Iterator) getUserDataForCollection(qc);
    if (datumItr != null && datumItr.hasNext()){
    return true;
    setCallService(false);
    setFetchCompleteForCollection(qc, true);
    return false;
    protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet resultSet) {
    Iterator datumItr = (Iterator) getUserDataForCollection(qc);
    Object datumObj = datumItr.next();
    ViewRowImpl r = createNewRowForCollection(qc);
    return r;
    Everything is working fine include table sorting/filtering. Then i noticed that everytime when user perform sorting/filtering, executeQueryForCollection is called, which in turn calls my service. It is a performance issue. I want to avoid. So i did some modification in the implementation in such a way that, service call will happen only if the callService flag is set to true, followed by executeQuery(). Code is given below.
    private boolean callService = false;
    public void setCallService(boolean callService){
    this.callService = callService;
    public boolean isCallService(){
    return callService;
    protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams){
    if (callService)
    Iterator datumItr = retrieveDataFromService(qc, params);
    setUserDataForCollection(qc, datumItr);
    hasNextForCollection(qc);
    super.executeQueryForCollection(qc, params, noUserParams);
    Issue i have:
    When user attempts to use table sort/filter, since i skipped the service call and set null as userDataCollection, createRowFromResultSet is not called and data which i retrieved and populated to view object is totally got vanished!!. I've already retrived data and created row from result set. Why it should get vanished? Don't know why.
    Tried solution:
    I came to know that query mode should be set to Scan_Entity_Cache for filtering and Scan_View_Rows for sorting. I din't disturb the implementation (i.e. skipping service call) but overrided the executeQuery and did like the following code.
    @Override
    public void executeQuery(){
    setQueryMode(callService ? ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES : ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS);
    super.executeQuery();
    By doing this, i could able to do table filtering but when i try to use table sorting or programmatic sorting, sorting is not at all applied.
    I changed the code like beolw*
    @Override
    public void executeQuery(){
    setQueryMode(callService ? ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES : ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);
    super.executeQuery();
    Now sorting is working fine but filtering is not working in an expected way because Scan_View_rows will do further filtering of view rows.
    Question:
    I don't know how to achieve both filtering and sorting as well as skipping of service call too.
    Can anyone help on this?? Thanks in advance.
    Raguraman

    Hi,
    I have an entity driven view object whose data should be retrieved and populated using custom java data source implementation. I've done the same as said in document. I understand that Query mode should be the default one (i.e. database tables) and createRowFromResultSet will be called as many times as it needs based on the no. of data retrieved from service, provided we should write the logic for hasNextForCollection(). Implementation sample code is given below.
    protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams) {
      Iterator datumItr = retrieveDataFromService(qc, params);
      setUserDataForCollection(qc, datumItr);
      hasNextForCollection(qc);
      super.executeQueryForCollection(qc, params, noUserParams);
    protected boolean hasNextForCollection(Object qc) {
      Iterator datumItr = (Iterator) getUserDataForCollection(qc);
      if (datumItr != null && datumItr.hasNext()){
        return true;
      setFetchCompleteForCollection(qc, true);
      return false;
    protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet resultSet) {
      Iterator datumItr = (Iterator) getUserDataForCollection(qc);
      Object datumObj = datumItr.next();
      ViewRowImpl r = createNewRowForCollection(qc);
      return r;
    }Everything is working fine include table sorting/filtering. Then i noticed that everytime when user perform sorting/filtering, executeQueryForCollection is called, which in turn calls my service. It is a performance issue. I want to avoid. So i did some modification in the implementation in such a way that, service call will happen only if the callService flag is set to true, followed by executeQuery(). Code is given below.
    private boolean callService = false;
    public void setCallService(boolean callService){
      this.callService = callService;
    public boolean isCallService(){
      return callService;
    protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams){
      if (callService) {
        Iterator datumItr = retrieveDataFromService(qc, params);
        setUserDataForCollection(qc, datumItr);
      hasNextForCollection(qc);
      super.executeQueryForCollection(qc, params, noUserParams);
    }Issue i have:
    When user attempts to use table sort/filter, since i skipped the service call and storing of userDataCollection, createRowFromResultSet is not called and data which i retrieved and populated to view object is totally got vanished!!. I've already retrived data and created row from result set. Why it should get vanished? Don't know why.
    Tried solution:
    I came to know that query mode should be set to Scan_Entity_Cache for filtering and Scan_View_Rows for sorting. I din't disturb the implementation (i.e. skipping service call) but overrided the executeQuery and did like the following code.
    @Override
    public void executeQuery(){
      setQueryMode(callService ? ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES : ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS);
      super.executeQuery();
    }By doing this, i could able to do table filtering but when i try to use table sorting or programmatic sorting, sorting is not at all getting applied.
    I changed the code like below one (i.e. changed to ViewObject.QUERY_MODE_SCAN_VIEW_ROWS instead of ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS)
    @Override
    public void executeQuery(){
      setQueryMode(callService ? ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES : ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);
      super.executeQuery();
    }Now sorting is working fine but filtering is not working in an expected way because Scan_View_rows will do further filtering of view rows.
    If i OR'ed the Query Mode as given below, i am getting duplicate rows. (vewObject.QUERY_MODE_SCAN_ENTITY_ROWS | ViewObject.QUERY_MODE_SCAN_VIEW_ROWS) Question:
    I don't know how to achieve both filtering and sorting as well as skipping of service call too.
    Can anyone help on this?? Thanks in advance.
    Raguraman
    Edited by: Raguraman on Apr 12, 2011 6:53 AM

  • I want to check all functions of PCI 6534.I have read the user manual..I have some memory related questions.​Please help me for that.

    I want to check all functions of PCI 6534.I have read the user manual..I have some memory related questions.Please help me for that.
    1.)If i am using the continuous output mode.and the size of generated data is less than 32 MB.If i want to preload the memory,what should i do?I want that first of all i load all my data to onboard memory & then i want to make start the transfer between 6534 & peripheral.Is it possible?As per me it should be.Plz tell me how should i do this?I think that in normal procedure the transfer between 6534-peripheral & outputting data from pc buffer to onboard memory works parallely.But i don't want this.Is it poss
    ible?
    (2).Similarly in finite input operation(pattern I/O) is it possible to preload the memory and then i read it?Because i think that the PC memory will be loaded automatically when 6534 acquires the data and then when we use DIO read vi the pc buffer data will be transferred to application buffer.If this is true,i do not want this.Is it possible?
    (3) One more question is there if i am using normal operation onboard memory will be used bydefault right?Now if i want to use DMA and if i have data of 512 bytes to acquire.How will it work and how should i do it?Please tell me the sequence of operations.As per my knowledge in normal DMA operation we have 32 Bytes FIFO is there so after acquisition of 32 bytes only i can read it.How it will known to me that 32 bytes acquisition is complete?Next,If i want to acquire each byte separately using DMA interrupts what should i do?Provide me the name of sourse from which i can get details about onboard memory & DMA process of 6534 specifically
    (4).In 6534 pattern Input mode,if i want to but only 10 bits of data.and i don't want to waste any data line what should i do?

    Hi Vishal,
    I'll try to answer your questions as best I can.
    1) It is definitely possible to preload data to the 32MB memory (per group) and start the acquisition after you have preloaded the memory. There are example programs on ni.com/support under Example Code for pattern generation and the 6534 that demonstrate which functions to use for this. Also, if your PC memory buffer is less than 32MB, it will automatically be loaded to the card. If you are in continuous mode however, you can choose to loop using the on-board memory or you can constantly be reading the PC memory buffer as you update it with your application environment.
    2) Yes, your data will automatically be loaded into the card's onboard memory. It will however be transferred as quickly as possible to the DMA FIFO on the card and then transferred to the PC memory buffer through DMA. It is not going to wait until the whole onboard memory is filled before it transfers. It will transfer throughout the acquisition process.
    3) Vishal, searching the example programs will give you many of the details of programming this type of application. I don't know you application software so I can't give you the exact functions but it is easiest to look at the examples on the net (or the shipping examples with your software). Now if you are acquiring 512 bytes of data, you will start to fill your onboard memory and at the same time, data will be sent to the DMA FIFO. When the FIFO is ready to send data to the PC memory buffer, it will (the exact algorithm is dependent on many things regarding how large the DMA packet is etc.).
    4) If I understand you correctly, you want to know if you waste the other 6 bits if you only need to acquire on 10 lines. The answer to this is Yes. Although you are only acquiring 10 bits, it is acquired as a complete word (16bits) and packed and sent using DMA. You application software (NI-DAQ driver) will filter out the last 6 bits of non-data.
    Hope that answers your questions. Once again, the example code on the NI site is a great place to start this type of project. Have a good day.
    Ron

  • Max date related to Max value in OBIEE answers

    Hi,
    I have one requirement in answers where in which i have to show the data with following columns
    My table structure is Account Number, date, Balance
    My report structure is Account Number, Max balance, Max balance Date, Balance as on start date, Balance as on end date.
    I have to provide a adhoc date filter, where in which user has the option to select the start date and end date.
    user wants the report in same format
    Can any one please let me know how to handle this in OBIEE 10.1.3.4 Answers.
    Thanks
    Krishna

    Hi Deva,
    But i tried with a simple scott RPD. It has two tables DEP and EMP. In the criteria section i dragged and dropped 4 columns. DEPNO, DNAME, ENAME AND SALARY. And in the criteria filter section, i added the column "DNAME" and chose the static filter as "ACCOUNTING". when i clicked on the results tab. It displayed the results related to DNAME-ACCOUNTING. After that, I created a dashboard_Prompt in which i chose the column prompt and the column as DNAME and the condition i gave is - equal to. In the Dashboard section, I dragged and dropped both the Dashboard_Prompt and Analysis. In the Dashboard, in Dashboard_Prompt section is chose the value "RESEARCH". Now the default analysis that was displaying the results related DNAME-ACCOUNTING changed and filtered the data related to DNAME-RESEARCH.
    By this experiment, I guess giving static value in criteria and changing it in the Dashboard_prompt will work. Is it right?
    Thanks
    Thenmozhi

  • How to export crystal report into disk using simple java

    hello
    i m working in the reporting part my j2ee application
    my requirement is that export this rpt file into pdf file and store into disk by writing simple java program
    if any have code this then plz provide me
    thanks & regards
    ram

    Uhm, these messages are not that related. One's a
    JNDI problem, this one's just some vague "how do I
    do" stuff.He wants to produce something in crystal reports and turn it into a PDF. So yes they are related. And yet another thread for this just sprung up.

  • Java dates from 0-11 or 1-12

    Hello
    In java Date, the months ranges from 0-11 . first january is thus 1/0/2003 (in dd/mm/yyyy form). But in almost all databases , month values are counted as 1-12 . That is first january becomes 1/1/2003 . Obviously we have to show the users month values from 1-12 and not from 0-11. This obviuosly places some overhead when doing calculations and display. Sometimes there are situations where we have to get the date from database using getString() function, but that will vary with the result of Resultset.getDate() . Any way to overcome such limitations? and why java has such dates?

    I kind of agree. When I first started, I felt that I shouldn't ever rely upon an assumption about the value of a constant field (i.e. Calendar.JANUARY, etc).
    But since I did need to have a user-intuitive interface (both in guis and because we deal regularly with processing today's or yesterday's version of a file named like yyyyMMdd.input), I always provided a class that was a day-only object who did its behind-the-scenes work with Calendar by using switch statements to choose the correct Calendar month constants (rather than by adding or subtracting one).
    But (a) that got old quick because of either the same cumbersome code repeated everywhere or having to have many otherwise simple standalone programs depend on a central utility class to do this, and (b) the Calendar class documentation states that the value of the month is zero-based, so the horror of assuming constant values is not so bad.
    So now I have slightly less cumbersome code (adding or subtracting one) repeated everywhere...

  • Can we call a simple java application from ESB

    Please let me know how this can be done by using a ESB. The application jar exists on the host server. How we can pass parameters etc and receive results from this application.
    Any help will be greatly appreciated.
    Prakash

    Not sure if I completely understand your question, but you can certainly try following ways:
    - call your java application via WSIF. ESB with JAVA wsif is available in 10.1.3.3.1 only (it is not supported in 10.1.3.3 very well).
    - you will have to include this jar file in server.xml or bpel/system/classes so that it is available to the SOA jvm.
    - You mentioned it is simple java application, but if your java API has complex (object) input and output, you will need some work
    HTH,
    Chintan

Maybe you are looking for