Package org.brerp.base.util
Class TextUtil
java.lang.Object
org.brerp.base.util.TextUtil
TextUtil
Text Utils
- Version:
- $Id: TextUtil.java, 20/11/2007 10:45:02 mgrigioni
- Author:
- Mario Grigioni (Kenos, www.kenos.com.br)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddEOL(FileWriter fw) addEOL End of Linestatic voidaddText(FileWriter fw, String text) addLine Add linestatic voidaddText(FileWriter fw, String text, boolean quoteValue) addLine Add linestatic voidaddLinestatic StringbigdecimalFormat(BigDecimal value) Transforma BigDecimal em String seguindo o padrão #.##0,00static StringbigdecimalToString(BigDecimal value) getValorstatic StringbigdecimalToString(BigDecimal value, int scale) bigdecimalToStringstatic StringbyteArrayToHexString(byte[] b) From: http://stackoverflow.com/questions/4895523/java-string-to-sha1static StringcheckOrderBy(String orderBy) static Stringstatic StringVerifica se a string está entre os valores minímos e máximostatic StringVerifica se a string está entre os valores minímos e máximostatic StringcheckSizeN(String value, int min, int max) Verifica se a string está entre os valores minímos e máximostatic StringcheckSizeN(String value, int min, int max, boolean mandatory) Verifica se a string está entre os valores minímos e máximostatic StringcheckWhereClause(String whereClause) static voidcloseFile(FileWriter fw) closeFile Close a text filestatic voidcloseFile Close a textfilestatic StringconvertStringToHex(String arg) Convert String to Hexstatic intcountMatches(char caracter, String str) Conta a quantidade de vezes que um caracter se repete em uma string countMatchesstatic WritercreateFile(File file, boolean append, String encoding) createFile with a encoding typestatic FileWritercreateFile(String fileName, boolean append) createFile (DEFAULT ENCODING UTF-8) Create a text filestatic FileWritercreateFile(String fileName, boolean append, String encoding) createFile Create a text filestatic voiddeleteFile(File fp) deleteFilestatic voiddeleteFile(String fileName) deleteFile Delete Filestatic StringformatTimeString(String time) Formata e Valida String HH:MM para HH:MM:SSstatic StringgenerateFile(String data, String filePath) generateFile (DEFAULT ENCODING UTF-8) Create and write String to Filestatic StringgenerateFile(String data, String filePath, String encoding) Gera um arquivostatic byte[]generateSHA1(String string) Generate SHA1 to param string From: http://stackoverflow.com/questions/4895523/java-string-to-sha1static StringgenerateTmpFile(String data, String fileName) generateTmpFile Create and write String to File at java.io.tmpdirstatic StringgetZoomTag(PO registro, String texto) Este método retorna um link HTML para realizar zoom em registros.static StringgetZoomTag(PO registro, String AD_Window_UU, String texto) Este método retorna um link HTML para realizar zoom em registros.static booleanVerifica se uma String contém exclusivamente dígitosstatic StringiTrimstatic Stringstatic Stringstatic StringLeft Padstatic StringLeft Pad with 0static StringlPad(BigDecimal valueBD, int length) Left Pad with 0 (Scale 2 Default)static StringlPad(BigDecimal valueBD, int length, int scale) Left Pad with 0static booleanVerifica se lista contém uma determinada string.static Stringpad(int value, char filler, int length, boolean lpad) static Stringstatic Stringpadstatic StringRead File, default encoding is UTF-8static StringRead Filestatic String[]readFile Reads a file and return the lines into a string arraystatic String[]readFile Reads a file and return the lines into a string arraystatic StringremoveEOLstatic Stringstatic StringretiraEspecial(String value) Retorna somente os digitos de 0..9
e as letras de a..z e A..Z, desconsiderando
qualquer outro caracter.
Por Exemplo:
UmaString"123ABC##&&%%999"
é automaticamente passada para "123ABC999".static StringretiraPontoFinal(String value) retiraPontoFinal Remove Periodstatic StringRight Padstatic StringRight Pad with blank space ' 'static BigDecimalstringTobigdecimal(String value) static TimestampstringToTime(String data, String dateFormat) StringToDate Convert String to Timestampstatic StringRetorna a data formatada em AnoMesDia yyyymmddstatic StringtimeToString(Timestamp ts, String format) Retorna a data formatada de acordo com o formato
Dia: dd, Mes: mm, Ano: yyyystatic StringtimeToString(Timestamp ts, String format, boolean mandatory) Retorna a data formatada de acordo com o formato
Dia: dd, Mes: mm, Ano: yyyystatic StringtimeToString(Date value, String format) Retorna a data formatadastatic Stringstatic StringRetorna sempre somente os digitos
de 0..9 de um String desconsiderando
qualquer outro caracter.
Por Exemplo:
UmaString"14.568-910"
é automaticamente passada para "14568910".static StringtoNumeric(BigDecimal value) Retorna sempre somente os digitos
de 0..9 de um BigDecimal com 2 casas.
Por Exemplo:
UmBigDecimal"14568.910"
é automaticamente passada para "14568,910".static StringtoNumeric(BigDecimal value, int scale) Retorna sempre somente os digitos
de 0..9 de um BigDecimal com 2 casas.
Por Exemplo:
UmBigDecimal"14568.910"
é automaticamente passada para "14568,910".static StringtoNumeric(BigDecimal value, int min, int max) Retorna sempre somente os digitos
de 0..9 de um BigDecimal com 2 casas.
Por Exemplo:
UmBigDecimal"14568.910"
é automaticamente passada para "14568,910".static StringtoNumeric(BigDecimal value, int min, int max, boolean mandatory) Retorna sempre somente os digitos
de 0..9 de um BigDecimal com 2 casas.
Por Exemplo:
UmBigDecimal"14568.910"
é automaticamente passada para "14568,910".static StringtoNumeric(BigDecimal value, int min, int max, int scale) Retorna sempre somente os digitos
de 0..9 de um BigDecimal com 2 casas.
Por Exemplo:
UmBigDecimal"14568.910"
é automaticamente passada para "14568,910".static final StringunescapeHtml3(String input)
-
Field Details
-
EOL_WIN32
EOL- See Also:
-
EOL_LINUX
- See Also:
-
EOL_MAC
- See Also:
-
UTF8
ENCODING- See Also:
-
ISO88591
- See Also:
-
PIPE
PIPE- See Also:
-
ZERO_STRING
Round -
ALFAB
Alfabeto
-
-
Constructor Details
-
TextUtil
public TextUtil()
-
-
Method Details
-
readFile
Read File, default encoding is UTF-8- Parameters:
file-- Returns:
- Throws:
Exception
-
readFile
Read File- Parameters:
file-encoding-- Returns:
- Throws:
Exception
-
readFile
readFile Reads a file and return the lines into a string array- Parameters:
String- FileName (FilePath)- Returns:
- String[] lines
- Throws:
FileNotFoundException
-
readFile
readFile Reads a file and return the lines into a string array- Parameters:
String- FileName (FilePath)- Returns:
- String[] lines
- Throws:
Exception
-
generateFile
generateFile (DEFAULT ENCODING UTF-8) Create and write String to File- Parameters:
data-filePath-- Returns:
- filePath
-
generateFile
Gera um arquivo- Parameters:
dados- a serem gravados no arquivonome- do arquivocodificação- (ex. UTF-8, ISO-8859-1, etc)
-
generateTmpFile
generateTmpFile Create and write String to File at java.io.tmpdir- Parameters:
data-fileName-- Returns:
- filePath
-
createFile
createFile (DEFAULT ENCODING UTF-8) Create a text file- Parameters:
String- FileName (FilePath)boolean- append- Returns:
- FileWriter fw
- Throws:
IOException
-
createFile
public static FileWriter createFile(String fileName, boolean append, String encoding) throws IOException createFile Create a text file- Parameters:
String- FileName (FilePath)boolean- appendString- encoding- Returns:
- FileWriter fw
- Throws:
IOException
-
createFile
createFile with a encoding type- Parameters:
fileName-append-encoding-- Returns:
- Throws:
IOException
-
addText
addLine Add line- Parameters:
FileWriter- fwString- line- Throws:
IOException
-
addText
addLine- Parameters:
wr-text-- Throws:
IOException
-
addText
addLine Add line- Parameters:
FileWriter- fwString- lineboolean- quoteValue ? surround the line with double quotes : do not surround the values with double quotes- Throws:
IOException
-
closeFile
closeFile Close a text file- Parameters:
String- FileName (FilePath)- Throws:
IOException
-
closeFile
closeFile Close a textfile- Parameters:
wr-- Throws:
IOException
-
deleteFile
deleteFile Delete File- Parameters:
String- FileName (FilePath)
-
deleteFile
deleteFile- Parameters:
File- fp
-
addEOL
addEOL End of Line- Parameters:
FileWriter- fw- Throws:
IOException
-
removeEOL
removeEOL- Parameters:
String- textboolean- trim- Returns:
- String without EOL
-
removeEOL
-
formatTimeString
Formata e Valida String HH:MM para HH:MM:SS- Parameters:
time-- Returns:
- string formata ou null
-
pad
-
pad
-
pad
public static String pad(String value, char filler, int length, boolean lpad, boolean removeMask, boolean removeSpecial) pad- Parameters:
String- valuechar- fillerint- lengthboolean- lpadboolean- removeMaskboolean- removeSpecial- Returns:
- String value
-
lPad
-
lPad
Left Pad with 0- Parameters:
String- valueint- length- Returns:
- String value
-
lPad
Left Pad- Parameters:
String- valuechar- fillerint- length- Returns:
- String value
-
lPad
Left Pad with 0 (Scale 2 Default)- Parameters:
String- valueint- length- Returns:
- String value
-
lPad
Left Pad with 0- Parameters:
String- valueint- lengthint- scale- Returns:
- String value
-
rPad
Right Pad with blank space ' '- Parameters:
String- valueint- length- Returns:
- String value
-
rPad
Right Pad- Parameters:
String- valuechar- fillerint- length- Returns:
- String value
-
retiraPontoFinal
retiraPontoFinal Remove Period- Parameters:
String- value- Returns:
- String value
-
toNumeric
Retorna sempre somente os digitos
de 0..9 de um String desconsiderando
qualquer outro caracter.
Por Exemplo:
UmaString"14.568-910"
é automaticamente passada para "14568910".
UmaString"1%4#5?55%16a8&910"
é automaticamente passada para "14555168",
só levando em conta os números.- Parameters:
String- Valor Original- Returns:
- String Somente Números
-
checkSizeN
Verifica se a string está entre os valores minímos e máximo- Parameters:
value-min-max-- Returns:
-
checkSizeN
Verifica se a string está entre os valores minímos e máximo- Parameters:
value-min-max-- Returns:
-
checkSize
Verifica se a string está entre os valores minímos e máximo- Parameters:
value-min-max-- Returns:
-
checkSize
-
checkSize
Verifica se a string está entre os valores minímos e máximo- Parameters:
value-min-max-- Returns:
-
toNumeric
Retorna sempre somente os digitos
de 0..9 de um BigDecimal com 2 casas.
Por Exemplo:
UmBigDecimal"14568.910"
é automaticamente passada para "14568,910".- Parameters:
BigDecimal- Valor Originalmin-max-- Returns:
- String Numero formatado
-
toNumeric
Retorna sempre somente os digitos
de 0..9 de um BigDecimal com 2 casas.
Por Exemplo:
UmBigDecimal"14568.910"
é automaticamente passada para "14568,910".- Parameters:
BigDecimal- Valor Originalmin-max-- Returns:
- String Numero formatado
-
toNumeric
Retorna sempre somente os digitos
de 0..9 de um BigDecimal com 2 casas.
Por Exemplo:
UmBigDecimal"14568.910"
é automaticamente passada para "14568,910".- Parameters:
BigDecimal- Valor Originalmin-max-scale-- Returns:
- String Numero formatado
-
toNumeric
Retorna sempre somente os digitos
de 0..9 de um BigDecimal com 2 casas.
Por Exemplo:
UmBigDecimal"14568.910"
é automaticamente passada para "14568,910".- Parameters:
BigDecimal- Valor Original- Returns:
- String Numero formatado
-
toNumeric
Retorna sempre somente os digitos
de 0..9 de um BigDecimal com 2 casas.
Por Exemplo:
UmBigDecimal"14568.910"
é automaticamente passada para "14568,910".- Parameters:
BigDecimal- Valor Original- Returns:
- String Numero formatado
-
retiraEspecial
Retorna somente os digitos de 0..9
e as letras de a..z e A..Z, desconsiderando
qualquer outro caracter.
Por Exemplo:
UmaString"123ABC##&&%%999"
é automaticamente passada para "123ABC999".
UmaString"1%4#5?55%16a8&910bbb"
é automaticamente passada para "1455516a8bbb",
só levando em conta os números.- Parameters:
String- Valor Original- Returns:
- String Somente Letras e Números
-
timeToString
Retorna a data formatada de acordo com o formato
Dia: dd, Mes: mm, Ano: yyyy- Parameters:
Timestamp- DataString- Formato da databoolean- Obrigatório- Returns:
- String Data Formatada
-
timeToString
Retorna a data formatada de acordo com o formato
Dia: dd, Mes: mm, Ano: yyyy- Parameters:
Timestamp- DataString- Formato da data- Returns:
- String Data Formatada
-
timeToUTC
-
timeToString
Retorna a data formatada em AnoMesDia yyyymmdd- Parameters:
Timestamp- Data- Returns:
- String Data Formatada
-
timeToString
Retorna a data formatada- Parameters:
Date- DataString- format Ex. ("dd/MM/yyyy")- Returns:
- String Data Formatada
-
stringToTime
StringToDate Convert String to Timestamp- Parameters:
String- dataFormatadaString- dateFormat- Returns:
- Timestamp
-
stringTobigdecimal
-
bigdecimalFormat
Transforma BigDecimal em String seguindo o padrão #.##0,00- Parameters:
value-- Returns:
- String formatada
-
bigdecimalToString
bigdecimalToString- Parameters:
BigDecimal- valueint- Scale- Returns:
- String with scale
-
bigdecimalToString
getValor- Parameters:
value-- Returns:
- String with scale
-
itrim
iTrim- Parameters:
String-- Returns:
- replace multiple whitespaces between words with single blank
-
itrim
-
isNumber
Verifica se uma String contém exclusivamente dígitos- Parameters:
documentNo-- Returns:
-
checkOrderBy
-
checkWhereClause
-
countMatches
Conta a quantidade de vezes que um caracter se repete em uma string countMatches- Parameters:
caracter-str-- Returns:
-
convertStringToHex
Convert String to Hex- Parameters:
arg-- Returns:
- String Hex
- Throws:
Exception
-
generateSHA1
Generate SHA1 to param string From: http://stackoverflow.com/questions/4895523/java-string-to-sha1- Parameters:
string-- Returns:
- byte[]
- Throws:
Exception
-
byteArrayToHexString
From: http://stackoverflow.com/questions/4895523/java-string-to-sha1- Parameters:
b-- Returns:
-
match
Verifica se lista contém uma determinada string.- Parameters:
stra-strings-- Returns:
- TRUE se a lista contém a string, senão FALSO
-
unescapeHtml3
-
getZoomTag
Este método retorna um link HTML para realizar zoom em registros. A janela que será exibida será a definida no cadastro da tabela no dicionário- Parameters:
registro- : uma intância da PO contendo o registro que deve ser dado o zoom ao clicar no link.texto- : o texto em que o link deve ser exibido.- Returns:
- uma String contendo a tag HTML "" com o link que redireciona para o registro informado.
-
getZoomTag
Este método retorna um link HTML para realizar zoom em registros.- Parameters:
registro- : uma intância da PO contendo o registro que deve ser dado o zoom ao clicar no link.AD_Window_UU- : UUID da janela que o zoom deve ser realizado.texto- : o texto em que o link deve ser exibido.- Returns:
- uma String contendo a tag HTML "" com o link que redireciona para o registro informado.
-