Is there no 'bit' data type in Java?

i want to write a private protol in java , but there is no 'bit' data type, it is difficult to communicate data frame to other application which wrote in c++.
can any friend give me a hand?
thanks.
:)

In Java there are no bit fields.
Also you can not directly map an external data layout to an internal representation, that is, there is no "struct" which you could read directly from a file.
You can read your int's or bytes's and do some computations with them.

Similar Messages

  • Is there a date data type in java???

    Hi guys!
    Is there a date data type in java???
    How to declare date data type variable?
    Your reply is greatly appreciated!
    -=samer=-

    RTFM
    there's about 8 date types, depending on what you want
    see
    java.util.Date
    java.util.Calendar
    GregorianCalendar
    SimpleDateFormat
    System.currentTimeMillis()

  • How to read XI Data type in Java code and populate as array list, using UDF

    Hi,
    How to read XI Data type in Java code and populate as array list, using UDF?
    Is there any API using which  the XI data types can be read?
    Kindly reply.
    Richa

    Input Structure:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:CustomerCreateResp xmlns:ns0="urn:bp:xi:up:re:cust_mdm:cmdm:pr5:100">
       <CUSTOMER>
          <item>
             <CUSTOMERNO/>
             <MDMCUSTOMER/>
             <CREATE_DATE/>
             <RETURN>
                <TYPE/>
                <MESSAGE/>
             </RETURN>
             <PT_CONTPART_RETURN>
                <item>
                   <MDM_CONTACT/>
                   <CONTACT/>
                </item>
             </PT_CONTPART_RETURN>
             <PARTNERS>
                <item>
                   <CUSTOMERNO/>
                   <PARTNER_FUNCTION/>
                   <PARTNER_NUMBER/>
                   <DEFAULT_PARTNER/>
                </item>
             </PARTNERS>
          </item>
       </CUSTOMER>
    </ns0:CustomerCreateResp>
    Output structure
    (Sample output structure.This actually needs to be mapped and generated using UDF)
    <?xml version="1.0" encoding="UTF-8"?>
    <ns1:updateCustomer xmlns:ns1="urn:xiSericeVi"><ns1:customer><ns2:ArrayList xmlns:ns2="java:sap/standard">[]</ns2:ArrayList></ns1:customer><ns1:name>2344566</ns1:name></ns1:updateCustomer>

  • How to get the values from struct data type using java code..?

    Hi ,
    I am newer to java.
    we are using oracle database.
    How to get the data from struct data type using java code.
    Thanks in Advance.
    Regards,
    kumar

    Hi Rajeev,
    To retrieve a FilterContainer you will need to traverse the report structure:
    ReportStructure boReportStructure = boDocumentInstance.getStructure();
    ReportContainer boReportContainer = (ReportContainer) boReportStructure.getReportElement(0);
    FilterContainer boFilterContainer = null;
    if (boReportContainer.hasFilter()) {
         boFilterContainer = boReportContainer.getFilter();
    } else {
         boFilterContainer = boReportContainer.createFilter(LogicalOperator.AND);
    Calling boDocumentInstance.getStructure() will retrieve the entire structure for the document.
    Calling boReportStructure.getReportElement(0) will retrieve the structure for the first report of the document.
    Hope this helps.
    Regards,
    Dan

  • Does data type nvarchar in SQL 7.0 have matched DATA TYPE in JAVA

    does data type nvarchar in SQL 7.0 have matched DATA TYPE in JAVA
    I use odbc-jdbc bridge to connect to SQL 7.0
    thanks in advance!

    try String.
    java.sql.Types.VARCHAR would be the sql type.

  • Selecting #of bits for data types in Java

    hi,
    i would like to know if we can constrain compiler on allocating memory to basic data types, such as int, float, short etc. i would like to read an exactly four byte integer into an int, 2 byte short into a short etc. i need to read these parameters exactly of their specified number of bytes - not more or less - as if i read anything more/less, i will be reading a part of other parameter.
    i know that C allows us to do this by letting us to specify number of bits we like to allocate for each data type (for eg. unsigned int:16; means i need an unsigned int of exactly 16bits (2 bytes long) -no more and no less).
    Is there anything similar i can do in Java?
    any suggestion is greately appreciated.
    Thanks,

    All primitive types in Java are well-defined. In contrast to C/C++, an int in Java is allways 32 bits, using one's complement, a char is allways 16 bits etc.
    Java does not give you direct acces to physical memory - that would compromise the basic design of Java.
    You can read individual bytes from files, and you can do all the integer arithmetic in Java as you can in C/C++. To convert eg. fout bytes to one int, you could do the following:
    byte b1= (some byte value),
         b2,
         b3,
         b4;
    int i= (((b1 << 8) | b2 << 8) | b3 << 8) | b4;
    b1 being the most significant byte, b4 being the least significant.
    Did this answer you questions?

  • Unsigned data types in Java

    I know this is beating an old dead horse, but I find it frustrating that Java does not support unsigned types. I frequently work with binary file formats that store data in unsigned types. In Java there is no easy way to work with these files. For example, if the file has unsigned longs it is a problem. Also, if the file has unsigned ints, a very common occurrence, I have to "upcast" those numbers into longs. This is expensive from a time and space point of view since data files from satellites can be hundreds of megabytes or gigabytes in size and I have to double them in size just to capture the final bit. It is also inefficient to process these files because now I am using longs (64-bits) on systems that are usually optimized for 32-bits which means processing code takes a big performance hit.
    Also, there is simple confusion. For example, if I provide data from a file to a user and they see "long" where they know they data is an int they start asking questions and I have to start explaining why it is a long instead of an int. Scientists don't like data to be "translated" for integrity reasons so I have make these long explanations how upconverting to a long is not really a translation, etc. It just creates a lot of confusion and problems.
    Also, look at from a developer point of view. The developer has a spec in front of him listing the data types and is now reading the corresponding java class where the data gets loaded--all the data types are different because of the upconverting--it creates confusion.
    Is there any hope of having unsigned types or we all condemned to a lifetime of upconverting?

    JohnChamberlain wrote:
    I thought it was obvious that you need to upconvert unsigned values because otherwise the number will be wrong if the sign bit is set.No. A 32-bit scalar with the high bit set is still correct (bit-for-bit). You only get problems if you perform arithmetic, right-shift or widening-conversion on it, or make a decimal String representation.
    For example, lets say the file has an unsigned int (uint32) value of 0xF1234567 which in decimal is 4,045,620,583. This is a positive number. If you load this value into a Java int value it will be interpreted as the negative number -249,346,713.For a given value of "interpreted"; Integer.toHexString(0xF1234567) produces the expected result.
    Further example: if you load a file containing uint32 values into Java ints and then average all the values you might come out with a negative number. Obviously this is impossible because the file contains only positive numbers so the average of those numbers cannot be negative.Obviously if you need to do this on a number of large 32-bit scalars you need the sum scalar to be 64-bit which means you can mask your way out of any issues when you perform the widening conversion.
       int[] x = { 0xF1234567, 0xF1234565, 0xF1234557 };
       long sum = 0L;
       for(int i=0;i<x.length;++i) { sum += 0xffffffffL & x; }
    int average = (int)(sum/x.length); // average is now "correct" (bit-for-bit)
    Maybe it wasn't clear that I need to not only load the values but use them.You did fail to mention that.
    The files I load get passed on to other applications where the values get used and obviously that includes doing calculations on them so the values have to be correct. I cannot load a bunch of UInt32s into Java ints and say "pretend they are positive numbers".I get the impression you are not really interested in finding solution.
    It can be releasing to have a whinge but don't let it distract you from thinking outside the box.
    I think part of the problem here is that Java programmers do not have to work with binary files or binary protocols so they do not appreciate that doing this has serious problems in Java.I have done binary protocols. Not having unsigned scalars was never a problem.
    For example, take unsigned longs. If you are working with a binary source that has these you have no alternative except to use the BigInteger package and convert every value into an object, an incredibly painful and CPU-intensive operation if you dealing with files with gigabytes of data.You might want to consider alternatives, like
    unsigned right-shifting ('>>>') the incoming values for 64-bit scalar fields where dividing by 2 would be acceptable,
    etc.

  • Can't transfer date type from java proxy to XI

    I 'm using Java proxy send message to XI&#12290;
    but some element for Date type didn't transfered to XI.
    XI 3.0
    I have tried  notes:719010.

    I have the same exact problem after more than year with no problem... Please help meI didn't install new firmware since I have the player I have the .40 version?thanks

  • Call Oracle procedure with custom data type within Java and Hibernate

    I have a custom date TYPE in Oracle
    like
    CREATE TYPE DATEARRAY AS TABLE OF DATE;
    and I have a Oracle function also
    like
    CREATE OR REPLACE FUNCTION doesContain (list DATEARRAY, val VARCHAR2) RETURN NUMBER
    IS
    END doesContain;
    In my Java class,
    I have a collection which contain a list of java.util.Date objects
    When I call Oracle function "doesContain", how to pass my java collection to this Oracle function ...
    anyone can provide solutions?
    Please !!!
    Thanks,
    Pulikkottil

    Vu,
    First of all you need to define your types as database types, for example:
    create or replace type T_ID as table of number(5)Then you need to use the "oracle.sql.ARRAY" class. You can search this forum's archives for the term "ARRAY" in order to find more details and you can also find some samples via the JDBC Web page at the OTN Web site.
    Good Luck,
    Avi.

  • Hi is there any XMLDocument data type available in SOAP libraries

    How to convert string to XML Document data type and is there any XML Document type available in SOAP Libraries&j2ee api?

    Hello Pradeep,
    I attached a code sample. But if xString is no valid type it wont help.
    Regards,
      Klaus
    report Test .
      data:
        serialized_Data     type xstring,
        orig_Strings        type string_Table,
        clnt_Strings        type string_Table.
      field-symbols:
        <cur_String>  type string.
    * data provider
      do 10 times.
        insert initial line into table orig_Strings assigning <cur_String>.
        <cur_String> = sy-Index.
      enddo.
      sort orig_Strings descending.
      export data = orig_Strings to data buffer serialized_Data.
    * client side
      import data = clnt_Strings from data buffer serialized_Data.
      loop at clnt_Strings assigning <cur_String>.
        write: / sy-tabix, <cur_String>.
      endloop.

  • Runtime conversion of a string value to a primitive data type in java

    can anyone of you give me an idea to convert a string value to a primitive data type during run time...i have the value and the type to which it has to be converted as String values...do you have any idea ,...pls share

    String recvalvalue = inputval;
                    String recvartype = inputtype;
                   if (recvartype.equals("int")){
                   value0 = Integer.parseInt(recvalvalue);
             else
             if (recvartype.equals("double")){
                    value1  = Double.parseDouble(recvalvalue);
             else
             if(recvartype.equals("float")){
              value2 = Float.parseFloat(recvalvalue);
             else
             if(recvartype.equals("Boolean")){
              value3 = Boolean.parseBoolean(recvalvalue);
             else
             if(recvartype.equals("char")){
               value4 = (char)recvalvalue.charAt(0);
            else
            if(recvartype.equals("String")){
              value5 = recvalvalue;
             else
             if(recvartype.equals("byte")){
               value6 = Byte.parseByte(recvalvalue);
                  //listA.add(6, value6);
                  //     listA.g = value6;
             else
              if(recvartype.equals("long")){
               value7 = Long.parseLong(recvalvalue);
             else
              if(recvartype.equals("short")){
              value8 = Short.parseShort(recvalvalue);
             } yes i can do this but the resultant value has to be assigned to a variable of a specific type which is here recvartype .....it has to be done dynamically automatically..if we know what type of data is that we can convert and assign to the type but we donot know when we run the program as the program will be supllied by someone and has to be executed

  • Using oracle.sql.BLOB data type in Java Class to pass in a Blob

    All,
    I'm trying to pass in a BLOB from PL/SQL to a Java Class, but the BLOB isn't passed correctly.
    When I check the length of the BLOB in PL/SQL its different from the length of the BLOB in java.
    I'm using DB 11g and the ojdbc5.jar file in my java classes.
    The java function uses the oracle.sql.BLOB type to get the parameter.
    The java class is loaded into the DB and called via a PL/SQL function.
    Kind regards,
    Nathalie

    The question is indeed a little ambigious defined ;o)
    When I pass the BLOB to the java method and invoke BLOB.getBytes() and then get the length of the BLOB in java the length of the BLOB is bigger than in PL/SQL.
    When I use the method 'getBinaryStream' and write this to a buffer, the code works.
    I will log a tar regarding the getBytes()-method to ask for more detailed information regarding the methods provided using the JDBC Drivers.
    Kind regards,
    Nathalie

  • How to read char() for bit data DB2's type in Oracle?

    Hello,
    I am developing an application (from JDeveloper) to operate with two data base. In one hand threre is Oracle and in the other one DB2 (AS400).
    I am trying to read a DB2'sfield with the "char() for bit data" type from Oracle, but I can't read it.
    I have trying:
    rset.getObject(1) -->[B@1a786c3
    rset.getBinaryStream(1) --> java.io.ByteArrayInputStream@1a786c3
    rset.getAsciiStream(1) --> java.io.ByteArrayInputStream@2bb514
    rset.getCharacterStream(1) -->java.io.StringReader@1a786c3
    Do you have any solution to see the value of this type of field?
    Thank you and regards

    I have to synchronize unidirectionally from the Oracle database to DB2. And I'd like to save the information of the record of DB2 prior to the update operation.
    And here is where the problem arises for me, because when I try to read from Java with the connection established on DB2 is unable to interpret the information. While there are no problems from Oracle to consume the information, it happens that DB2 field types are not common with Oracle, such as char () for bit data. From what I could find the equivalent in Oracle would be raw (), but since Java is possible to read this type of information... And this is my doubt, it is necessary to do any type of cast or to do a special view to retrieve this information?

  • Mapping SQL data types (especially SMALLINT) to Java classes

    I want to know the reason for a certain pair of exceptions in JDBC�s mapping of SQL data types to Java classes.
    Sun�s web site ( http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/getstart/mapping.html ), Sybase�s site, and other sites contain mappings from SQL data types to Java primitive data types and/or Java classes. On that Sun web page, Section 9.9.1 maps mostly to Java primitive data types, and Section 9.9.3 maps mostly to Java classes. For the SQL data types that map to both primitive data types and classes, the class is typically the wrapper class of the primitive data type. For example, SQL�s DOUBLE data type maps to both the double primitive data type and its wrapper class (Double). However, Section 9.7 of that Sun web page says that there are exceptions for SQL�s TINYINT and SMALLINT. As expected, they map to the byte and short primitive data types, but they map to the Integer class, not the Byte and Short classes (which are the wrapper classes for byte and short). The web page does not state the reason for this pair of exceptions. It seems to me that SMALLINT data would either work for both short and Short or fail for both short and Short. I don�t see why it would work for short but fail for Short (as the web page implies).
    Can anybody think of a reason for the pair of exceptions? Thanks.

    ghs wrote:
    1) If a DBMS deals with the short and byte primitive data types (as the various web pages imply that it does), then why would it not deal with the Short and Byte wrapper classes?As another guess, because conversions get a little weird in java. Or at least they did in the past. As I recall (with not a lot of clarity) it is possible to do something like pass a perfectly valid string value into a short and get an exception. Whereas using Integer and then converting to Short works.
    Keep in mind that these are guesses.
    3) What I really want to know is this: If I use wrapper classes of Short and Byte (instead of Integer), what will be the harmful consequences (IF ANY)? So far, I have done some trivial testing with a Short for a SMALLINT column (I have not yet tried any TINYINT columns), and it seems to be working.I considered it risky to not test all target databases and drivers.
    Obviously testing will reveal problems.
    If you don't want to test then you might want to stick with integers.

  • Java Data Types?

    Hi,
    shall we say
    The data types in Java 1.5 can be divided into 4 categories. They are:
    i.     Primitive Data Types
    ii.     Abstract Data Types
    iii.     Arrays
    iv.     Enumerated Data Types
    ...............?

    Raijinsetsu wrote:
    I have to agree with jverd...
    Abstract is not a data type. Abstract declares a specific type of class which cannot be instantiated. Enumerations are just specialized objects. Arrays are also specialized objects.One could choose to consider arrays, enums, and abstract classes as separate categories.
    >
    If you wanted, the full list would be:
    Object (reference is another term you could apply to objects)
    int
    long
    short
    byte
    charEven if you include the primitives you forgot, this list is just as arbitrary as the original one, and does not correspond to the JLS.
    In particular, Object is not a type. There are primitives, references, and the null type.
    Edited by: jverd on May 6, 2009 7:56 AM

Maybe you are looking for