public class InternalUtils
extends java.lang.Object
NB: Some of these are copies (sometimes simplified) of methods in com.winterwell.utils.Utils You can find this code here: https://github.com/sodash/open-code
| Modifier and Type | Field and Description |
|---|---|
static java.util.regex.Pattern |
DM
Group 1 = the recipient
|
static long |
HOUR
one hour in milliseconds
|
static java.util.regex.Pattern |
latLongLocn
Matches latitude, longitude, including with the UberTwitter UT: prefix
Group 2 = latitude, Group 3 = longitude.
|
static java.util.regex.Pattern |
pComment
Matches an xml comment - including some bad versions
|
static java.util.regex.Pattern |
pDocType
Matches a doctype element.
|
static java.util.regex.Pattern |
pScriptOrStyle
Used in strip tags to get rid of scripts and css style blocks altogether.
|
static java.util.regex.Pattern |
REGEX_JUST_DIGITS |
static java.util.regex.Pattern |
TAG_REGEX |
| Constructor and Description |
|---|
InternalUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.math.BigInteger |
addTimeToStatusId(java.math.BigInteger statusId,
long time)
Splits a Twitter Snowflake ID into its component numbers, performs arithmetic on the timestamp component, and reconstitutes a synthetic ID for "since_id" and "until_id" purposes.
|
static java.util.Map |
asMap(java.lang.Object... keyValuePairs)
Create a map from a list of key, value pairs.
|
static void |
close(java.io.Closeable output) |
static void |
close(java.io.InputStream input) |
static java.util.Map<com.winterwell.jgeoplanet.IPlace,java.lang.Double> |
filterByReq(com.winterwell.jgeoplanet.GeoCodeQuery query,
java.util.Map<com.winterwell.jgeoplanet.IPlace,java.lang.Double> places)
Utility method for
IGeoCoders |
static java.lang.Boolean |
geoMatch(com.winterwell.jgeoplanet.GeoCodeQuery query,
com.winterwell.jgeoplanet.IPlace place)
Does place match the query?
|
static java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Long> |
getAPIUsageStats()
Deprecated.
|
static <X> X |
getBest(java.util.Map<X,java.lang.Double> places)
Best of them, or null if places is empty
|
static java.util.Date |
getDate(int year,
java.lang.String month,
int day)
Convenience method for making Dates.
|
static java.util.Date |
getMaxDate(java.util.List<? extends Twitter.ITweet> stati) |
static java.math.BigInteger |
getMinId(java.math.BigInteger maxId,
java.util.List<? extends Twitter.ITweet> stati) |
static java.lang.String |
join(java.lang.String[] screenNames)
Join the list
|
protected static java.lang.String |
jsonGet(java.lang.String key,
com.winterwell.json.JSONObject jsonObj)
Helper method to deal with JSON-in-Java weirdness
|
static void |
log(java.lang.String tag,
java.lang.Object msg)
Use the Winterwell logger.
|
static java.lang.Object |
or(java.lang.Object... bits) |
static java.util.Map<com.winterwell.jgeoplanet.IPlace,java.lang.Double> |
prefer(com.winterwell.jgeoplanet.GeoCodeQuery query,
java.util.List<? extends com.winterwell.jgeoplanet.IPlace> places,
java.lang.String prefType,
double baseConfidence)
Utility method for
IGeoCoders |
protected static java.lang.String |
read(java.io.InputStream inputStream)
Use a buffered reader (preferably UTF-8) to extract the contents of the
given stream.
|
static java.lang.String |
removePunctuation(java.lang.String string) |
static void |
setTrackAPIUsage(boolean on)
Deprecated.
|
static void |
sleep(long msecs) |
static java.lang.String |
str(java.lang.Object obj)
Created to handle odd failed toString() for Exception: "[Ljava.lang.StackTraceElement;@6553bf22"
Seen Dec 2014
|
static java.lang.String |
str(java.lang.Object[] array) |
static java.lang.String |
stripTags(java.lang.String xml)
Remove xml and html tags, e.g.
|
static java.lang.String |
stripUrls(java.lang.String text)
Deprecated.
Not used anymore
|
static java.math.BigInteger |
toBigInteger(java.lang.Number statusId) |
static java.lang.String |
toCanonical(java.lang.String string) |
static java.lang.String |
toString(java.lang.Throwable x,
boolean stacktrace)
Copied from Printer in utils
|
static java.lang.String |
trimPunctuation(java.lang.String string)
Trim out whitespace and punctuation from the beginning and end of
the string.
|
static java.lang.String |
urlEncode(java.lang.String x)
URL encode
|
public static final java.util.regex.Pattern TAG_REGEX
public static final java.util.regex.Pattern latLongLocn
Weird: I saw this as an address - "ÜT: 25.324488,55.376224t" Is it just a one-off typo? Should we match N/S/E/W markers?
public static final java.util.regex.Pattern REGEX_JUST_DIGITS
public static final java.util.regex.Pattern DM
public static final java.util.regex.Pattern pComment
public static final java.util.regex.Pattern pScriptOrStyle
public static final java.util.regex.Pattern pDocType
public static final long HOUR
@Deprecated public static void setTrackAPIUsage(boolean on)
@Deprecated public static java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Long> getAPIUsageStats()
public static java.util.Map<com.winterwell.jgeoplanet.IPlace,java.lang.Double> filterByReq(com.winterwell.jgeoplanet.GeoCodeQuery query,
java.util.Map<com.winterwell.jgeoplanet.IPlace,java.lang.Double> places)
IGeoCodersquery - places - Can be null.public static java.util.Map<com.winterwell.jgeoplanet.IPlace,java.lang.Double> prefer(com.winterwell.jgeoplanet.GeoCodeQuery query,
java.util.List<? extends com.winterwell.jgeoplanet.IPlace> places,
java.lang.String prefType,
double baseConfidence)
IGeoCodersquery - places - prefType - e.g. citybaseConfidence - public static java.lang.String stripUrls(java.lang.String text)
text - public static java.util.Map asMap(java.lang.Object... keyValuePairs)
Arrays.asList(Object...). If
the value is null, the key will not be included.public static void close(java.io.Closeable output)
public static void close(java.io.InputStream input)
public static java.util.Date getDate(int year,
java.lang.String month,
int day)
year - month - day - public static java.lang.String join(java.lang.String[] screenNames)
screenNames - protected static java.lang.String jsonGet(java.lang.String key,
com.winterwell.json.JSONObject jsonObj)
protected static java.lang.String read(java.io.InputStream inputStream)
public static java.lang.String urlEncode(java.lang.String x)
x - can be null (returns ""). Will be turned into a String using
String.valueOf()public static java.lang.String stripTags(java.lang.String xml)
xml - can be null, in which case null will be returnedpublic static void sleep(long msecs)
public static java.math.BigInteger getMinId(java.math.BigInteger maxId,
java.util.List<? extends Twitter.ITweet> stati)
maxId - stati - public static java.util.Date getMaxDate(java.util.List<? extends Twitter.ITweet> stati)
maxId - stati - public static <X> X getBest(java.util.Map<X,java.lang.Double> places)
places - public static java.lang.Boolean geoMatch(com.winterwell.jgeoplanet.GeoCodeQuery query,
com.winterwell.jgeoplanet.IPlace place)
query - place - public static java.lang.String toCanonical(java.lang.String string)
public static void log(java.lang.String tag,
java.lang.Object msg)
tag - msg - public static java.math.BigInteger toBigInteger(java.lang.Number statusId)
statusId - Can be null (returns null)public static java.lang.String str(java.lang.Object[] array)
public static java.lang.String str(java.lang.Object obj)
obj - public static java.lang.String toString(java.lang.Throwable x,
boolean stacktrace)
x - stacktrace - public static java.lang.Object or(java.lang.Object... bits)
public static java.math.BigInteger addTimeToStatusId(java.math.BigInteger statusId,
long time)
time - A signed integer - milliseconds to add or subtract from the time. Can be null.public static java.lang.String trimPunctuation(java.lang.String string)
string - public static java.lang.String removePunctuation(java.lang.String string)