X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fmisc%2FStringUtil.java;h=7f08337f4657cf221c609b9cca05231616b47c57;hb=ed9932a980050bd1a8c3ffda8d8dff36ead479cc;hp=57139c7ba5be0ff78f04f66f8c927e7f94324d48;hpb=664ecfbf6fee4e39efe7092e52c3d52dade0d3f8;p=mir.git diff --git a/source/mir/misc/StringUtil.java b/source/mir/misc/StringUtil.java index 57139c7b..7f08337f 100755 --- a/source/mir/misc/StringUtil.java +++ b/source/mir/misc/StringUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001, 2002 The Mir-coders group + * Copyright (C) 2005 The Mir-coders group * * This file is part of Mir. * @@ -18,60 +18,39 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. + * the code of this program with any library licensed under the Apache Software License. + * You must obey the GNU General Public License in all respects for all of the code used + * other than the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. + * If you do not wish to do so, delete this exception statement from your version. */ - package mir.misc; -import java.io.*; -import java.lang.*; -import java.util.*; -import java.text.NumberFormat; -import gnu.regexp.*; +import org.apache.oro.text.regex.Pattern; +import org.apache.oro.text.regex.Perl5Matcher; +import org.apache.oro.text.regex.Perl5Substitution; +import org.apache.oro.text.regex.Util; +import org.apache.oro.text.regex.Perl5Compiler; + +import java.text.NumberFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; /** - * Statische Hilfsmethoden zur Stringbehandlung - * - * @version $Id: StringUtil.java,v 1.31 2002/12/23 03:15:32 mh Exp $ - * @author mir-coders group - * */ public final class StringUtil { - private static RE re_newline2br, re_brbr2p, re_mail, re_url, re_tags, - re_tables, re_forbiddenTags; + private static TimeZone UTC = TimeZone.getTimeZone("UTC"); private StringUtil() { } // this avoids contruction - static { - try { - //precompile regex - re_newline2br = new RE("(\r?\n){1}"); - re_brbr2p = new RE("(
\r?\n
){1,}"); - re_mail = new RE("([a-zA-Z0-9_.-]+)@([a-zA-Z0-9_-]+)\\.([a-zA-Z0-9_.-]+)"); - re_url = new RE("((https://)|(http://)|(ftp://)){1}([a-zA-Z0-9_-]+).([a-zA-Z0-9_.:-]+)/?([^ \t\r\n<>\\)\\]]+[^ \t\r\n.,<>\\)\\]])"); - re_tags = new RE("<[^>]*>",RE.REG_ICASE); - re_tables = new RE("<[ \t\r\n/]*(table|td|tr)[ \t\r\n]*>",RE.REG_ICASE); - re_forbiddenTags = new RE("<[ \t\r\n/]*(body|head|script)[ \t\r\n]*>",RE.REG_ICASE); - } - catch (REException e){ - System.err.println("FATAL: StringUtil: could not precompile REGEX: "+e.toString()); - } - } - /** * Formats a number with the specified minimum and maximum number of digits. **/ public static synchronized String zeroPaddingNumber(long value, int minDigits, - int maxDigits) + int maxDigits) { NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumIntegerDigits(minDigits); @@ -85,27 +64,12 @@ public final class StringUtil { * @return 8-ziffriger String (yyyymmdd) */ - public static final String date2webdbDate (GregorianCalendar theDate) { + public static String date2webdbDate (GregorianCalendar theDate) { StringBuffer webdbDate = new StringBuffer(); webdbDate.append(String.valueOf(theDate.get(Calendar.YEAR))); webdbDate.append(pad2(theDate.get(Calendar.MONTH) + 1)); webdbDate.append(pad2(theDate.get(Calendar.DATE))); - return webdbDate.toString(); - } - /** - * Wandelt Calendar in einen 12-ziffrigen String um (yyyymmddhhmm) - * @param theDate - * @return 12-ziffriger String (yyyymmdd) - */ - - public static final String date2webdbDateTime (GregorianCalendar theDate) { - StringBuffer webdbDate = new StringBuffer(); - webdbDate.append(String.valueOf(theDate.get(Calendar.YEAR))); - webdbDate.append(pad2(theDate.get(Calendar.MONTH) + 1)); - webdbDate.append(pad2(theDate.get(Calendar.DATE))); - webdbDate.append(pad2(theDate.get(Calendar.HOUR))); - webdbDate.append(pad2(theDate.get(Calendar.MINUTE))); return webdbDate.toString(); } @@ -115,7 +79,7 @@ public final class StringUtil { * @return w3approved datetime */ - public static final String date2w3DateTime (GregorianCalendar theDate) { + public static String date2w3DateTime (GregorianCalendar theDate) { StringBuffer webdbDate = new StringBuffer(); webdbDate.append(String.valueOf(theDate.get(Calendar.YEAR))); webdbDate.append("-"); @@ -123,7 +87,7 @@ public final class StringUtil { webdbDate.append("-"); webdbDate.append(pad2(theDate.get(Calendar.DATE))); webdbDate.append("T"); - webdbDate.append(pad2(theDate.get(Calendar.HOUR))); + webdbDate.append(pad2(theDate.get(Calendar.HOUR_OF_DAY))); webdbDate.append(":"); webdbDate.append(pad2(theDate.get(Calendar.MINUTE))); webdbDate.append(":"); @@ -161,29 +125,13 @@ public final class StringUtil { } /** - * deleteForbiddenTags - * this method deletes all