public class Utils extends Object implements Lot49Constants
Modifier and Type | Field and Description |
---|---|
private static AtomicLong |
COOKIE_SEQUENCER
For use in
createModUidCookie() . |
static org.joda.time.format.PeriodFormatter |
DEFAULT_PERIOD_FORMATTER |
static com.fasterxml.jackson.core.JsonFactory |
JSON_FACTORY |
static com.fasterxml.jackson.databind.ObjectMapper |
MAPPER |
static Random |
RANDOM |
static Pattern |
REGEXP_COOKIE_VALUE_DISALLOWED_PATTERN |
static String |
REGEXP_COOKIE_VALUE_DISALLOWED_STR |
static Pattern |
REGEXP_DOMAIN_NAME_PATTERN |
static String |
REGEXP_DOMAIN_NAME_PATTERN_STR |
static Pattern |
REGEXP_REDUNDANT_WHITESPACE_PATTERN |
static String |
REGEXP_REDUNDANT_WHITESPACE_STR |
private static Map<String,net.sf.uadetector.ReadableUserAgent> |
UA_TO_BROWSER_INFO |
AD_FILENAME_PREFIX, AUCTION_RESULTS_PATH_ADX, AUCTION_RESULTS_PATH_OPENX, AUCTION_RESULTS_PATH_PUBMATIC, BID_OUTCOME_CONTROL, BID_OUTCOME_INTERNAL_AUCTION_LOSS, BID_OUTCOME_SUBMITTED, BID_PRICE_CALCULATOR_FILENAME_PREFIX, COOKIE_PREFIX_A, DECISION_BIDS_MADE, DECISION_BIDS_NEEDED, DECISION_BIDS_POSSIBLE, DECISION_BRANDSAFETY, DECISION_BROWSER, DECISION_BUDGET, DECISION_CATEGORY, DECISION_DATE, DECISION_DAY, DECISION_DEVICE, DECISION_DOMAIN_REQUIRED, DECISION_DOMAIN_UNMATCHED, DECISION_EVALUATION_ERROR, DECISION_EXCHANGE, DECISION_EXPERIMENT_CONTROL_SET, DECISION_FLOOR, DECISION_FREQ_CAP, DECISION_GEO, DECISION_HOST, DECISION_HOUR, DECISION_INTEGRAL, DECISION_INTEGRAL_URL, DECISION_INTERNAL_AUCTION, DECISION_IP_BLACKLISTED, DECISION_LANGUAGE, DECISION_LOADING_ERROR, DECISION_NO_IMPRESSIONS, DECISION_NO_USER, DECISION_OS, DECISION_PACING, DECISION_PRIVATE_DEAL, DECISION_PROBABILITY, DECISION_PROVIDER, DECISION_SSP, DECISION_TAG, DECISION_TIMEOUT_EXPERIMENT_STATUS, DECISION_TIMEOUT_FC, DECISION_TIMEOUT_INTEGRAL, DECISION_TIMEOUT_UNKNOWN, DECISION_TIMEOUT_USERDATA, DECISION_TRAQ, DECISION_URL, DECISION_USER_UNKNOWN, DECISION_VALIDATION, DECISION_VIEWABILITY, DECISION_WRONG_USER, DEFAULT_CLICK_PATH_ABSOLUTE, DEFAULT_CLICK_PATH_RELATIVE, DEFAULT_IMPRESSION_PATH_ABSOLUTE, DEFAULT_IMPRESSION_PATH_RELATIVE, DEFAULT_NURL_PATH_ABSOLUTE, DEFAULT_NURL_PATH_RELATIVE, DEFAULT_PIXEL_PATH_ABSOLUTE, DEFAULT_PIXEL_PATH_RELATIVE, DEFAULT_PROUST_PATH_ABSOLUTE, DEFAULT_PROUST_PATH_RELATIVE, DEFAULT_REDIR_PATH_ABSOLUTE, DEFAULT_REDIR_PATH_RELATIVE, DEFAULT_TEST_PATH_RELATIVE, EXCHANGE_ADAPTV, EXCHANGE_ADX, EXCHANGE_BIDSWITCH, EXCHANGE_BRX, EXCHANGE_LIVERAIL, EXCHANGE_LOT49_INTERNAL_AUCTION, EXCHANGE_OPENX, EXCHANGE_PUBMATIC, EXCHANGE_SMAATO, EXCHANGE_SPOTXCHANGE, EXCHANGE_TEST1, EXCHANGE_TEST2, LOT49_VERSION_KEY, LOT49_VERSION_VALUE, MEDIA_TYPE_APPLICATION_JAVASCRIPT, MEDIA_TYPE_APPLICATION_SHOCKWAVE_FLASH, MEDIA_TYPE_VIDEO_FLV, MEDIA_TYPE_VIDEO_MP4, MOD_UID_COOKIE_LENGTH_MAX, MOD_UID_COOKIE_LENGTH_MIN, MOD_UID_LOG_LENGTH, NAME, NURL_ONLY_TAG, NURL_ONLY_WIN_NOTIFICATION, NURL_STANDART, QUERY_STRING_EXCHANGE_CLICK_THROUGH_ENCODED_MACRO, QUERY_STRING_EXCHANGE_CLICK_THROUGH_MACRO, QUERY_STRING_LOT49_CLICK_THROUGH_MACRO, REL_PATH_DEBUG_NURL, ROOT_PATH_ADMIN, ROOT_PATH_AUCTIONS, ROOT_PATH_STATS, TAG_DECISION_API, TAG_DECISION_DIMENSIONS, TAG_DECISION_DURATION, TAG_DECISION_MIME, TAG_DECISION_NOT_BANNER, TAG_DECISION_NOT_VIDEO, TAG_DECISION_PROTOCOL, TAG_DECISION_REQUEST_DISALLOWS_MARKUP, TAG_DECISION_SSL_REQUIRED, TAG_DECISION_VIDEO_LINEARITY, TAG_FILENAME_PREFIX, TEST_MOD_UID_COOKIE_1, TEST_MOD_UID_COOKIE_2, TEST_MOD_UID_COOKIE_3, TEST_MOD_UID_COOKIE_4, TEST_MOD_UID_LOG_1, TEST_MOD_UID_LOG_2, TEST_MOD_UID_LOG_3, TEST_MOD_UID_LOG_4
Modifier | Constructor and Description |
---|---|
private |
Utils()
All methods here are static.
|
Modifier and Type | Method and Description |
---|---|
static javax.ws.rs.core.Response.ResponseBuilder |
addOptoutHeaders(Lot49Ext ext,
javax.ws.rs.core.Response.ResponseBuilder builder)
Add optout headers to the response if
Lot49Ext.isDebug() . |
static List<String> |
apisToString(List<Integer> apis) |
static String |
apiToString(int api) |
static String |
brxMimeToString(BrxRtb095.Mimes mime) |
static String |
capitalize(String s) |
static String |
cookieToLogModUid(String encUid)
Convert NGINX-set user ID from cookie to log format.
|
static int |
countChar(String str,
char reg) |
static long |
cpmToMicro(double cpm)
Convert CPM value in dollars to micro-dollars per impression.
|
static String |
createModUidCookie()
Creates cookie based on mod_uid cookie rules.
|
static String |
createModUidCookie(boolean urlSafe) |
static String |
delimFormat(char delim,
char delim2,
String nullChar,
boolean waitForFutures,
long waitForFuturesTimeoutMillis,
Object... obj)
Convert the provided objects to tab-separated string of their String representations (TSV).
|
static void |
delimFormat(StringBuilder buf,
char delim,
char delim2,
String nullChar,
boolean waitForFutures,
long waitForFuturesTimeoutMillis,
List obj)
Convert the provided objects to delimiter-separated string of their String representations.
|
static void |
delimFormat(StringBuilder sb,
char delim,
char delim2,
String nullChar,
boolean waitForFutures,
long waitForFuturesTimeoutMillis,
Object... obj) |
static String |
encodeUrl(String url,
ExchangeAdapter adapter)
URL-encodes provided URL keeping Winning price macro alone
|
static String |
fixStringEncode(String target) |
static net.sf.uadetector.ReadableUserAgent |
getBrowserInfoFromUa(String ua) |
static String |
getId() |
static long |
incrMapCounter(Map<String,AtomicLong> map,
String key) |
static Set<String> |
incrMapSet(Map<String,Set<String>> map,
String key,
String value) |
static long |
ipToLong(String ipAddress) |
static BigInteger |
ipv6ToBigInteger(String ipAddress) |
private static BigInteger |
ipv6ToBigIntegerInt(String ipAddress) |
static boolean |
isMagic() |
static boolean |
isTrue(Object o)
Whether the specified argument can be interpreted as true.
|
static Config |
loadConfig(String fileName,
Class<? extends Config> configClass) |
static String |
logToCookieModUid(String encUid)
The opposite of
cookieToLogModUid(String) . |
static String |
logToCookieModUid(String encUid,
boolean urlSafe) |
static double |
microToCpm(double micro) |
static double |
microToCpm(long micro)
Convert micro-dollar per impression to CPM in dollars.
|
static void |
noop()
No-op method to insert for a breakpoint.
|
static void |
noop(Object... objects)
No-op method to insert for a breakpoint, if you want to examine the objects in the debugger.
|
static Map<String,String> |
parseQueryString(String s)
Parse query string (of the format "k1=v1&k2=v2&k3=v3").
|
private static net.sf.uadetector.ReadableUserAgent |
parseUa(String ua) |
static List<String> |
protosToString(List<Integer> protos) |
static String |
protoToString(int proto) |
static String |
readFile(File f) |
static String |
readFile(String s) |
static String |
readUrl(String url) |
static String |
removeRedundantWhitespace(String s) |
static StringBuilder |
replace(StringBuilder sb,
String searched,
String replaceTo) |
static StringBuilder |
replaceAll(StringBuilder sb,
String searched,
String replaceTo) |
static <T> Set<T> |
set(T... items) |
private static String |
toHexString(long l) |
static String |
toStringKeyValue(String key,
Object value) |
static void |
trace(Object msg)
Same as
LogUtils.debug(Object) , but also writes information about current stack
frames. |
static boolean |
validateDomain(String d) |
private static final Map<String,net.sf.uadetector.ReadableUserAgent> UA_TO_BROWSER_INFO
public static final String REGEXP_DOMAIN_NAME_PATTERN_STR
public static final Pattern REGEXP_DOMAIN_NAME_PATTERN
public static final String REGEXP_REDUNDANT_WHITESPACE_STR
public static final Pattern REGEXP_REDUNDANT_WHITESPACE_PATTERN
public static final String REGEXP_COOKIE_VALUE_DISALLOWED_STR
public static final Pattern REGEXP_COOKIE_VALUE_DISALLOWED_PATTERN
private static AtomicLong COOKIE_SEQUENCER
createModUidCookie()
.public static final Random RANDOM
public static final com.fasterxml.jackson.core.JsonFactory JSON_FACTORY
public static final com.fasterxml.jackson.databind.ObjectMapper MAPPER
public static final org.joda.time.format.PeriodFormatter DEFAULT_PERIOD_FORMATTER
private static final net.sf.uadetector.ReadableUserAgent parseUa(String ua)
public static final net.sf.uadetector.ReadableUserAgent getBrowserInfoFromUa(String ua)
public static String encodeUrl(String url, ExchangeAdapter adapter)
public static final javax.ws.rs.core.Response.ResponseBuilder addOptoutHeaders(Lot49Ext ext, javax.ws.rs.core.Response.ResponseBuilder builder)
Lot49Ext.isDebug()
.public static boolean validateDomain(String d)
public static boolean isMagic()
public static final String cookieToLogModUid(String encUid)
Lot49Constants.TEST_MOD_UID_LOG_1
or
Lot49Constants.TEST_MOD_UID_LOG_2
and value sent in a cookie field is, respectively,
Lot49Constants.TEST_MOD_UID_COOKIE_1
and Lot49Constants.TEST_MOD_UID_COOKIE_2
.public static <T> Set<T> set(T... items)
private static final String toHexString(long l)
public static final String logToCookieModUid(String encUid)
cookieToLogModUid(String)
.public static final String createModUidCookie()
public static final String createModUidCookie(boolean urlSafe)
public static Map<String,String> parseQueryString(String s)
public static final boolean isTrue(Object o)
Boolean
, the answer is obviousString
, then it is lower-cased and leading/trailing whitespace
is trimmed. After that, any of the following values are interpreted as false :
Number
, then a 0 value is false, everything else is
true.Collection
, then an empty one is false , everything
else is true.File
, the result is the same as calling File.exists()
.
public static String readFile(String s) throws Lot49Exception
Lot49Exception
public static String readUrl(String url) throws IOException
IOException
public static Config loadConfig(String fileName, Class<? extends Config> configClass) throws Lot49Exception
Lot49Exception
public static String readFile(File f) throws Lot49Exception
Lot49Exception
public static final long cpmToMicro(double cpm)
Example: $12.45 CPM means that each impression is priced at $ $12.45/1,000=0.01245. In micro-dollars, that would be 0.01245*1,000,000=12450.
public static final double microToCpm(long micro)
Example: 2,500 micro-dollars per-impression mean that I am willing to pay $ 2,500/1,000,000=0.0025 for each individual impression. That means that for the thousand impressions, my price (CPM) is $ 0.0025*1,000=2.5.
public static final double microToCpm(double micro)
public static final String apiToString(int api)
public static final String brxMimeToString(BrxRtb095.Mimes mime)
public static final String protoToString(int proto)
public static void noop()
public static long incrMapCounter(Map<String,AtomicLong> map, String key)
public static Set<String> incrMapSet(Map<String,Set<String>> map, String key, String value)
public static void noop(Object... objects)
public static void delimFormat(StringBuilder buf, char delim, char delim2, String nullChar, boolean waitForFutures, long waitForFuturesTimeoutMillis, List obj)
public static String delimFormat(char delim, char delim2, String nullChar, boolean waitForFutures, long waitForFuturesTimeoutMillis, Object... obj)
delim
- delimiterdelim2
- delimiter within fields that are of list formatnullChar
- character to use for null (should default to XXX).waitForFutures
- whether to wait for futures or to log future not found.public static void delimFormat(StringBuilder sb, char delim, char delim2, String nullChar, boolean waitForFutures, long waitForFuturesTimeoutMillis, Object... obj)
public static void trace(Object msg)
LogUtils.debug(Object)
, but also writes information about current stack
frames.public static final String getId()
public static StringBuilder replace(StringBuilder sb, String searched, String replaceTo)
public static StringBuilder replaceAll(StringBuilder sb, String searched, String replaceTo)
public static long ipToLong(String ipAddress)
public static BigInteger ipv6ToBigInteger(String ipAddress)
private static BigInteger ipv6ToBigIntegerInt(String ipAddress)
public static int countChar(String str, char reg)