org.schemarepo
Class RepositoryUtil

java.lang.Object
  extended by org.schemarepo.RepositoryUtil

public final class RepositoryUtil
extends Object

RepositoryUtil contains static helper methods for the org.schemarepo package.

subjectsToString(Iterable) and subjectNamesFromString(String) can be used to encode subjects to string format.
schemasToString(Iterable) and schemasFromString(String) can be used to encode schemas to string format.

These formats simply delimit items by the newline character and can be used for human readable output. The RESTRepository uses this format to encode subjects and schemas over HTTP. Subject names are forbidden from containing whitespace. Schemas have their whitespace removed prior to use in the Repository.


Method Summary
static String commaJoin(Collection<String> strings)
           
static List<String> commaSplit(String toSplit)
          Helper method for splitting a string by a delimiter with java.util.String.split().
static SubjectConfig configFromProperties(Properties props)
          Returns an immutable Map from the properties provided.
static String propertiesToString(Properties props, String comment)
          Converts properties to string representation
static SubjectConfig safeConfig(SubjectConfig config)
          temporary until we have decided how to deal with null configs or create a SubjectConfig class
static Iterable<SchemaEntry> schemasFromString(String str)
          Decode a string created by schemasToString(Iterable)
static String schemasToString(Iterable<SchemaEntry> allEntries)
          Encode SchemaEntry objects into a String for use by schemasFromString(String)
static Iterable<String> subjectNamesFromString(String str)
          Decode a string created by subjectsToString(Iterable)
static String subjectsToString(Iterable<Subject> subjects)
          Encode Subjects into a String for use by subjectNamesFromString(String)
static void validateSchemaOrSubject(String val)
          Throws IllegalArgumentException if the string provided is null, or empty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

subjectsToString

public static String subjectsToString(Iterable<Subject> subjects)
Encode Subjects into a String for use by subjectNamesFromString(String)

Parameters:
subjects - the Subject objects to encode
Returns:
The Subject objects encoded as a String

subjectNamesFromString

public static Iterable<String> subjectNamesFromString(String str)
Decode a string created by subjectsToString(Iterable)

Parameters:
str - The String to decode
Returns:
an Iterable of Subject

schemasToString

public static String schemasToString(Iterable<SchemaEntry> allEntries)
Encode SchemaEntry objects into a String for use by schemasFromString(String)

Parameters:
allEntries - the SchemaEntry objects to encode
Returns:
The SchemaEntry objects encoded as a String

schemasFromString

public static Iterable<SchemaEntry> schemasFromString(String str)
Decode a string created by schemasToString(Iterable)

Parameters:
str - The String to decode
Returns:
An Iterable of SchemaEntry

validateSchemaOrSubject

public static void validateSchemaOrSubject(String val)
Throws IllegalArgumentException if the string provided is null, or empty.


configFromProperties

public static SubjectConfig configFromProperties(Properties props)
Returns an immutable Map from the properties provided. Includes any default values that exist in the properties.


safeConfig

public static SubjectConfig safeConfig(SubjectConfig config)
temporary until we have decided how to deal with null configs or create a SubjectConfig class


commaSplit

public static List<String> commaSplit(String toSplit)
Helper method for splitting a string by a delimiter with java.util.String.split(). Omits empty values.

Parameters:
toSplit - The string to split. If null, an empty String[] is returned
Returns:
A String[] containing the non-empty values resulting from the split. Does not return null.

commaJoin

public static String commaJoin(Collection<String> strings)

propertiesToString

public static String propertiesToString(Properties props,
                                        String comment)
Converts properties to string representation

Parameters:
props -
comment - optional comment (can be null)
Returns:
String (standard key=value format)


Copyright © 2015. All rights reserved.