Class SoMFString

  • Direct Known Subclasses:
    SoMFFilePathString

    public class SoMFString
    extends SoMField
    Multiple-value field containing any number of strings. A multiple-value field that contains any number of strings.

    SoMFStrings are written to file as one or more strings within double quotes. Any characters (including newlines) may appear within the quotes. To include a double quote character within the string, precede it with a backslash. For example:

       [ cowEnizer , "Scene Boy" , "He said, \"I did not!\"" ]

    Unicode Support

    Unicode is an industry standard for encoding text of all forms and languages for use by computers. Open Inventor supports Unicode encoding, which allows internationalization of text in a standard cross-platform fashion.

    String and as well as classes like SoSFString support the wchar_t type which is used for Unicode strings, and all of the text nodes are able to render Unicode strings.

    String includes methods for construction of Unicode strings, string operators (=, += ,== ,!=, <, >, <=, >=), as well as a query method (String.isUnicode()).

    To be able to display a particular Unicode character, the selected font must have a character for that Unicode value. Many fonts do not contain a complete set of Unicode characters. However, the shareware Unicode font file "Code2000" seems to work well.

    Note that Unicode characters are not directly supported in Open Inventor files. Unicode strings are written as if the bytes in the string were a string of 8-bit characters. The string will be prefixed by "MCS_U_".

    Data copying:

    SoMF fields are a kind of "smart container", automatically expanding as necessary to hold the data provided by the application. This is very convenient, but for large blocks of data it may be desireable to avoid making a copy of the application data. The setValuesBuffer() methods allow Open Inventor to directly use an array of values supplied by the application. The application data is not copied. Please see SoMFVec3f for more information and example code.

    • Method Detail

      • find

        public int find​(java.lang.String targetValue)
        Calls find(targetValue, false).
      • setValue

        public void setValue​(java.lang.String newValue)
        Sets the first value in the array to newValue, and deletes. the second and subsequent values. If field's values are stored in an user data array, this array is no more used.
      • getValueAt

        public java.lang.String getValueAt​(int i)
      • disableDeleteValues

        public void disableDeleteValues()
        Temporary disable value deleting.
      • setValues

        public void setValues​(int start,
                              java.lang.String[] newValues)
        Sets num values starting at index start to the values. in newValues. The array will automatically be made larger to accommodate the new values, if necessary. In that case, if field's values are stored in an user data array, this array is no more used.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class SoField
      • set1Value

        public void set1Value​(int index,
                              java.lang.String newValue)
        Sets the index'th value in the array to newValue. The array will be automatically expanded, if necessary. In that case, if field's values are stored in an user data array, this array is no more used.
      • deleteText

        public void deleteText​(int fromLine,
                               int fromChar,
                               int toLine,
                               int toChar)
        Convenience function to delete text from consecutive strings. All text from the given character of one line (fromChar in fromLine) to the given character of another line (toChar in toLine), inclusive, is deleted. Any leftover text on fromLine and toLine is merged into one line.
      • find

        public int find​(java.lang.String targetValue,
                        boolean addIfNotFound)
        Finds the given targetValue in the array and returns the index of that value. in the array. If the value is not found, -1 is returned. If addIfNotFound is set, then targetValue is added to the end of the array (but -1 is still returned).