2222 * SAS</a>
2323 *
2424 */
25+ /**
26+ * @author demau
27+ *
28+ */
2529public class SplitString {
2630 private ArrayList <String > stringsplit ;
2731 private ArrayList <Boolean > transitions ;
32+ private ArrayList <Boolean > hasbullet ;
2833
2934 /**
3035 * @return the number of sections of this string
@@ -53,19 +58,31 @@ public boolean getTransitionAt(int index) {
5358 return transitions .get (index ).booleanValue ();
5459 }
5560
61+ /**
62+ * provides information if the current section is a bullet
63+ *
64+ * @param index index of the section
65+ * @return true if the section is a bullet, false else
66+ * @since 1.12
67+ */
68+ public boolean getBulletAt (int index ) {
69+ return hasbullet .get (index ).booleanValue ();
70+ }
71+
5672 /**
5773 * create a Split chain, parsing the string for new lines only (\n or \r\n)
58- * (carriage returns are kept in sections), or for all
74+ * (carriage returns are kept in sections), or for all. Also manages bullet
75+ * points in the text
5976 *
6077 * @param chaintosplit the string to split
6178 * @param onlymajor if true, only new lines are considered, if false, new
6279 * lines and carriage returns are considered
63- * @since 1.5
80+ * @since 1.5
6481 */
6582 public SplitString (String chaintosplit , boolean onlymajor ) {
6683 stringsplit = new ArrayList <String >();
6784 transitions = new ArrayList <Boolean >();
68-
85+ hasbullet = new ArrayList < Boolean >();
6986 boolean lastsplitismajor = true ;
7087 StringBuffer currentstring = new StringBuffer ();
7188 int parseindex = 0 ;
@@ -78,18 +95,20 @@ public SplitString(String chaintosplit, boolean onlymajor) {
7895 }
7996 if (currentchar == 10 ) { // \n
8097 specialcharacter = true ;
81-
98+
8299 if (lastisbackslashr ) {
83100 // treats \r\n as a maj carriage return ()
84101 stringsplit .add (currentstring .toString ());
102+ hasbullet .add (hasBullet (currentstring .toString ()));
85103 transitions .add (new Boolean (lastsplitismajor ));
86104 lastsplitismajor = true ;
87105 currentstring = new StringBuffer ();
88-
106+
89107 } else {
90108 // treats \n as minor carriage return (print as \n)
91109 if (!onlymajor ) {
92110 stringsplit .add (currentstring .toString ());
111+ hasbullet .add (hasBullet (currentstring .toString ()));
93112 transitions .add (new Boolean (lastsplitismajor ));
94113 lastsplitismajor = false ;
95114 currentstring = new StringBuffer ();
@@ -104,22 +123,38 @@ public SplitString(String chaintosplit, boolean onlymajor) {
104123 // treats \r\n as a maj carriage return ()
105124 specialcharacter = true ;
106125 stringsplit .add (currentstring .toString ());
126+ hasbullet .add (hasBullet (currentstring .toString ()));
107127 transitions .add (new Boolean (lastsplitismajor ));
108128 lastsplitismajor = true ;
109129 lastisbackslashr = false ;
110130 currentstring = new StringBuffer ();
111-
112-
113- }
131+
132+ }
114133 currentstring .append ((char ) currentchar );
115-
134+
116135 }
117136 if (currentchar == 13 )
118137 lastisbackslashr = true ;
119138 parseindex ++;
120139 }
121140 stringsplit .add (currentstring .toString ());
122141 transitions .add (new Boolean (lastsplitismajor ));
142+ hasbullet .add (hasBullet (currentstring .toString ()));
143+ }
144+
145+ /**
146+ *
147+ * @param string a String
148+ * @return true if a bullet is detected, false else
149+ * @since 1.12
150+ */
151+ public static boolean hasBullet (String string ) {
152+
153+ if (string .indexOf ('\u25CF' ) >= 0 )
154+ return true ;
155+ if (string .indexOf ('\u2022' ) >= 0 )
156+ return true ;
157+ return false ;
123158 }
124159
125160 /**
0 commit comments