The String class depracated?

I am porting our application to Solaris 10, Oracle 11, yada, yeda.
Anyway, our long written code used the GNU C++ Class Library - the String class. It appears that the String class does not exist in the latest distribution (4.2).
Can anyone verify if that is true or if I am mistaken?
If this is true, I will have to implement the functionality I need in the class that we have built on top of the Sting class.
Some of the functionality of that class I need fcompare, before, after, gsub and freq.
Thanks

Upon further research, it is the String class from libg++ that is no longer included.
I am currently trying to compile the older version of this library, but having many issues using the newer compilers.

Similar Messages

  • EXTENDING the string class

    ok, i know extending the string class is illegal because it's final, but i want to make an advanced string class that basically "extends" the string class and i've seen online this can be done through wrapper classes and/or composition, but i'm lost
    here is my sample code that is coming up with numerous compile time errors due to the fact that when i declare a new AdvString object, it doesn't inherit the basic string features (note: Add is a method that can add a character to a specified location in a string)
    class AdvString
         private String s;
         public AdvString(String s)
              this.s = s;
         public void Add(int pos, char ch)
              int this_len = (this.length()) + 1;
              int i;
              for(i=0;i<(this_len);i++)
                   if(pos == i)
                        this = this + ch;
                   else if(pos < i)
                        this = this + this.charAt(i-1);
                   else
                        this = this + this.charAt(i);
         public static void main(String[] args)
              AdvString s1;
              s1 = new AdvString("hello");
              char c = 'x';
              int i = 3;
              s1.Add(i,c);
              //s2 = Add(s1,i,c);
              //String s2_reversed = Reverse(s2);     
              System.out.println("s1 is: " + s1);
    any tips?

    see REString at,
    http://www.geocities.com/rmlchan/mt.html
    you will have to replicate all the String methods you are interested in, and just forward it to the String instance stored in REString or the like. it is like a conduit class and just passes most processing to the 'real' string. maybe a facade pattern.

  • How to implement the String class "split()" method (JDK1.4) in JDK 1.3

    is it possible , with some code, to implement the split() method of the String class......which is added in JDK1.4 ..... in JDK1.3
    would be helpful if anyone could suggest some code for this...

    Here it is
    public static String[] split(String source, char separ){
    answer=new Vector();
    int position=-1, newPosition;
    while ((newPosition=source.indexOf(separ,position+1))>=0){
    answer.add(source.subString(position+1,newPosition));
    position=newPosition;
    } //while
    answer.add(source.subString(position+1,source.length-1);
    return (String[])(answer.toArray());
    } //split

  • What does the trim() method of the String class do in special cases?

    Looking here ( String (Java Platform SE 7 ) ), I understand that the trim() method of the String class "returns a copy of the string, with leading and trailing whitespace omitted", but I don't understand what the last special case involving Unicode characters is exactly.
    Looking here ( List of Unicode characters - Wikipedia, the free encyclopedia ), I see that U+0020 is a space character, and I also see the characters that follow the space character (such as the exclamation mark character).
    So, I decided to write a small code sample to try and replicate the behaviour that I quoted (from the API documentation of the trim method) in the multi-line comment of this same code sample. Here is the code sample.:
    public class TrimTester {
        public static void main(String[] args) {
             * "Otherwise, let k be the index of the first character in the string whose code
             * is greater than '\u0020', and let m be the index of the last character in the
             * string whose code is greater than '\u0020'. A new String object is created,
             * representing the substring of this string that begins with the character at
             * index k and ends with the character at index m-that is, the result of
             * this.substring(k, m+1)."
            String str = "aa!Hello$bb";
            System.out.println(str.trim());
    However, what is printed is "aa!Hello$bb" (without the quotes) instead of "!Hello$" (without the quotes).
    Any input to help me better understand what is going on would be greatly appreciated!

    That's not what I was thinking; I was thinking about the special case where the are characters in the String whose Unicode codes are greater than \u0020.
    In other words, I was trying to trigger what the following quote talks about.:
    Otherwise, let k be the index of the first character in the string whose code is greater than '\u0020', and let m be the index of the last character in the string whose code is greater than '\u0020'. A new String object is created, representing the substring of this string that begins with the character at index k and ends with the character at index m-that is, the result of this.substring(k, m+1).
    Basically, shouldn't the String returned be the String that is returned by the String class' substring(3,9+1) method (because the '!' and '$' characters have a Unicode code greater than \u0020)?
    It seems to not be the case, but why?

  • Question about the String class

    Did I understood the JLS/Javadoc properly if I say that the String class has got an internal pool of String objects (therefore I expect this pool to be stored in some sort of static variable)?
    Looking at the intern() method in the String class, this is declared as native, which make me think the whole pooling thing is managed internally by the JVM.
    Does this mean that, if there is only a String class per JVM and String literals (or better Strings that are values of constant expressions) are pooled in the String class, the more String constants are around the bigger the String class object becomes?

    Did I understood the JLS/Javadoc properly if I say
    that the String class has got an internal pool of
    String objects (therefore I expect this pool to be
    stored in some sort of static variable)?Yes.
    Looking at the intern() method in the String class,
    this is declared as native, which make me think the
    whole pooling thing is managed internally by the JVM.The intern() method is implemented in some programming language. If you happen to have a Java runtime where it is written as a native method, it is probably implemented in C or C++. Not a terribly important detail.
    Does this mean that, if there is only a String class
    per JVM and String literals (or better Strings that
    are values of constant expressions) are pooled in the
    String class, the more String constants are around
    the bigger the String class object becomes?The String.class object (of type java.lang.Class) as such doesn't "grow", but some memory structure somewhere will contain interned String literals. Probably a hash table of some sort. Yes indeed: if you have String literals in your program, those literals are stored in the computer's memory during runtime so that they can be accessed by the executable program code.

  • Extend the String Class

    Is there a way to extend the string class? I know it's final, if i make my class final too would that work? I want to add some functionality to the string class, but I wanna be able to do concatination with the + operator and stuff like that. That's special to the String class.
    Any help would be great.
    Thanks.
    Joe

    Well, put your mind at easy with the fact that being
    able to use the '+' operator on Strings is a design
    flaw in Java. At least from a purist point of view...And from a pragmatist's point of view, it's a reasonable compromise, the benefit of which outweighs the downside. This is consistent with Java's goal as a good general-purpose language. It's not intended to be pure OO or pure anything else.

  • How does the String class achieve this.

    How come we can do the following with the String class:
    // The class is initialized using the equals sign!
    String s = "Hello, World"";I am currently checking the string class but can not find what makes the above possible. could anyone help me?

    ok sorry for not being so clear :)
    When having a String class, we can initialize it by doing the following:
    String myString = "Hello World"; Whis as JosAH explained it is handeled by the compiler. However my common sense tells me that the String class is nothing but a normal class (not like int, long, etc). So if it a normal class, then in that class there is a way to understand what = "somthing" means, and update it's state accordingly.
    I would like to do the same think with my class. example:
    Person MyPerson = "John, Smith";The above is a stupid example, however it gathers my point. The String class sess what is inside the quates and updates it state (with the help of the compiler). Can the Person class do the same? how?

  • How to find out what are the functions supported by string class

    Hi,
    Can any one let me know how to find what are all the functions supported by the string class in standard(STL) library on solaris.
    Regards,
    Vignesh

    1. Any C++ textbook that covers the Standard Library will tell you about the standard string class. A good tutorial and reference for the entire Standard Library is "The C++ Standard Library" by Nicolai Josuttis, published by Addison Wesley.
    2. WIth Sun C++, the command
    man -s3C++ basic_string
    provides documentation for the default libCstd version of the Standard Library.
    3. You could look at the <string> header itself. I don't recommend that approach.

  • Did the Java Writers Get a Little Happy with Memory Use in String class?

    I mean that question half jokingly.
    Taking a look at the String class code, I saw the following (below).
    Why is there an int for offset and an int for count?
    String is immutable, why not just return value.length for the count?
    And what is the offset for?
    Thanks!
    public final class String
        implements java.io.Serializable, Comparable<String>, CharSequence
        /** The value is used for character storage. */
        private final char value[];
        /** The offset is the first index of the storage that is used. */
        private final int offset;
        /** The count is the number of characters in the String. */
        private final int count;
        /** Cache the hash code for the string */
        private int hash; // Default to 0PS: a second look kinda verifies it too.
    in the constructor ,count is even defined as value.length.
        public String(char value[]) {
         int size = value.length;
         this.offset = 0;
         this.count = size;
         this.value = Arrays.copyOf(value, size);
        }

    You don't get the choice. The arrays are shared
    whenever you do substring.Yea, thats my point. I think most Strings are unique.
    Id be very surprised if even 2% of all String use was
    a result of a substring.The wrapper classes use it for parsing.
    File uses it for getName and getParent.
    String uses it for trim.
    Class uses it for resolving names.
    Regex uses it.
    etc. ...
    Now, I don't know what percentage of usage all that amounts to, but it IS heavily used.
    So your desire to gain the 2 bytes back would cost enough byte every time substring is used that it might end up costing far more than the 8 bytes you save.

  • Is the instance fields have private accessibility in String class?

    Is the instance fields have private accessibility in an immutable class, such as the String class?
    also Could any one answer the following question,
    (This is the question I got in written exam for job recruitment)
    "Invoking a method can represent a significant amount of overhead in a program; as such, some compilers will perform an optimization called "method inlining." This optimization will remove a method call by copying the code inside the method into the calling method."
    Referring to the text above, which one of these statements is true?
    Choice 1 The performance benefits should be balanced against the increased chance of a RuntimeException.
    Choice 2 It allows the use of getter and setter methods to execute nearly as fast as direct access to member variables.
    Choice 3 This optimization will only occur if the relevant methods are declared volatile.
    Choice 4 The developer of inlined methods must copy and paste the code that is to be inlined into another method.
    Choice 5 It prevents code from executing in a way that follows object-oriented encapsulation.

    Sarwan_Gres wrote:
    Is the instance fields have private accessibility in an immutable class, such as the String class?Usually, but not always.
    "Invoking a method can represent a significant amount of overhead in a program; as such, some compilers will perform an optimization called "method inlining." This optimization will remove a method call by copying the code inside the method into the calling method."The java compiler does not inline methods so this is not relevant to Java. (The JVM does inline methods) The java compiler does inline constants known at compile time but it is a feature causes more trouble than good IMHO.

  • Memory leak in string class

    We have developed our application in Solaris 10 environment. While running Purify on that it shows leak in the string class. This leak is incremental and so process size keeps in increasing. If we replace string with char array, the leaks disappears and process size also becomes stable.
    Following is the snapshot of the memory leak stack reported by Purify:
    MLK: 4505 bytes leaked in 85 blocks
    * This memory was allocated from:
    malloc [rtlib.o]
    operator new(unsigned) [libCrun.so.1]
    void*operator new(unsigned) [rtlib.o]
    __rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >*std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__getRep(unsigned,unsigned) [libCstd.so.1]
    char*std::basic_string<char,std::char_traits<char>,std::allocator<char> >::replace(unsigned,unsigned,const char*,unsigned,unsigned,unsigned) [libCstd.so.1]
    std::basic_string<char,std::char_traits<char>,std::allocator<char> >&std::basic_string<char,std::char_traits<char>,std::allocator<char> >::operator=(const char*) [libCstd.so.1]
    Has anyone faced this problem earlier or is there any patch available for this?

    Over time, we have found and fixed memory leaks in the C++ runtime libraries.
    Get the latest patches for the compiler you are using. (You didn't say which one.) You can find all patches here:
    [http://developers.sun.com/sunstudio/downloads/patches/index.jsp]
    Also get the latest Solaris patch for the C++ runtime libraries, listed on the same web page.
    If that doesn't fix the problem, please file a bug report at
    [http://bugs.sun.com]
    with a test case that can be compiled and run to demonstrate the problem.

  • How to avoid string copy when spliting the string?

    Hi all,
    I have some old APIs (which I do not have control over) that expects the caller to pass the "content" of a text file as either String or String[] (each element is a line in the text file). Since the text file can be huge, I want to save memory and try to only hold 1 copy of the file content in memory. So, the question boils down to how can I make a String variable and a String[] variable share one single piece of memory.
    After digging into the source code, I notice the String.substring(...) always makes allocate a new memory space for the returning string if the result substring is smaller than 1/4 of the actual String. The String.split() method internally also invokes the String.substring(...) method.
    This creates a problem for me. If I first load the content of a file into a String "a". Then I call "String[] array = a.split("\n")", as the result, each element in the resulting array will be a copy of the substring of the original String "a" (since each line in my text file will be smaller than 1/4 of the entire file). StringTokenizer seems to have the same problem. Is there anything else I could do?
    I really would like to extends the String class and override the substring method to make it always "share" the same memory content. But since String class is declared as final, I cannot do this. I think maybe the String.split() method implementation should make the return String[] from the split function share the same memory space as the original string. Any workaround anyone can suggest?
    Thanks
    -- Gary

    While you could try to create some sort of custom class, if you want something that is already in java, you need to use one of the instantiations of CharSequence
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/CharSequence.html
    Personally, I would recommend CharBuffer. From the look of it, it seems most like what you want.
    Hi all,
    I have some old APIs (which I do not have control
    rol over) that expects the caller to pass the
    "content" of a text file as either String or String[]
    (each element is a line in the text file). Since the
    text file can be huge, I want to save memory and try
    to only hold 1 copy of the file content in memory.
    So, the question boils down to how can I make a
    a String variable and a String[] variable share one
    single piece of memory.
    After digging into the source code, I notice the
    the String.substring(...) always makes allocate a new
    memory space for the returning string if the result
    substring is smaller than 1/4 of the actual String.
    The String.split() method internally also invokes
    s the String.substring(...) method.
    This creates a problem for me. If I first load
    oad the content of a file into a String "a". Then I
    call "String[] array = a.split("\n")", as the result,
    each element in the resulting array will be a copy of
    the substring of the original String "a" (since each
    line in my text file will be smaller than 1/4 of the
    entire file). StringTokenizer seems to have the same
    problem. Is there anything else I could do?
    I really would like to extends the String class and
    nd override the substring method to make it always
    "share" the same memory content. But since String
    class is declared as final, I cannot do this. I
    think maybe the String.split() method implementation
    should make the return String[] from the split
    function share the same memory space as the original
    string. Any workaround anyone can suggest?
    Thanks
    -- Gary

  • What does the SomeClassIdentifier.class keyword do?

    I see this often.
    SomeClassIdentifier.class == SomeClassIdentifier.getClass() ?

    I see this often.
    SomeClassIdentifier.class == SomeClassIdentifier.getClass() ?Not quite; the getClass() method is a non-static method inherited from the Object class.
    It returns a Class object representing the runtime class of the object for which the method was
    invoked. The funny .class notation is a class literal, it also evaluates to a Class object, but
    this object will represent the type that was mentioned on the left of the dot. e.g. -- Object a= new String("foo");
    String  b= new String("bar"); both a.getClass() and b.getClass() will return a Class object for the String class.
    String.class will evaluate to that same object, but Object.class wouldn't of course ...
    You can even create class literals for primitive types or arrays of even for void.
    kind regars,
    Jos

  • Stop escaped characters from resolving within String class.

    Hello,
    Is it possible to stop escaped characters from resolving within the String class?
    For example, I define a character array,
    char[] c = {'0','\\','n'}
    and I want to create a String based on this exact sequence (0\n). However, when I call the String constructor String(char[]), it resolves the \n sequence into the newline character, creating a String of length 2 not 3.
    I'm not very familiar with the innards of the Java compiler (does "xyz" translate to char[]{'x','y','z'}?), so maybe this is something very basic.
    Does anyone know if there is a flag that can be set somehow before I create a String instance (it appears that no String constructor supports this kind flag)?
    Or perhaps is there a method in the standard Java release that escapes all escape characters in a character array...? I'm curious if there is a simpler way (like a flag), because the method approach seems superfluous.
    Thanks,
    Brien

    What do you mean?char[] c = {'0', '\\', 'n'};
    String s = new String(c);
    System.out.println(s);does give the string 0\n...
    And by the way, it's not the String class that transforms \n to the linefeed character, it is the compiler..

  • To change the string in Class Builder "New Method"

    HI friends,
    Im using the std program of "RFDOPR10"...(changed into my customised program as ZRFDOPR10).....
    Here i want to change the strings of Id_type eq 4 availble under the class builder "New Method".
    "id_ruler_string = '2.13.24.29|43|58|73|88|103|118|'" (for 24...i want to give 38.....then 45...)
    Pls help me how to change the std method function  for my z program...
    FYR:
    RFDOPR10 is the std program for tcode :"s_alr_87012178", Customer analysis.If u want to c the example report, in this tcode...give OI:1, Summ level:6, OI list:1 and Company CD:2 under Output control tab in selection screen with Company code.Now, u able to see the reports in the screen.There, after Customer number....I've to give some more spaces(length) for Sort field.
    Thanks & regards
    Sankar.

    No, but I suggest using a different editor which does allow a different text option and just pasting it in.

Maybe you are looking for

  • Problem openning + setting up Flash cs3 trial

    I get an error when i open ADBEFLPRCS3_WWE.EXE (Flash cs3 ) this is the picture: My Error i get when i open the Flash cs3 setup, please click image to get a better view. And please zoom in to the picture to see the error ( just click the image) It co

  • How do I deactivate a (lost) copy of Acrobat XI professional

    I am advised to contact Adobe but am unable to do so. Please let me have a contact number for Adobe in the UK  so I can get this reinstalled copy working

  • 2005 database and log file locations

    Is there a SQL query to list where exactly the database and log files reside for all databases on an instance (sql server 2005)?

  • HT1222 My software don't updates why?!

    My software doesn't update i try different time and he doesn't update why?! 

  • Photoshop CS6 Internal Font Missing!

    Help,  I was using Extensis Suitcase Fusion 4 trial, and it ended, but when it did now because I can't use it, somehow it must have removed or just had de-activated the photoshop internal system font.    All of my panels and menus etc except for the