]> rtime.felk.cvut.cz Git - orte.git/blob - orte/java/src/org/ocera/orte/types/MessageData.java
JORTE: initialize string_pointer variable to make Java compiler happy
[orte.git] / orte / java / src / org / ocera / orte / types / MessageData.java
1 /* MessageData.java */
2
3 /**
4  * Class MessageData.
5  *
6  * @author Lukas Pokorny (lukas_pokorny@centrum.cz)
7  * @author CTU FEE Prague - Department of Control Engineering (dce.felk.cvut.cz)
8  * @author Project ORTE - OCERA Real Time Ethernet (www.ocera.org)
9  * @author dedication to Kj
10  * @version 0.1
11  *
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  */
24
25 package org.ocera.orte.types;
26 import java.nio.ByteBuffer;
27 import java.nio.ByteOrder;
28
29 public abstract class MessageData
30 {
31
32   private   String         topic;
33   protected  ByteBuffer    buffer; 
34   
35    /**
36     * default constructor
37     * */
38    public MessageData() 
39    {
40      this.buffer = ByteBuffer.allocateDirect(getMaxDataLength());
41      this.buffer.order(ByteOrder.nativeOrder());
42      //System.out.println(":j: instance MessageData created..");        
43    }    
44
45   public abstract void  read();
46   public abstract void write();
47
48   /** 
49    * Get the Publication's Topic.  
50    * @ return Publication's topic  
51    * */
52   public String getTopic()
53   {
54     return topic;
55   }
56    
57   /** 
58    * Set the Publication's Topic.  
59    * @ return void 
60    * */
61   public void setTopic(String newTopic)
62   {
63     topic = newTopic;
64   }
65        
66   /** 
67    * Get default Type of Publication. Default type name is abbreviate from its class name.  
68    * @ return default type of Publication 
69    * */
70   public String getType()
71   {
72     char    extensionSeparator = '.';
73     // get name of class
74         String  className = getClass().getName();
75     // find last separator
76         int     dot = className.lastIndexOf(extensionSeparator);
77         return  className.substring(dot + 1);
78   }
79   
80   public abstract int getMaxDataLength();
81   
82   public ByteBuffer getBuffer()
83   {
84         return this.buffer;
85   }
86   
87 }
88
89
90