Bootstring encoding as defined in From: https://tools.ietf.org/html/rfc3492
An ImageInputStream implementation that reads from an Array[Byte]
An ImageOutputStream implementation that writes to a Array[Byte]
A Simple InputStream wrapper around a ByteBuffer
A Simple OutputStream wrapper around a ByteBuffer
Value enum with ByteEnumEntry entries
Value enum with ByteEnumEntry entries
This is similar to ValueEnum, but different in that values must be literal values. This restraint allows us to enforce uniqueness at compile time.
Note that uniqueness is only guaranteed if you do not do any runtime string manipulation on values.
Value Enum Entry parent class for Byte
valued entries
Wrapper around com.google.common.cache.Cache
Value enum with CharEnumEntry entries
Value enum with CharEnumEntry entries
This is similar to ValueEnum, but different in that values must be literal values. This restraint allows us to enforce uniqueness at compile time.
Note that uniqueness is only guaranteed if you do not do any runtime string manipulation on values.
Value Enum Entry parent class for Char
valued entries
Similar to Reader except for reading Unicode Code Points instead of Java Characters.
Similar to Reader except for reading Unicode Code Points instead of Java Characters.
See java.io.Reader for API descriptions. The behavior of this trait should mimic java.io.Reader.
A simple Logback extension to the PatternLayoutEncoder that adds simple coloring for WARN and ERROR levels
EXPERIMENTAL - A Scala mutable map that wraps a java ConcurrentHashMap and allows null values
EXPERIMENTAL - A Scala mutable Set based on ConcurrentHashMap
A Simple Crypto Class
A Simple Crypto Class
NOTE: Use at your own risk. We make no claim that any of this Crypto code is correct.
A Dummy Resource that does nothing
All the cool kids have their own Enumeration implementation, most of which try to do so in the name of implementing exhaustive pattern matching.
All the cool kids have their own Enumeration implementation, most of which try to do so in the name of implementing exhaustive pattern matching.
This is yet another one.
Example:
scala> sealed trait DummyEnum extends EnumEntry defined trait DummyEnum scala> object DummyEnum extends Enum[DummyEnum] { | val values = findValues | case object Hello extends DummyEnum | case object GoodBye extends DummyEnum | case object Hi extends DummyEnum | } scala> DummyEnum.withNameOption("Hello") res0: Option[DummyEnum] = Some(Hello) scala> DummyEnum.withNameOption("Nope") res1: Option[DummyEnum] = None
The sealed trait
Base type for an enum entry for Enum
For Resource.flatMap
Like java.io.ByteArrayOutputStream but exposes the internal Array
Simple Wrapper around an IPv4 Address
Represents an immutable java.util.Date
Represents an immutable java.util.Date
This provides an immutable milliseconds since epoch representation of a date when it might be a mismatch to use the newer java.time.Instance (which represents things as nanoseconds since or before epoch)
NOTE: NOT extending AnyVal so that nulls still work (just like with java.util.Date)
These are the Implicits that are shared between both the JVM and JS Implicits trait/object
These are the Implicits that are shared between both the JVM and JS Implicits trait/object
Value enum with IntEnumEntry entries
Value Enum Entry parent class for Int
valued entries
Wraper around Guava's Interner class.
Wraper around Guava's Interner class.
Originally I had a generic Intern object that had a map of Class[_] to Guava Interner but that relies on a correct implementation of equals which can make it error prone. For Example an Option[Char] can == an Option[Int]. So instead you have to be explicit about creating an Interner.
EXPERIMENTAL - A Java Set based on ConcurrentHashMap
Wrapper around com.google.common.cache.LoadingCache
This can be extended for basic logging functionality
Value enum with LongEnumEntry entries
Value Enum Entry parent class for Long
valued entries
For Resource.map
Compatible with the Rails MessageEncryptor using 'aes-256-cbc' and MessageVerifier using 'sha1' when working with *String* values.
Compatible with the Rails MessageEncryptor using 'aes-256-cbc' and MessageVerifier using 'sha1' when working with *String* values.
Also compatible with the custom MessageCrypto which marshalls values as JSON instead of using the ruby Marshal.dump and Marshal.load. Use json=true to dump using JSON.
MessageEncryptor uses Marshal.dump and Marshal.load on whatever values you are trying to encrypt/sign. A subset of Marshal.dump and Marshal.load have been implemented to support String values.
NOTE: This is a legacy class that was created when we switched from Rails to Scala. It is still used in a few places but probably needs to be refactored to remove the old Ruby marshalling stuff.
Takes multiple SeekableByteChannel instances and turns them into a single virtual one.
Takes multiple SeekableByteChannel instances and turns them into a single virtual one.
This is used for reading multi-part 7 Zip archives via commons-compress where we just need to concatenate all the parts of the 7 Zip archive into a single SeekableByteChannel which can then be used with the commons-compress SevenZFile class.
A Resource that can be used multiple times (e.g.
A Resource that can be used multiple times (e.g. opening an InputStream or Reader for a File)
scala.math.Ordering only goes up to Tuple9
Similar to a TaskRunner but allows you to pass in a priority value such that lower priority tasks will execute before higher priority tasks.
Represents immutable query parameters from a query string (e.g.
Represents immutable query parameters from a query string (e.g. "?foo=bar&asd=qwe").
This class distinguishes between 3 different types of values for a key:
Structural type for close()able resources
An Automatically Managed Resource that can either be used once (e.g.
An Automatically Managed Resource that can either be used once (e.g. reading an input stream) or multiple times (e.g. reading a file).
The purpose of Resource is two-fold: 1 - To automatically handle closing a resource after it is done being used. 2 - To abstract the fact that some resources can be read multiple times while other resources are one-time use.
This is a replacement for the deprecated scala.collection.SeqProxy.
This is a replacement for the deprecated scala.collection.SeqProxy.
This doesn't implement Seq[A] like the original SeqProxy but instead just provides an implicit conversion from this trait into a Seq[A] which then gives you all the Seq functionality
This is here so that LazySeq can be split out into it's own project.
This is here so that LazySeq can be split out into it's own project.
Some implementations are still in our internal Util package for now until we get a chance to refactor and possible merge with our fm-serializer project.
Value enum with ShortEnumEntry entries
Value Enum Entry parent class for Short
valued entries
A Resource that can only be used once (e.g.
A Resource that can only be used once (e.g. reading an InputStream)
Value enum with StringEnumEntry entries
Value enum with StringEnumEntry entries
This is similar to Enum, but different in that values must be literal values. This restraint allows us to enforce uniqueness at compile time.
Note that uniqueness is only guaranteed if you do not do any runtime string manipulation on values.
Value Enum Entry parent class for String
valued entries
Value Enum Entry parent class for String
valued entries
This is similar to Enum, but different in that values must be literal values. This restraint allows us to enforce uniqueness at compile time.
Note that uniqueness is only guaranteed if you do not do any runtime string manipulation on values.
Wraps a Scala mutable.HashMap inside of a ThreadLocal and exposes some simple operations.
Wraps a Scala mutable.HashMap inside of a ThreadLocal and exposes some simple operations.
The initial use case of this is for caching NumberFormat instances by Locale. This can be accomplished by overriding the initialValue method and just calling the apply() method with the Locale.
The HashMap Key
The HashMap Value
A type alias for java.net.URI
A type alias for java.net.URL
A custom UUID implementation (not to be confused with java.util.UUID or RFC4122 implementations) that allows natural sorting by timestamp based on the string or numeric representation.
A custom UUID implementation (not to be confused with java.util.UUID or RFC4122 implementations) that allows natural sorting by timestamp based on the string or numeric representation.
The UUID consists of 16 bytes (128 bits) broken up into 2 longs:
timeAndCounter: {6-Byte Millis since epoch}{2-Byte Counter} nodeIdAndRandom: {2-Byte Node ID}{6-Byte Random Number}
The "pretty" hex encoded representation is: {6-byte millis since epoch}-{2-byte-counter}-{2-byte-optional-node-id}-{4-byte-random}
Example: 015247f01787-9740-85e0-3e9672a8dfa2
This goes along with the UUIDWrapper
This goes along with the UUIDWrapper
See documentation of UUIDWrapper for the intended usage of this class
An UUID wrapper class that allow you to define custom types that represent an UUID.
An UUID wrapper class that allow you to define custom types that represent an UUID.
The intended usage pattern is something like:
object UserId extends UUIDFactory[UserId](new UserId(_)) final class UserId(val uuid: UUID) extends UUIDWrapper[UserId]
This allows you to then reference UserId instead of UUID and to have methods that take a strongly typed UserId instead of an UUID (which could represent something other than a User id)
Note: The class that extends this should also extends AnyVal so that serialization will just pass through to the underlying uuid
Wraps an InputStream and makes the close() method do nothing
Wraps an OutputStream and makes the close() method do nothing
Base trait for a Value-based enums.
Base trait for a Value-based enums.
Example:
sealed abstract class Greeting(val value: Int) extends IntEnumEntry object Greeting extends IntEnum[Greeting] { val values = findValues case object Hello extends Greeting(1) case object GoodBye extends Greeting(2) case object Hi extends Greeting(3) case object Bye extends Greeting(4) } Greeting.withValueOpt(1) == Some(GreetingHello) Greeting.withValueOpt(6) == None
Created by Lloyd on 4/11/16.
Created by Lloyd on 4/11/16.
Copyright 2016
DEPRECATED - Should use fm.common.Intern instead
DEPRECATED - Should use fm.common.Intern instead
An object pool based on a WeakHashMap (using weak key AND weak values) that can be used to return canonical versions of objects. Once all references to the object go away the WeakHashMap entry will be GC'd.
This is similar to how String.intern() works (although probably not as efficient)
Hex (Base16) encoding/decoding
Hex (Base16) encoding/decoding
Note: encodes to lowercase by default but will decode both lower/upper case Hex.
Base32 encoding/decoding
Base32 encoding/decoding
Note: encodes to lowercase by default but will decode both lower/upper case Base32.
Base32Hex encoding/decoding
Base32Hex encoding/decoding
Note: encodes to lowercase by default but will decode both lower/upper case Base32.
Base58 is a way to encode Bitcoin addresses (or arbitrary data) as alphanumeric strings.
Base58 is a way to encode Bitcoin addresses (or arbitrary data) as alphanumeric strings.
Note that this is not the same base58 as used by Flickr, which you may find referenced around the Internet.
You may want to consider working with PrefixedChecksummedBytes
instead, which
adds support for testing the prefix and suffix bytes commonly found in addresses.
Satoshi explains: why base-58 instead of standard base-64 encoding?
However, note that the encoding/decoding runs in O(n²) time, so it is not useful for large data.
The basic idea of the encoding is to treat the data bytes as a large number represented using base-256 digits, convert the number to be represented using base-58 digits, preserve the exact number of leading zeros (which are otherwise lost during the mathematical operations on the numbers), and finally represent the resulting base-58 digits as alphanumeric ASCII characters.
Base64 encoding/decoding methods.
Base64 encoding/decoding methods.
Note: This will decode normal Base64 and the modified Base64 for URL variant. If you don't want this behavior then use Base64Strict or Base64URL directly.
Wrapper for Google Guava's Cache classes
This contains utility methods for scanning Classes or Files on the classpath.
This contains utility methods for scanning Classes or Files on the classpath.
Originally we used the classpath scanning functionality in the Spring Framework and then later switched to the Reflections library (https://code.google.com/p/reflections/) to avoid the dependency on Spring. At some point we ran into issues with the Reflections library not properly detecting classes so I ended up writing this as a replacement.
NOTE: Use at your own risk.
NOTE: Use at your own risk. We make no claim that any of this Crypto code is correct.
MD5/SHA1/SHA256 Helpers
Deprecated.
Deprecated. Prefer the fm.common.Base16 object
Collection of IO Utilities.
Collection of IO Utilities. Some implemented via Apache Commons IO
Helpers for parsing and working with IPv4 addresses
A helper for determining the java.lang.Integer.IntegerCache.high value (controlled by -XX:AutoBoxCacheMax)
A helper for determining the java.lang.Integer.IntegerCache.high value (controlled by -XX:AutoBoxCacheMax)
Originally from fm-serializer
This is the same as scala.collection.JavaConverters with a few additional methods.
This is the same as scala.collection.JavaConverters with a few additional methods.
Specifically you can now call .asScalaNullToEmpty to have null java collections converted to an empty collection to avoid NullPointerExceptions
This has SLF4J/Logback Helpers that depend on SLF4j/Logback
This has SLF4J/Logback Helpers that depend on SLF4j/Logback
TODO: Clean this up!!
Provides cached instances of Boolean/Char/Byte/Int/Long wrapped in Scala's Option type to avoid boxing and allocations for commonly used values.
Provides cached instances of Boolean/Char/Byte/Int/Long wrapped in Scala's Option type to avoid boxing and allocations for commonly used values. Similar to how the JDK Integer cache works
Caching behavior per type:
Boolean - true/false cached Byte - All bytes cached (0 to 255) Char - All ASCII chars cached Int - Defaults to -XX:AutoBoxCacheMax range, can override with fm.common.IntegerCache.low/fm.common.IntegerCache.high properties Long - Defaults to -XX:AutoBoxCacheMax range, can override with fm.common.IntegerCache.low/fm.common.IntegerCache.high properties
Punycode as defined in From: https://tools.ietf.org/html/rfc3492
Implicits that go along with the Serializer trait
Simple wrappers for the java.net.URI constructors
Simple wrappers for the java.net.URL constructors
This is a marker Charset that is used to write out UTF-8 BOM encoding in OutputStreamResource
This is a marker Charset that is used to write out UTF-8 BOM encoding in OutputStreamResource
Originally I attempted to have the Charset directly encode the BOM (like the UTF-16 Charsets) but ran into problems with not being able to call into protected methods of the UTF-8 Charset implementation and did not want to copy/paste a bunch of code and/or implement a bunch of hacks to make it work properly.
An empty resource
Used to swallow unused warnings.
Used to swallow unused warnings.