|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdeadbeef.Tools.ToolBox
public class ToolBox
Selection of utility functions.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Constructor Summary | |
---|---|
ToolBox()
|
Method Summary | |
---|---|
static java.lang.String |
addSeparator(java.lang.String fName)
Add (system default) path separator to string (if there isn't one already) |
static java.lang.String |
exchangeSeparators(java.lang.String fName)
Exchange any DOS style path separator ("\") with a Unix style separator ("/") |
static java.lang.String |
formatDouble(double d)
Format double as string in the form "xx.yyy" |
static int |
getByte(byte[] buffer,
int index)
Read byte from a buffer from position index |
static double |
getDouble(java.lang.String s)
Convert String to double |
static java.lang.String |
getExtension(java.lang.String path)
Returns the extension (".XXX") of a filename without the dot |
static byte[] |
getFileID(java.lang.String fname,
int num)
Returns the first few bytes of a file to check it's type |
static java.lang.String |
getFileName(java.lang.String path)
Return file name from path |
static java.lang.String |
getFileName(java.lang.String path,
java.lang.String fn,
java.lang.String[] ext,
boolean load,
java.awt.Component parent)
Get file name via "file chooser" dialog |
static int |
getInt(java.lang.String s)
Convert String to integer |
static java.lang.String |
getPathName(java.lang.String path)
Return path name from a file name |
static int |
getWord(byte[] buffer,
int index)
Read (big endian) word from a buffer from position index |
static java.lang.String |
hex(int val,
int digits)
Convert an integer to a C-style hex string with leading zeroes |
static java.lang.String |
hex(long val,
int digits)
Convert a long integer to a C-style hex string with leading zeroes |
static int[] |
msToTime(long ms)
Convert time in milliseconds to array containing hours, minutes, seconds and milliseconds |
static java.lang.String |
ptsToTimeStr(long pts)
Convert time in 90kHz ticks to string hh:mm:ss.ms |
static java.lang.String |
ptsToTimeStrIdx(long pts)
Convert time in 90kHz ticks to string hh:mm:ss:ms |
static java.lang.String |
ptsToTimeStrXml(long pts,
double fps)
Convert time in 90kHz ticks to string hh:mm:ss:ff (where ff is number of frames) |
static void |
setByte(byte[] buffer,
int index,
int val)
Write byte to buffer[index] |
static void |
setDWord(byte[] buffer,
int index,
int val)
Write (big endian) double word to buffer[index] (index points at most significant byte) |
static void |
setString(byte[] buffer,
int index,
java.lang.String s)
Write ASCII string to buffer[index] (no special handling for multi-byte characters) |
static void |
setWord(byte[] buffer,
int index,
int val)
Write (big endian) word to buffer[index] (index points at most significant byte) |
static void |
showException(java.lang.Throwable ex)
Show a dialog with details about an exception |
static java.lang.String |
stripExtension(java.lang.String path)
Strips the extension (".XXX") from a file name (including the dot) If no extension is found, the unchanged string is returned. |
static long |
timeStrToPTS(java.lang.String s)
Convert string in hh:mm:ss.ms or hh:mm:ss:ms format to time in 90kHz resolution |
static long |
timeStrXmlToPTS(java.lang.String s,
double fps)
Convert string in hh:mm:ss:ff format to time in 90kHz resolution |
static java.lang.String |
trim(java.lang.String s)
Remove trailing and leading spaces from a string |
static java.lang.String |
zeroTrim(int i,
int digits)
Convert an integer to a string with leading zeroes |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ToolBox()
Method Detail |
---|
public static java.lang.String zeroTrim(int i, int digits)
i
- Integer value to convertdigits
- Number of digits to display (note: a 32bit number can have only 10 digits)
public static java.lang.String hex(long val, int digits)
val
- Integer value to convertdigits
- Number of digits to display (note: a 32bit hex number can have only 8 digits)
public static java.lang.String hex(int val, int digits)
val
- Integer value to convertdigits
- Number of digits to display (note: a 32bit hex number can have only 8 digits)
public static java.lang.String formatDouble(double d)
d
- Double value
public static int[] msToTime(long ms)
ms
- Time in milliseconds
public static java.lang.String ptsToTimeStr(long pts)
pts
- Time in 90kHz resolution
public static java.lang.String ptsToTimeStrIdx(long pts)
pts
- Time in 90kHz resolution
public static java.lang.String ptsToTimeStrXml(long pts, double fps)
pts
- Time in 90kHz resolutionfps
- Frames per second
public static long timeStrToPTS(java.lang.String s)
s
- String in hh:mm:ss.ms or hh:mm:ss:ms format
public static long timeStrXmlToPTS(java.lang.String s, double fps)
s
- String in hh:mm:ss:ff formatfps
- Frames per second
public static int getByte(byte[] buffer, int index) throws java.lang.ArrayIndexOutOfBoundsException
buffer
- Byte arrayindex
- Index to read from
java.lang.ArrayIndexOutOfBoundsException
public static int getWord(byte[] buffer, int index) throws java.lang.ArrayIndexOutOfBoundsException
buffer
- Byte arrayindex
- Index to read from
java.lang.ArrayIndexOutOfBoundsException
public static void setByte(byte[] buffer, int index, int val) throws java.lang.ArrayIndexOutOfBoundsException
buffer
- Byte arrayindex
- Index to write toval
- Integer value of byte to write
java.lang.ArrayIndexOutOfBoundsException
public static void setWord(byte[] buffer, int index, int val) throws java.lang.ArrayIndexOutOfBoundsException
buffer
- Byte arrayindex
- Index to write toval
- Integer value of word to write
java.lang.ArrayIndexOutOfBoundsException
public static void setDWord(byte[] buffer, int index, int val) throws java.lang.ArrayIndexOutOfBoundsException
buffer
- Byte arrayindex
- Index to write toval
- Integer value of double word to write
java.lang.ArrayIndexOutOfBoundsException
public static void setString(byte[] buffer, int index, java.lang.String s) throws java.lang.ArrayIndexOutOfBoundsException
buffer
- Byte arrayindex
- Index to write tos
- String containing ASCII characters
java.lang.ArrayIndexOutOfBoundsException
public static void showException(java.lang.Throwable ex)
ex
- Throwable/Exception to displaypublic static java.lang.String getFileName(java.lang.String path, java.lang.String fn, java.lang.String[] ext, boolean load, java.awt.Component parent)
path
- Default path (without file name). Might be "", but not null.fn
- Default file name (without path). Can be null.ext
- Array of allowed extensions (without ".")load
- If true, this is a load dialog, else it's a save dialogparent
- Parent component (Frame, Window)
public static java.lang.String addSeparator(java.lang.String fName)
fName
- String containing path name
public static java.lang.String exchangeSeparators(java.lang.String fName)
fName
- String containing file/path name
public static java.lang.String getFileName(java.lang.String path)
path
- String of a path with a file name
public static java.lang.String getPathName(java.lang.String path)
path
- String of file name with a path
public static java.lang.String getExtension(java.lang.String path)
path
- String containing file name
public static java.lang.String stripExtension(java.lang.String path)
path
- String containing a file name
public static byte[] getFileID(java.lang.String fname, int num)
fname
- Filename of the filenum
- Number of bytes to return
public static java.lang.String trim(java.lang.String s)
s
- String to process
public static int getInt(java.lang.String s)
s
- String containing integer (assumed: positive)
public static double getDouble(java.lang.String s)
s
- String containing double
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |