text:
package hostport

import (
	"bytes"
	"fmt"
	"net"
	"strings"

	utiliptables "k8s.io/kubernetes/pkg/util/iptables"
)

type fakeChain struct {
	name  utiliptables.Chain
	rules []string
}

type fakeTable struct {
	name   utiliptables.Table
	chains map[string]*fakeChain
}

type fakeIPTables struct {
	tables map[string]*fakeTable
}

func NewFakeIPTables() *fakeIPTables {
	return &fakeIPTables{
		tables: make(map[string]*fakeTable, 0),
	}
}

func (f *fakeIPTables) GetVersion() (string, error) {
	return "1.4.21", nil
}

func (f *fakeIPTables) getTable(tableName utiliptables.Table) (*fakeTable, error) {
	table, ok := f.tables[string(tableName)]
	if !ok {
		return nil, fmt.Errorf("Table %s does not exist", tableName)
	}
	return table, nil
}

func (f *fakeIPTables) getChain(tableName utiliptables.Table, chainName utiliptables.Chain) (*fakeTable, *fakeChain, error) {
	table, err := f.getTable(tableName)
	if err != nil {
		return nil, nil, err
	}

	chain, ok := table.chains[string(chainName)]
	if !ok {
		return table, nil, fmt.Errorf("Chain %s/%s does not exist", tableName, chainName)
	}

	return table, chain, nil
}

func (f *fakeIPTables) ensureChain(tableName utiliptables.Table, chainName utiliptables.Chain) (bool, *fakeChain) {
	table, chain, err := f.getChain(tableName, chainName)
	if err != nil {
		// either table or table+chain don't exist yet
		if table == nil {
			table = &fakeTable{
				name:   tableName,
				chains: make(map[string]*fakeChain),
			}
			f.tables[string(tableName)] = table
		}
		chain := &fakeChain{
			name:  chainName,
			rules: make([]string, 0),
		}
		table.chains[string(chainName)] = chain
		return false, chain
	}
	return true, chain
}

func (f *fakeIPTables) EnsureChain(tableName utiliptables.Table, chainName utiliptables.Chain) (bool, error) {
	existed, _ := f.ensureChain(tableName, chainName)
	return existed, nil
}

func (f *fakeIPTables) FlushChain(tableName utiliptables.Table, chainName utiliptables.Chain) error {
	_, chain, err := f.getChain(tableName, chainName)
	if err != nil {
		return err
	}
	chain.rules = make([]string, 0)
	return nil
}

func (f *fakeIPTables) DeleteChain(tableName utiliptables.Table, chainName utiliptables.Chain) error {
	table, _, err := f.getChain(tableName, chainName)
	if err != nil {
		return err
	}
	delete(table.chains, string(chainName))
	return nil
}

// Returns index of rule in array; < 0 if rule is not found
func findRule(chain *fakeChain, rule string) int {
	for i, candidate := range chain.rules {
		if rule == candidate {
			return i
		}
	}
	return -1
}

func (f *fakeIPTables) ensureRule(position utiliptables.RulePosition, tableName utiliptables.Table, chainName utiliptables.Chain, rule string) (bool, error) {
	_, chain, err := f.getChain(tableName, chainName)
	if err != nil {
		_, chain = f.ensureChain(tableName, chainName)
	}

	rule, err = normalizeRule(rule)
	if err != nil {
		return false, err
	}
	ruleIdx := findRule(chain, rule)
	if ruleIdx >= 0 {
		return true, nil
	}

	if position == utiliptables.Prepend {
		chain.rules = append([]string{rule}, chain.rules...)
	} else if position == utiliptables.Append {
		chain.rules = append(chain.rules, rule)
	} else {
		return false, fmt.Errorf("Unknown position argument %q", position)
	}

	return false, nil
}

func normalizeRule(rule string) (string, error) {
	normalized := ""
	remaining := strings.TrimSpace(rule)
	for {
		var end int

		if strings.HasPrefix(remaining, "--to-destination=") {
			remaining = strings.Replace(remaining, "=", " ", 1)
		}

		if remaining[0] == '"' {
			end = strings.Index(remaining[1:], "\"")
			if end < 0 {
				return "", fmt.Errorf("Invalid rule syntax: mismatched quotes")
			}
			end += 2
		} else {
			end = strings.Index(remaining, " ")
			if end < 0 {
				end = len(remaining)
			}
		}
		arg := remaining[:end]

		// Normalize un-prefixed IP addresses like iptables does
		if net.ParseIP(arg) != nil {
			arg = arg + "/32"
		}

		if len(normalized) > 0 {
			normalized += " "
		}
		normalized += strings.TrimSpace(arg)
		if len(remaining) == end {
			break
		}
		remaining = remaining[end+1:]
	}
	return normalized, nil
}

func (f *fakeIPTables) EnsureRule(position utiliptables.RulePosition, tableName utiliptables.Table, chainName utiliptables.Chain, args ...string) (bool, error) {
	ruleArgs := make([]string, 0)
	for _, arg := range args {
		// quote args with internal spaces (like comments)
		if strings.Index(arg, " ") >= 0 {
			arg = fmt.Sprintf("\"%s\"", arg)
		}
		ruleArgs = append(ruleArgs, arg)
	}
	return f.ensureRule(position, tableName, chainName, strings.Join(ruleArgs, " "))
}

func (f *fakeIPTables) DeleteRule(tableName utiliptables.Table, chainName utiliptables.Chain, args ...string) error {
	_, chain, err := f.getChain(tableName, chainName)
	if err == nil {
		rule := strings.Join(args, " ")
		ruleIdx := findRule(chain, rule)
		if ruleIdx < 0 {
			return nil
		}
		chain.rules = append(chain.rules[:ruleIdx], chain.rules[ruleIdx+1:]...)
	}
	return nil
}

func (f *fakeIPTables) IsIpv6() bool {
	return false
}

func saveChain(chain *fakeChain, data *bytes.Buffer) {
	for _, rule := range chain.rules {
		data.WriteString(fmt.Sprintf("-A %s %s\n", chain.name, rule))
	}
}

func (f *fakeIPTables) Save(tableName utiliptables.Table) ([]byte, error) {
	data := bytes.NewBuffer(nil)
	err := f.SaveInto(tableName, data)
	return data.Bytes(), err
}

func (f *fakeIPTables) SaveInto(tableName utiliptables.Table, buffer *bytes.Buffer) error {
	table, err := f.getTable(tableName)
	if err != nil {
		return err
	}

	buffer.WriteString(fmt.Sprintf("*%s\n", table.name))

	rules := bytes.NewBuffer(nil)
	for _, chain := range table.chains {
		buffer.WriteString(fmt.Sprintf(":%s - [0:0]\n", string(chain.name)))
		saveChain(chain, rules)
	}
	buffer.Write(rules.Bytes())
	buffer.WriteString("COMMIT\n")
	return nil
}

func (f *fakeIPTables) restore(restoreTableName utiliptables.Table, data []byte, flush utiliptables.FlushFlag) error {
	buf := bytes.NewBuffer(data)
	var tableName utiliptables.Table
	for {
		line, err := buf.ReadString('\n')
		if err != nil {
			break
		}
		if line[0] == '#' {
			continue
		}

		line = strings.TrimSuffix(line, "\n")
		if strings.HasPrefix(line, "*") {
			tableName = utiliptables.Table(line[1:])
		}
		if tableName != "" {
			if restoreTableName != "" && restoreTableName != tableName {
				continue
			}
			if strings.HasPrefix(line, ":") {
				chainName := utiliptables.Chain(strings.Split(line[1:], " ")[0])
				if flush == utiliptables.FlushTables {
					table, chain, _ := f.getChain(tableName, chainName)
					if chain != nil {
						delete(table.chains, string(chainName))
					}
				}
				_, _ = f.ensureChain(tableName, chainName)
			} else if strings.HasPrefix(line, "-A") {
				parts := strings.Split(line, " ")
				if len(parts) < 3 {
					return fmt.Errorf("Invalid iptables rule '%s'", line)
				}
				chainName := utiliptables.Chain(parts[1])
				rule := strings.TrimPrefix(line, fmt.Sprintf("-A %s ", chainName))
				_, err := f.ensureRule(utiliptables.Append, tableName, chainName, rule)
				if err != nil {
					return err
				}
			} else if strings.HasPrefix(line, "-I") {
				parts := strings.Split(line, " ")
				if len(parts) < 3 {
					return fmt.Errorf("Invalid iptables rule '%s'", line)
				}
				chainName := utiliptables.Chain(parts[1])
				rule := strings.TrimPrefix(line, fmt.Sprintf("-I %s ", chainName))
				_, err := f.ensureRule(utiliptables.Prepend, tableName, chainName, rule)
				if err != nil {
					return err
				}
			} else if strings.HasPrefix(line, "-X") {
				parts := strings.Split(line, " ")
				if len(parts) < 2 {
					return fmt.Errorf("Invalid iptables rule '%s'", line)
				}
				if err := f.DeleteChain(tableName, utiliptables.Chain(parts[1])); err != nil {
					return err
				}
			} else if line == "COMMIT" {
				if restoreTableName == tableName {
					return nil
				}
				tableName = ""
			}
		}
	}

	return nil
}

func (f *fakeIPTables) Restore(tableName utiliptables.Table, data []byte, flush utiliptables.FlushFlag, counters utiliptables.RestoreCountersFlag) error {
	return f.restore(tableName, data, flush)
}

func (f *fakeIPTables) RestoreAll(data []byte, flush utiliptables.FlushFlag, counters utiliptables.RestoreCountersFlag) error {
	return f.restore("", data, flush)
}

func (f *fakeIPTables) AddReloadFunc(reloadFunc func()) {
}

func (f *fakeIPTables) Destroy() {
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<TITLE>
Index (SKR REST API)
</TITLE>

<META NAME="date" CONTENT="2011-04-12">

<LINK REL ="stylesheet" TYPE="text/css" HREF="./stylesheet.css" TITLE="Style">

      Package
      Class
      Use
      Tree
      Deprecated
    Index
      Help

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes

A B C D E G H I J K L M N O P Q R S T U V W

A

accumulate(String, Object) -
Method in class org.json.JSONObject

Accumulate values under a key.

append(String, Object) -
Method in class org.json.JSONObject

Append values to the array under a key.

append(String) -
Method in class org.json.JSONWriter

Append a value.

array() -
Method in class org.json.JSONWriter

Begin appending a new array.

B

back() -
Method in class org.json.JSONTokener

Back up one character.

C

cause -
Variable in exception org.json.JSONException

character -
Variable in class org.json.JSONTokener

clone() -
Method in class org.json.JSONObject.Null

There is only intended to be a single instance of the NULL object,
 so the clone method returns itself.

comma -
Variable in class org.json.JSONWriter

The comma flag determines if a comma should be output before the next
 value.

D

dehexchar(char) -
Static method in class org.json.JSONTokener

Get the hex value of a character (base16).

doubleToString(double) -
Static method in class org.json.JSONObject

Produce a string from a double.

E

end() -
Method in class org.json.JSONTokener

end(char, char) -
Method in class org.json.JSONWriter

End something.

endArray() -
Method in class org.json.JSONWriter

End an array.

endObject() -
Method in class org.json.JSONWriter

End an object.

eof -
Variable in class org.json.JSONTokener

equals(Object) -
Method in class org.json.JSONObject.Null

A Null object is equal to the null value and to itself.

G

get(int) -
Method in class org.json.JSONArray

Get the object value associated with an index.

get(String) -
Method in class org.json.JSONObject

Get the value object associated with a key.

getBoolean(int) -
Method in class org.json.JSONArray

Get the boolean value associated with an index.

getBoolean(String) -
Method in class org.json.JSONObject

Get the boolean value associated with a key.

getCause() -
Method in exception org.json.JSONException

getDouble(int) -
Method in class org.json.JSONArray

Get the double value associated with an index.

getDouble(String) -
Method in class org.json.JSONObject

Get the double value associated with a key.

getInt(int) -
Method in class org.json.JSONArray

Get the int value associated with an index.

getInt(String) -
Method in class org.json.JSONObject

Get the int value associated with a key.

getJSONArray(int) -
Method in class org.json.JSONArray

Get the JSONArray associated with an index.

getJSONArray(String) -
Method in class org.json.JSONObject

Get the JSONArray value associated with a key.

getJSONObject(int) -
Method in class org.json.JSONArray

Get the JSONObject associated with an index.

getJSONObject(String) -
Method in class org.json.JSONObject

Get the JSONObject value associated with a key.

getLong(int) -
Method in class org.json.JSONArray

Get the long value associated with an index.

getLong(String) -
Method in class org.json.JSONObject

Get the long value associated with a key.

getNames(JSONObject) -
Static method in class org.json.JSONObject

Get an array of field names from a JSONObject.

getNames(Object) -
Static method in class org.json.JSONObject

Get an array of field names from an Object.

getString(int) -
Method in class org.json.JSONArray

Get the string associated with an index.

getString(String) -
Method in class org.json.JSONObject

Get the string associated with a key.

H

has(String) -
Method in class org.json.JSONObject

Determine if the JSONObject contains a specific key.

I

increment(String) -
Method in class org.json.JSONObject

Increment a property of a JSONObject.

index -
Variable in class org.json.JSONTokener

isNull(int) -
Method in class org.json.JSONArray

Determine if the value is null.

isNull(String) -
Method in class org.json.JSONObject

Determine if the value associated with the key is null or if there is
  no value.

J

join(String) -
Method in class org.json.JSONArray

Make a string from the contents of this JSONArray.

JSONArray - Class in org.json
A JSONArray is an ordered sequence of values.
JSONArray() -
Constructor for class org.json.JSONArray

Construct an empty JSONArray.

JSONArray(JSONTokener) -
Constructor for class org.json.JSONArray

Construct a JSONArray from a JSONTokener.

JSONArray(String) -
Constructor for class org.json.JSONArray

Construct a JSONArray from a source JSON text.

JSONArray(Collection) -
Constructor for class org.json.JSONArray

Construct a JSONArray from a Collection.

JSONArray(Object) -
Constructor for class org.json.JSONArray

Construct a JSONArray from an array

JSONException - Exception in org.json
The JSONException is thrown by the JSON.org classes when things are amiss.
JSONException(String) -
Constructor for exception org.json.JSONException

Constructs a JSONException with an explanatory message.

JSONException(Throwable) -
Constructor for exception org.json.JSONException

JSONObject - Class in org.json
A JSONObject is an unordered collection of name/value pairs.
JSONObject() -
Constructor for class org.json.JSONObject

Construct an empty JSONObject.

JSONObject(JSONObject, String[]) -
Constructor for class org.json.JSONObject

Construct a JSONObject from a subset of another JSONObject.

JSONObject(JSONTokener) -
Constructor for class org.json.JSONObject

Construct a JSONObject from a JSONTokener.

JSONObject(Map) -
Constructor for class org.json.JSONObject

Construct a JSONObject from a Map.

JSONObject(Object) -
Constructor for class org.json.JSONObject

Construct a JSONObject from an Object using bean getters.

JSONObject(Object, String[]) -
Constructor for class org.json.JSONObject

Construct a JSONObject from an Object, using reflection to find the
 public members.

JSONObject(String) -
Constructor for class org.json.JSONObject

Construct a JSONObject from a source JSON text string.

JSONObject(String, Locale) -
Constructor for class org.json.JSONObject

Construct a JSONObject from a ResourceBundle.

JSONObject.Null - Class in org.json
JSONObject.NULL is equivalent to the value that JavaScript calls null,
 whilst Java's null is equivalent to the value that JavaScript calls
 undefined.
JSONObject.Null() -
Constructor for class org.json.JSONObject.Null

JSONString - Interface in org.json
The JSONString interface allows a toJSONString()
 method so that a class can change the behavior of
 JSONObject.toString(), JSONArray.toString(),
 and JSONWriter.value(Object).
JSONStringer - Class in org.json
JSONStringer provides a quick and convenient way of producing JSON text.
JSONStringer() -
Constructor for class org.json.JSONStringer

Make a fresh JSONStringer.

JSONTokener - Class in org.json
A JSONTokener takes a source string and extracts characters and tokens from
 it.
JSONTokener(Reader) -
Constructor for class org.json.JSONTokener

Construct a JSONTokener from a Reader.

JSONTokener(InputStream) -
Constructor for class org.json.JSONTokener

Construct a JSONTokener from an InputStream.

JSONTokener(String) -
Constructor for class org.json.JSONTokener

Construct a JSONTokener from a string.

JSONWriter - Class in org.json
JSONWriter provides a quick and convenient way of producing JSON text.
JSONWriter(Writer) -
Constructor for class org.json.JSONWriter

Make a fresh JSONWriter.

K

key(String) -
Method in class org.json.JSONWriter

Append a key.

keys() -
Method in class org.json.JSONObject

Get an enumeration of the keys of the JSONObject.

L

length() -
Method in class org.json.JSONArray

Get the number of elements in the JSONArray, included nulls.

length() -
Method in class org.json.JSONObject

Get the number of keys stored in the JSONObject.

line -
Variable in class org.json.JSONTokener

M

map -
Variable in class org.json.JSONObject

The map where the JSONObject's properties are kept.

maxdepth -
Static variable in class org.json.JSONWriter

mode -
Variable in class org.json.JSONWriter

The current mode.

more() -
Method in class org.json.JSONTokener

Determine if the source string still contains characters that next()
 can consume.

myArrayList -
Variable in class org.json.JSONArray

The arrayList where the JSONArray's properties are kept.

N

names() -
Method in class org.json.JSONObject

Produce a JSONArray containing the names of the elements of this
 JSONObject.

next() -
Method in class org.json.JSONTokener

Get the next character in the source string.

next(char) -
Method in class org.json.JSONTokener

Consume the next character, and check that it matches a specified
 character.

next(int) -
Method in class org.json.JSONTokener

Get the next n characters.

nextClean() -
Method in class org.json.JSONTokener

Get the next char in the string, skipping whitespace.

nextString(char) -
Method in class org.json.JSONTokener

Return the characters up to the next close quote character.

nextTo(char) -
Method in class org.json.JSONTokener

Get the text up but not including the specified character or the
 end of line, whichever comes first.

nextTo(String) -
Method in class org.json.JSONTokener

Get the text up but not including one of the specified delimiter
 characters or the end of line, whichever comes first.

nextValue() -
Method in class org.json.JSONTokener

Get the next value.

NULL -
Static variable in class org.json.JSONObject

It is sometimes more convenient and less ambiguous to have a
 NULL object than to use Java's null value.

numberToString(Number) -
Static method in class org.json.JSONObject

Produce a string from a Number.

O

object() -
Method in class org.json.JSONWriter

Begin appending a new object.

opt(int) -
Method in class org.json.JSONArray

Get the optional object value associated with an index.

opt(String) -
Method in class org.json.JSONObject

Get an optional value associated with a key.

optBoolean(int) -
Method in class org.json.JSONArray

Get the optional boolean value associated with an index.

optBoolean(int, boolean) -
Method in class org.json.JSONArray

Get the optional boolean value associated with an index.

optBoolean(String) -
Method in class org.json.JSONObject

Get an optional boolean associated with a key.

optBoolean(String, boolean) -
Method in class org.json.JSONObject

Get an optional boolean associated with a key.

optDouble(int) -
Method in class org.json.JSONArray

Get the optional double value associated with an index.

optDouble(int, double) -
Method in class org.json.JSONArray

Get the optional double value associated with an index.

optDouble(String) -
Method in class org.json.JSONObject

Get an optional double associated with a key,
 or NaN if there is no such key or if its value is not a number.

optDouble(String, double) -
Method in class org.json.JSONObject

Get an optional double associated with a key, or the
 defaultValue if there is no such key or if its value is not a number.

optInt(int) -
Method in class org.json.JSONArray

Get the optional int value associated with an index.

optInt(int, int) -
Method in class org.json.JSONArray

Get the optional int value associated with an index.

optInt(String) -
Method in class org.json.JSONObject

Get an optional int value associated with a key,
 or zero if there is no such key or if the value is not a number.

optInt(String, int) -
Method in class org.json.JSONObject

Get an optional int value associated with a key,
 or the default if there is no such key or if the value is not a number.

optJSONArray(int) -
Method in class org.json.JSONArray

Get the optional JSONArray associated with an index.

optJSONArray(String) -
Method in class org.json.JSONObject

Get an optional JSONArray associated with a key.

optJSONObject(int) -
Method in class org.json.JSONArray

Get the optional JSONObject associated with an index.

optJSONObject(String) -
Method in class org.json.JSONObject

Get an optional JSONObject associated with a key.

optLong(int) -
Method in class org.json.JSONArray

Get the optional long value associated with an index.

optLong(int, long) -
Method in class org.json.JSONArray

Get the optional long value associated with an index.

optLong(String) -
Method in class org.json.JSONObject

Get an optional long value associated with a key,
 or zero if there is no such key or if the value is not a number.

optLong(String, long) -
Method in class org.json.JSONObject

Get an optional long value associated with a key,
 or the default if there is no such key or if the value is not a number.

optString(int) -
Method in class org.json.JSONArray

Get the optional string value associated with an index.

optString(int, String) -
Method in class org.json.JSONArray

Get the optional string associated with an index.

optString(String) -
Method in class org.json.JSONObject

Get an optional string associated with a key.

optString(String, String) -
Method in class org.json.JSONObject

Get an optional string associated with a key.

org.json - package org.json

P

pop(char) -
Method in class org.json.JSONWriter

Pop an array or object scope.

populateMap(Object) -
Method in class org.json.JSONObject

previous -
Variable in class org.json.JSONTokener

push(JSONObject) -
Method in class org.json.JSONWriter

Push an array or object scope.

put(boolean) -
Method in class org.json.JSONArray

Append a boolean value.

put(Collection) -
Method in class org.json.JSONArray

Put a value in the JSONArray, where the value will be a
 JSONArray which is produced from a Collection.

put(double) -
Method in class org.json.JSONArray

Append a double value.

put(int) -
Method in class org.json.JSONArray

Append an int value.

put(long) -
Method in class org.json.JSONArray

Append an long value.

put(Map) -
Method in class org.json.JSONArray

Put a value in the JSONArray, where the value will be a
 JSONObject which is produced from a Map.

put(Object) -
Method in class org.json.JSONArray

Append an object value.

put(int, boolean) -
Method in class org.json.JSONArray

Put or replace a boolean value in the JSONArray.

put(int, Collection) -
Method in class org.json.JSONArray

Put a value in the JSONArray, where the value will be a
 JSONArray which is produced from a Collection.

put(int, double) -
Method in class org.json.JSONArray

Put or replace a double value.

put(int, int) -
Method in class org.json.JSONArray

Put or replace an int value.

put(int, long) -
Method in class org.json.JSONArray

Put or replace a long value.

put(int, Map) -
Method in class org.json.JSONArray

Put a value in the JSONArray, where the value will be a
 JSONObject which is produced from a Map.

put(int, Object) -
Method in class org.json.JSONArray

Put or replace an object value in the JSONArray.

put(String, boolean) -
Method in class org.json.JSONObject

Put a key/boolean pair in the JSONObject.

put(String, Collection) -
Method in class org.json.JSONObject

Put a key/value pair in the JSONObject, where the value will be a
 JSONArray which is produced from a Collection.

put(String, double) -
Method in class org.json.JSONObject

Put a key/double pair in the JSONObject.

put(String, int) -
Method in class org.json.JSONObject

Put a key/int pair in the JSONObject.

put(String, long) -
Method in class org.json.JSONObject

Put a key/long pair in the JSONObject.

put(String, Map) -
Method in class org.json.JSONObject

Put a key/value pair in the JSONObject, where the value will be a
 JSONObject which is produced from a Map.

put(String, Object) -
Method in class org.json.JSONObject

Put a key/value pair in the JSONObject.

putOnce(String, Object) -
Method in class org.json.JSONObject

Put a key/value pair in the JSONObject, but only if the key and the
 value are both non-null, and only if there is not already a member
 with that name.

putOpt(String, Object) -
Method in class org.json.JSONObject

Put a key/value pair in the JSONObject, but only if the
 key and the value are both non-null.

Q

quote(String) -
Static method in class org.json.JSONObject

Produce a string in double quotes with backslash sequences in all the
 right places.

R

reader -
Variable in class org.json.JSONTokener

remove(int) -
Method in class org.json.JSONArray

Remove an index and close the hole.

remove(String) -
Method in class org.json.JSONObject

Remove a name and its value, if present.

S

serialVersionUID -
Static variable in exception org.json.JSONException

skipTo(char) -
Method in class org.json.JSONTokener

Skip characters until the next character is the requested character.

stack -
Variable in class org.json.JSONWriter

The object/array stack.

stringToValue(String) -
Static method in class org.json.JSONObject

Try to convert a string into a number, boolean, or null.

syntaxError(String) -
Method in class org.json.JSONTokener

Make a JSONException to signal a syntax error.

T

testValidity(Object) -
Static method in class org.json.JSONObject

Throw an exception if the object is a NaN or infinite number.

toJSONArray(JSONArray) -
Method in class org.json.JSONObject

Produce a JSONArray containing the values of the members of this
 JSONObject.

toJSONObject(JSONArray) -
Method in class org.json.JSONArray

Produce a JSONObject by combining a JSONArray of names with the values
 of this JSONArray.

toJSONString() -
Method in interface org.json.JSONString

The toJSONString method allows a class to produce its own JSON
 serialization.

top -
Variable in class org.json.JSONWriter

The stack top index.

toString() -
Method in class org.json.JSONArray

Make a JSON text of this JSONArray.

toString(int) -
Method in class org.json.JSONArray

Make a prettyprinted JSON text of this JSONArray.

toString(int, int) -
Method in class org.json.JSONArray

Make a prettyprinted JSON text of this JSONArray.

toString() -
Method in class org.json.JSONObject.Null

Get the "null" string value.

toString() -
Method in class org.json.JSONObject

Make a JSON text of this JSONObject.

toString(int) -
Method in class org.json.JSONObject

Make a prettyprinted JSON text of this JSONObject.

toString(int, int) -
Method in class org.json.JSONObject

Make a prettyprinted JSON text of this JSONObject.

toString() -
Method in class org.json.JSONStringer

Return the JSON text.

toString() -
Method in class org.json.JSONTokener

Make a printable string of this JSONTokener.

U

usePrevious -
Variable in class org.json.JSONTokener

V

value(boolean) -
Method in class org.json.JSONWriter

Append either the value true or the value
 false.

value(double) -
Method in class org.json.JSONWriter

Append a double value.

value(long) -
Method in class org.json.JSONWriter

Append a long value.

value(Object) -
Method in class org.json.JSONWriter

Append an object value.

valueToString(Object) -
Static method in class org.json.JSONObject

Make a JSON text of an Object value.

valueToString(Object, int, int) -
Static method in class org.json.JSONObject

Make a prettyprinted JSON text of an object value.

W

wrap(Object) -
Static method in class org.json.JSONObject

Wrap an object, if necessary.

write(Writer) -
Method in class org.json.JSONArray

Write the contents of the JSONArray as JSON text to a writer.

write(Writer) -
Method in class org.json.JSONObject

Write the contents of the JSONObject as JSON text to a writer.

writer -
Variable in class org.json.JSONWriter

The writer that will receive the output.

A B C D E G H I J K L M N O P Q R S T U V W

      Package
      Class
      Use
      Tree
      Deprecated
    Index
      Help

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes

NLS Projects

redpajama_set_name: RedPajamaGithub


text:
export XOS_DIR=/opt/xos
cp /root/setup/node_key $XOS_DIR/synchronizers/vtr/node_key
chmod 0600 $XOS_DIR/synchronizers/vtr/node_key
python vtr-synchronizer.py  -C $XOS_DIR/synchronizers/vtr/vtn_vtr_synchronizer_config


text: You want [`elm-lang/http`](https://github.com/elm-lang/http) instead.


text:
/*
 * Copyright (C) 2008 The Android Open Source Project
 *
 * 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
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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.
 */

package java.lang;

import dalvik.system.PathClassLoader;
import dalvik.system.VMStack;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.ByteBuffer;
import java.security.ProtectionDomain;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

/**
 * Loads classes and resources from a repository. One or more class loaders are
 * installed at runtime. These are consulted whenever the runtime system needs a
 * specific class that is not yet available in-memory. Typically, class loaders
 * are grouped into a tree where child class loaders delegate all requests to
 * parent class loaders. Only if the parent class loader cannot satisfy the
 * request, the child class loader itself tries to handle it.
 *

 * {@code ClassLoader} is an abstract class that implements the common
 * infrastructure required by all class loaders. Android provides several
 * concrete implementations of the class, with
 * {@link dalvik.system.PathClassLoader} being the one typically used. Other
 * applications may implement subclasses of {@code ClassLoader} to provide
 * special ways for loading classes.
 *

 * @see Class
 */
public abstract class ClassLoader {

    // BEGIN android-note
    /*
     * Because of a potential class initialization race between ClassLoader and
     * java.lang.System, reproducible when using JDWP with "suspend=y", we defer
     * creation of the system class loader until first use. We use a static
     * inner class to get synchronization at init time without having to sync on
     * every access.
     */
    // END android-note
    /**
     * The 'System' ClassLoader - the one that is responsible for loading
     * classes from the classpath. It is not equal to the bootstrap class loader -
     * that one handles the built-in classes.
     *
     * @see #getSystemClassLoader()
     */
    static private class SystemClassLoader {
        public static ClassLoader loader = ClassLoader.createSystemClassLoader();
    }

    /**
     * The parent ClassLoader.
     */
    private ClassLoader parent;

    /**
     * The packages known to the class loader.
     */
    private Map<String, Package> packages = new HashMap<String, Package>();

    /**
     * Create the system class loader. Note this is NOT the bootstrap class
     * loader (which is managed by the VM). We use a null value for the parent
     * to indicate that the bootstrap loader is our parent.
     */
    private static ClassLoader createSystemClassLoader() {
        String classPath = System.getProperty("java.class.path", ".");

        // String[] paths = classPath.split(":");
        // URL[] urls = new URL[paths.length];
        // for (int i = 0; i < paths.length; i++) {
        // try {
        // urls[i] = new URL("file://" + paths[i]);
        // }
        // catch (Exception ex) {
        // ex.printStackTrace();
        // }
        // }
        //
        // return new java.net.URLClassLoader(urls, null);

        // TODO Make this a java.net.URLClassLoader once we have those?
        return new PathClassLoader(classPath, BootClassLoader.getInstance());
    }

    /**
     * Returns the system class loader. This is the parent for new
     * {@code ClassLoader} instances and is typically the class loader used to
     * start the application. If a security manager is present and the caller's
     * class loader is neither {@code null} nor the same as or an ancestor of
     * the system class loader, then this method calls the security manager's
     * checkPermission method with a RuntimePermission("getClassLoader")
     * permission to ensure that it is ok to access the system class loader. If
     * not, a {@code SecurityException} is thrown.
     *
     * @return the system class loader.
     * @throws SecurityException
     *             if a security manager exists and it does not allow access to
     *             the system class loader.
     */
    public static ClassLoader getSystemClassLoader() {
        SecurityManager smgr = System.getSecurityManager();
        if (smgr != null) {
            ClassLoader caller = VMStack.getCallingClassLoader();
            if (caller != null && !caller.isAncestorOf(SystemClassLoader.loader)) {
                smgr.checkPermission(new RuntimePermission("getClassLoader"));
            }
        }

        return SystemClassLoader.loader;
    }

    /**
     * Finds the URL of the resource with the specified name. The system class
     * loader's resource lookup algorithm is used to find the resource.
     *
     * @return the {@code URL} object for the requested resource or {@code null}
     *         if the resource can not be found.
     * @param resName
     *            the name of the resource to find.
     * @see Class#getResource
     */
    public static URL getSystemResource(String resName) {
        return SystemClassLoader.loader.getResource(resName);
    }

    /**
     * Returns an enumeration of URLs for the resource with the specified name.
     * The system class loader's resource lookup algorithm is used to find the
     * resource.
     *
     * @return an enumeration of {@code URL} objects containing the requested
     *         resources.
     * @param resName
     *            the name of the resource to find.
     * @throws IOException
     *             if an I/O error occurs.
     */
    public static Enumeration<URL> getSystemResources(String resName) throws IOException {
        return SystemClassLoader.loader.getResources(resName);
    }

    /**
     * Returns a stream for the resource with the specified name. The system
     * class loader's resource lookup algorithm is used to find the resource.
     * Basically, the contents of the java.class.path are searched in order,
     * looking for a path which matches the specified resource.
     *
     * @return a stream for the resource or {@code null}.
     * @param resName
     *            the name of the resource to find.
     * @see Class#getResourceAsStream
     */
    public static InputStream getSystemResourceAsStream(String resName) {
        return SystemClassLoader.loader.getResourceAsStream(resName);
    }

    /**
     * Constructs a new instance of this class with the system class loader as
     * its parent.
     *
     * @throws SecurityException
     *             if a security manager exists and it does not allow the
     *             creation of a new {@code ClassLoader}.
     */
    protected ClassLoader() {
        this(getSystemClassLoader(), false);
    }

    /**
     * Constructs a new instance of this class with the specified class loader
     * as its parent.
     *
     * @param parentLoader
     *            The {@code ClassLoader} to use as the new class loader's
     *            parent.
     * @throws SecurityException
     *             if a security manager exists and it does not allow the
     *             creation of new a new {@code ClassLoader}.
     */
    protected ClassLoader(ClassLoader parentLoader) {
        this(parentLoader, false);
    }

    /*
     * constructor for the BootClassLoader which needs parent to be null.
     */
    ClassLoader(ClassLoader parentLoader, boolean nullAllowed) {
        SecurityManager smgr = System.getSecurityManager();
        if (smgr != null) {
            smgr.checkCreateClassLoader();
        }

        if (parentLoader == null && !nullAllowed) {
            throw new NullPointerException(
                    "Parent ClassLoader may not be null");
        }

        parent = parentLoader;
    }

    /**
     * Constructs a new class from an array of bytes containing a class
     * definition in class file format.
     *
     * @param classRep
     *            the memory image of a class file.
     * @param offset
     *            the offset into {@code classRep}.
     * @param length
     *            the length of the class file.
     * @return the {@code Class} object created from the specified subset of
     *         data in {@code classRep}.
     * @throws ClassFormatError
     *             if {@code classRep} does not contain a valid class.
     * @throws IndexOutOfBoundsException
     *             if {@code offset < 0}, {@code length < 0} or if
     *             {@code offset + length} is greater than the length of
     *             {@code classRep}.
     * @deprecated Use {@link #defineClass(String, byte[], int, int)}
     */
    @Deprecated
    protected final Class<?> defineClass(byte[] classRep, int offset, int length)
            throws ClassFormatError {

        return VMClassLoader.defineClass(this, classRep, offset, length, null);
    }

    /**
     * Constructs a new class from an array of bytes containing a class
     * definition in class file format.
     *
     * @param className
     *            the expected name of the new class, may be {@code null} if not
     *            known.
     * @param classRep
     *            the memory image of a class file.
     * @param offset
     *            the offset into {@code classRep}.
     * @param length
     *            the length of the class file.
     * @return the {@code Class} object created from the specified subset of
     *         data in {@code classRep}.
     * @throws ClassFormatError
     *             if {@code classRep} does not contain a valid class.
     * @throws IndexOutOfBoundsException
     *             if {@code offset < 0}, {@code length < 0} or if
     *             {@code offset + length} is greater than the length of
     *             {@code classRep}.
     */
    protected final Class<?> defineClass(String className, byte[] classRep, int offset, int length)
            throws ClassFormatError {

        // TODO Define a default ProtectionDomain on first use
        return defineClass(className, classRep, offset, length, null);
    }

    /**
     * Constructs a new class from an array of bytes containing a class
     * definition in class file format and assigns the specified protection
     * domain to the new class. If the provided protection domain is
     * {@code null} then a default protection domain is assigned to the class.
     *
     * @param className
     *            the expected name of the new class, may be {@code null} if not
     *            known.
     * @param classRep
     *            the memory image of a class file.
     * @param offset
     *            the offset into {@code classRep}.
     * @param length
     *            the length of the class file.
     * @param protectionDomain
     *            the protection domain to assign to the loaded class, may be
     *            {@code null}.
     * @return the {@code Class} object created from the specified subset of
     *         data in {@code classRep}.
     * @throws ClassFormatError
     *             if {@code classRep} does not contain a valid class.
     * @throws IndexOutOfBoundsException
     *             if {@code offset < 0}, {@code length < 0} or if
     *             {@code offset + length} is greater than the length of
     *             {@code classRep}.
     * @throws NoClassDefFoundError
     *             if {@code className} is not equal to the name of the class
     *             contained in {@code classRep}.
     */
    protected final Class<?> defineClass(String className, byte[] classRep, int offset, int length,
            ProtectionDomain protectionDomain) throws java.lang.ClassFormatError {

        return VMClassLoader.defineClass(this, className, classRep, offset, length,
                protectionDomain);
    }

    /**
     * Defines a new class with the specified name, byte code from the byte
     * buffer and the optional protection domain. If the provided protection
     * domain is {@code null} then a default protection domain is assigned to
     * the class.
     *
     * @param name
     *            the expected name of the new class, may be {@code null} if not
     *            known.
     * @param b
     *            the byte buffer containing the byte code of the new class.
     * @param protectionDomain
     *            the protection domain to assign to the loaded class, may be
     *            {@code null}.
     * @return the {@code Class} object created from the data in {@code b}.
     * @throws ClassFormatError
     *             if {@code b} does not contain a valid class.
     * @throws NoClassDefFoundError
     *             if {@code className} is not equal to the name of the class
     *             contained in {@code b}.
     */
    protected final Class<?> defineClass(String name, ByteBuffer b,
            ProtectionDomain protectionDomain) throws ClassFormatError {

        byte[] temp = new byte[b.remaining()];
        b.get(temp);
        return defineClass(name, temp, 0, temp.length, protectionDomain);
    }

    /**
     * Overridden by subclasses, throws a {@code ClassNotFoundException} by
     * default. This method is called by {@code loadClass} after the parent
     * {@code ClassLoader} has failed to find a loaded class of the same name.
     *
     * @param className
     *            the name of the class to look for.
     * @return the {@code Class} object that is found.
     * @throws ClassNotFoundException
     *             if the class cannot be found.
     */
    protected Class<?> findClass(String className) throws ClassNotFoundException {
        throw new ClassNotFoundException(className);
    }

    /**
     * Returns the class with the specified name if it has already been loaded
     * by the virtual machine or {@code null} if it has not yet been loaded.
     *
     * @param className
     *            the name of the class to look for.
     * @return the {@code Class} object or {@code null} if the requested class
     *         has not been loaded.
     */
    protected final Class<?> findLoadedClass(String className) {
        ClassLoader loader;
        if (this == BootClassLoader.getInstance())
            loader = null;
        else
            loader = this;
        return VMClassLoader.findLoadedClass(loader, className);
    }

    /**
     * Finds the class with the specified name, loading it using the system
     * class loader if necessary.
     *
     * @param className
     *            the name of the class to look for.
     * @return the {@code Class} object with the requested {@code className}.
     * @throws ClassNotFoundException
     *             if the class can not be found.
     */
    protected final Class<?> findSystemClass(String className) throws ClassNotFoundException {
        return Class.forName(className, false, getSystemClassLoader());
    }

    /**
     * Returns this class loader's parent.
     *
     * @return this class loader's parent or {@code null}.
     * @throws SecurityException
     *             if a security manager exists and it does not allow to
     *             retrieve the parent class loader.
     */
    public final ClassLoader getParent() {
        SecurityManager smgr = System.getSecurityManager();
        if (smgr != null) {
            smgr.checkPermission(new RuntimePermission("getClassLoader"));
        }

        return parent;
    }

    /**
     * Returns the URL of the resource with the specified name. This
     * implementation first tries to use the parent class loader to find the
     * resource; if this fails then {@link #findResource(String)} is called to
     * find the requested resource.
     *
     * @param resName
     *            the name of the resource to find.
     * @return the {@code URL} object for the requested resource or {@code null}
     *         if either the resource can not be found or a security manager
     *         does not allow to access the resource.
     * @see Class#getResource
     */
    public URL getResource(String resName) {
        URL resource = null;

        resource = parent.getResource(resName);

        if (resource == null) {
            resource = findResource(resName);
        }

        return resource;
    }

    /**
     * Returns an enumeration of URLs for the resource with the specified name.
     * This implementation first uses this class loader's parent to find the
     * resource, then it calls {@link #findResources(String)} to get additional
     * URLs. The returned enumeration contains the {@code URL} objects of both
     * find operations.
     *
     * @return an enumeration of {@code URL} objects for the requested resource.
     * @param resName
     *            the name of the resource to find.
     * @throws IOException
     *             if an I/O error occurs.
     */
    @SuppressWarnings("unchecked")
    public Enumeration<URL> getResources(String resName) throws IOException {

        Enumeration first = parent.getResources(resName);
        Enumeration second = findResources(resName);

        return new TwoEnumerationsInOne(first, second);
    }

    /**
     * Returns a stream for the resource with the specified name. See
     * {@link #getResource(String)} for a description of the lookup algorithm
     * used to find the resource.
     *
     * @return a stream for the resource or {@code null} if either the resource
     *         can not be found or a security manager does not allow to access
     *         the resource.
     * @param resName
     *            the name of the resource to find.
     * @see Class#getResourceAsStream
     */
    public InputStream getResourceAsStream(String resName) {
        try {
            URL url = getResource(resName);
            if (url != null) {
                return url.openStream();
            }
        } catch (IOException ex) {
            // Don't want to see the exception.
        }

        return null;
    }

    /**
     * Loads the class with the specified name. Invoking this method is
     * equivalent to calling {@code loadClass(className, false)}.
     *

     * Note: In the Android reference implementation, the
     * second parameter of {@link #loadClass(String, boolean)} is ignored
     * anyway.
     *

     *
     * @return the {@code Class} object.
     * @param className
     *            the name of the class to look for.
     * @throws ClassNotFoundException
     *             if the class can not be found.
     */
    public Class<?> loadClass(String className) throws ClassNotFoundException {
        return loadClass(className, false);
    }

    /**
     * Loads the class with the specified name, optionally linking it after
     * loading. The following steps are performed:
     *

     *
 Call {@link #findLoadedClass(String)} to determine if the requested
     * class has already been loaded.

     *
If the class has not yet been loaded: Invoke this method on the
     * parent class loader.

     *
If the class has still not been loaded: Call
     * {@link #findClass(String)} to find the class.

     *

     *

     * Note: In the Android reference implementation, the
     * {@code resolve} parameter is ignored; classes are never linked.
     *

     *
     * @return the {@code Class} object.
     * @param className
     *            the name of the class to look for.
     * @param resolve
     *            Indicates if the class should be resolved after loading. This
     *            parameter is ignored on the Android reference implementation;
     *            classes are not resolved.
     * @throws ClassNotFoundException
     *             if the class can not be found.
     */
    protected Class<?> loadClass(String className, boolean resolve) throws ClassNotFoundException {
        Class<?> clazz = findLoadedClass(className);

        if (clazz == null) {
            try {
                clazz = parent.loadClass(className, false);
            } catch (ClassNotFoundException e) {
                // Don't want to see this.
            }

            if (clazz == null) {
                clazz = findClass(className);
            }
        }

        return clazz;
    }

    /**
     * Forces a class to be linked (initialized). If the class has already been
     * linked this operation has no effect.
     *

     * Note: In the Android reference implementation, this
     * method has no effect.
     *

     *
     * @param clazz
     *            the class to link.
     */
    protected final void resolveClass(Class<?> clazz) {
        // no-op, doesn't make sense on android.
    }

    /**
     * Indicates whether this class loader is the system class loader. This
     * method must be provided by the virtual machine vendor, as it is used by
     * other provided class implementations in this package. A sample
     * implementation of this method is provided by the reference
     * implementation. This method is used by
     * SecurityManager.classLoaderDepth(), currentClassLoader() and
     * currentLoadedClass(). Returns true if the receiver is a system class
     * loader.
     *

     * Note that this method has package visibility only. It is defined here to
     * avoid the security manager check in getSystemClassLoader, which would be
     * required to implement this method anywhere else.
     *

     *
     * @return {@code true} if the receiver is a system class loader
     * @see Class#getClassLoaderImpl()
     */
    final boolean isSystemClassLoader() {
        return false;
    }

    /**
     *

     * Returns true if the receiver is ancestor of another class loader. It also
     * returns true if the two class loader are equal.
     *

     *

     * Note that this method has package visibility only. It is defined here to
     * avoid the security manager check in getParent, which would be required to
     * implement this method anywhere else. The method is also required in other
     * places where class loaders are accesses.
     *

     *
     * @param child
     *            A child candidate
     * @return {@code true} if the receiver is ancestor of, or equal to,
     *         the parameter
     */
    final boolean isAncestorOf(ClassLoader child) {
        for (ClassLoader current = child; current != null;
                current = current.parent) {
            if (current == this) {
                return true;
            }
        }
        return false;
    }

    /**
     * Finds the URL of the resource with the specified name. This
     * implementation just returns {@code null}; it should be overridden in
     * subclasses.
     *
     * @param resName
     *            the name of the resource to find.
     * @return the {@code URL} object for the requested resource.
     */
    protected URL findResource(String resName) {
        return null;
    }

    /**
     * Finds an enumeration of URLs for the resource with the specified name.
     * This implementation just returns an empty {@code Enumeration}; it should
     * be overridden in subclasses.
     *
     * @param resName
     *            the name of the resource to find.
     * @return an enumeration of {@code URL} objects for the requested resource.
     * @throws IOException
     *             if an I/O error occurs.
     */
    @SuppressWarnings( {
            "unchecked", "unused"
    })
    protected Enumeration<URL> findResources(String resName) throws IOException {
        return EmptyEnumeration.getInstance();
    }

    /**
     * Returns the absolute path of the native library with the specified name,
     * or {@code null}. If this method returns {@code null} then the virtual
     * machine searches the directories specified by the system property
     * "java.library.path".
     *

     * This implementation always returns {@code null}.
     *

     *
     * @param libName
     *            the name of the library to find.
     * @return the absolute path of the library.
     */
    protected String findLibrary(String libName) {
        return null;
    }

    /**
     * Returns the package with the specified name. Package information is
     * searched in this class loader.
     *
     * @param name
     *            the name of the package to find.
     * @return the package with the requested name; {@code null} if the package
     *         can not be found.
     */
    protected Package getPackage(String name) {
        synchronized (packages) {
            Package p = packages.get(name);
            return p;
        }
    }

    /**
     * Gets the package with the specified name, searching it in the specified
     * class loader.
     *
     * @param loader
     *            the class loader to search the package in.
     * @param name
     *            the name of the package to find.
     * @return the package with the requested name; {@code null} if the package
     *         can not be found.
     */
    static Package getPackage(ClassLoader loader, String name) {
        return loader.getPackage(name);
    }

    /**
     * Returns all the packages known to this class loader.
     *
     * @return an array with all packages known to this class loader.
     */
    protected Package[] getPackages() {
        synchronized (packages) {
            Collection<Package> col = packages.values();
            Package[] result = new Package[col.size()];
            col.toArray(result);
            return result;
        }
    }

    /**
     * Defines and returns a new {@code Package} using the specified
     * information. If {@code sealBase} is {@code null}, the package is left
     * unsealed. Otherwise, the package is sealed using this URL.
     *
     * @param name
     *            the name of the package.
     * @param specTitle
     *            the title of the specification.
     * @param specVersion
     *            the version of the specification.
     * @param specVendor
     *            the vendor of the specification.
     * @param implTitle
     *            the implementation title.
     * @param implVersion
     *            the implementation version.
     * @param implVendor
     *            the specification vendor.
     * @param sealBase
     *            the URL used to seal this package or {@code null} to leave the
     *            package unsealed.
     * @return the {@code Package} object that has been created.
     * @throws IllegalArgumentException
     *             if a package with the specified name already exists.
     */
    protected Package definePackage(String name, String specTitle, String specVersion,
            String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase)
            throws IllegalArgumentException {

        synchronized (packages) {
            if (packages.containsKey(name)) {
                throw new IllegalArgumentException("Package " + name + " already defined");
            }

            Package newPackage = new Package(name, specTitle, specVersion, specVendor, implTitle,
                    implVersion, implVendor, sealBase);

            packages.put(name, newPackage);

            return newPackage;
        }
    }

    /**
     * Gets the signers of the specified class. This implementation returns
     * {@code null}.
     *
     * @param c
     *            the {@code Class} object for which to get the signers.
     * @return signers the signers of {@code c}.
     */
    final Object[] getSigners(Class<?> c) {
        return null;
    }

    /**
     * Sets the signers of the specified class. This implementation does
     * nothing.
     *
     * @param c
     *            the {@code Class} object for which to set the signers.
     * @param signers
     *            the signers for {@code c}.
     */
    protected final void setSigners(Class<?> c, Object[] signers) {
        return;
    }

    /**
     *

     * This must be provided by the VM vendor. It is used by
     * SecurityManager.checkMemberAccess() with depth = 3. Note that
     * checkMemberAccess() assumes the following stack when called:

     *

     *
     *

     *          < user code &gt; <- want this class
     *          Class.getDeclared*();
     *          Class.checkMemberAccess();
     *          SecurityManager.checkMemberAccess(); <- current frame
     *

     *
     *

     * Returns the ClassLoader of the method (including natives) at the
     * specified depth on the stack of the calling thread. Frames representing
     * the VM implementation of java.lang.reflect are not included in the list.
     *

     * Notes:
     *

     *
This method operates on the defining classes of methods on stack.
     * NOT the classes of receivers.

     *
The item at depth zero is the caller of this method

     *

     *
     * @param depth
     *            the stack depth of the requested ClassLoader
     * @return the ClassLoader at the specified depth
     */
    static final ClassLoader getStackClassLoader(int depth) {
        Class<?>[] stack = VMStack.getClasses(depth + 1, false);
        if(stack.length < depth + 1) {
            return null;
        }
        return stack[depth].getClassLoader();
    }

    /**
     * This method must be provided by the VM vendor, as it is called by
     * java.lang.System.loadLibrary(). System.loadLibrary() cannot call
     * Runtime.loadLibrary() because this method loads the library using the
     * ClassLoader of the calling method. Loads and links the library specified
     * by the argument.
     *
     * @param libName
     *            the name of the library to load
     * @param loader
     *            the classloader in which to load the library
     * @throws UnsatisfiedLinkError
     *             if the library could not be loaded
     * @throws SecurityException
     *             if the library was not allowed to be loaded
     *

     * Note: This method does nothing in the Android reference
     * implementation.
     *

     */
    static void loadLibraryWithClassLoader(String libName, ClassLoader loader) {
        return;
    }

    /**
     * This method must be provided by the VM vendor, as it is called by
     * java.lang.System.load(). System.load() cannot call Runtime.load() because
     * the library is loaded using the ClassLoader of the calling method. Loads
     * and links the library specified by the argument. No security check is
     * done.
     *

     * Note: This method does nothing in the Android reference
     * implementation.
     *

     *
     * @param libName
     *            the name of the library to load
     * @param loader
     *            the classloader in which to load the library
     * @param libraryPath
     *            the library path to search, or null
     * @throws UnsatisfiedLinkError
     *             if the library could not be loaded
     */
    static void loadLibraryWithPath(String libName, ClassLoader loader, String libraryPath) {
        return;
    }

    /**
     * Sets the assertion status of the class with the specified name.
     *

     * Note: This method does nothing in the Android reference
     * implementation.
     *

     *
     * @param cname
     *            the name of the class for which to set the assertion status.
     * @param enable
     *            the new assertion status.
     */
    public void setClassAssertionStatus(String cname, boolean enable) {
        return;
    }

    /**
     * Sets the assertion status of the package with the specified name.
     *

     * Note: This method does nothing in the Android reference
     * implementation.
     *

     *
     * @param pname
     *            the name of the package for which to set the assertion status.
     * @param enable
     *            the new assertion status.
     */
    public void setPackageAssertionStatus(String pname, boolean enable) {
        return;
    }

    /**
     * Sets the default assertion status for this class loader.
     *

     * Note: This method does nothing in the Android reference
     * implementation.
     *

     *
     * @param enable
     *            the new assertion status.
     */
    public void setDefaultAssertionStatus(boolean enable) {
        return;
    }

    /**
     * Sets the default assertion status for this class loader to {@code false}
     * and removes any package default and class assertion status settings.
     *

     * Note: This method does nothing in the Android reference
     * implementation.
     *

     */
    public void clearAssertionStatus() {
        return;
    }

    /**
     * Returns the assertion status of the named class Returns the assertion
     * status of the class or nested class if it has been set. Otherwise returns
     * the assertion status of its package or superpackage if that has been set.
     * Otherwise returns the default assertion status. Returns 1 for enabled and
     * 0 for disabled.
     *
     * @return the assertion status.
     * @param cname
     *            the name of class.
     */
    boolean getClassAssertionStatus(String cname) {
        return false;
    }

    /**
     * Returns the assertion status of the named package Returns the assertion
     * status of the named package or superpackage if that has been set.
     * Otherwise returns the default assertion status. Returns 1 for enabled and
     * 0 for disabled.
     *
     * @return the assertion status.
     * @param pname
     *            the name of package.
     */
    boolean getPackageAssertionStatus(String pname) {
        return false;
    }

    /**
     * Returns the default assertion status
     *
     * @return the default assertion status.
     */
    boolean getDefaultAssertionStatus() {
        return false;
    }
}

/*
 * Provides a helper class that combines two existing URL enumerations into one.
 * It is required for the getResources() methods. Items are fetched from the
 * first enumeration until it's empty, then from the second one.
 */
class TwoEnumerationsInOne implements Enumeration<URL> {

    private Enumeration<URL> first;

    private Enumeration<URL> second;

    public TwoEnumerationsInOne(Enumeration<URL> first, Enumeration<URL> second) {
        this.first = first;
        this.second = second;
    }

    public boolean hasMoreElements() {
        return first.hasMoreElements() || second.hasMoreElements();
    }

    public URL nextElement() {
        if (first.hasMoreElements()) {
            return first.nextElement();
        } else {
            return second.nextElement();
        }
    }

}

/**
 * Provides an explicit representation of the boot class loader. It sits at the
 * head of the class loader chain and delegates requests to the VM's internal
 * class loading mechanism.
 */
class BootClassLoader extends ClassLoader {

    static BootClassLoader instance;

    public static synchronized BootClassLoader getInstance() {
        if (instance == null) {
            instance = new BootClassLoader();
        }

        return instance;
    }

    public BootClassLoader() {
        super(null, true);
    }

    @Override
    protected Class<?> findClass(String name) throws ClassNotFoundException {
        return VMClassLoader.loadClass(name, false);
    }

    @Override
    protected URL findResource(String name) {
        return VMClassLoader.getResource(name);
    }

    @SuppressWarnings("unused")
    @Override
    protected Enumeration<URL> findResources(String resName) throws IOException {
        Enumeration<URL> result = VMClassLoader.getResources(resName);

        // VMClassLoader doesn't keep the contract for getResources()
        if (result == null) {
            result = EmptyEnumeration.getInstance();
        }

        return result;
    }

    /**
     * Returns package information for the given package. Unfortunately, the
     * Android BootClassLoader doesn't really have this information, and as a
     * non-secure ClassLoader, it isn't even required to, according to the spec.
     * Yet, we want to provide it, in order to make all those hopeful callers of
     * {@code myClass.getPackage().getName()} happy. Thus we construct a Package
     * object the first time it is being requested and fill most of the fields
     * with dummy values. The Package object is then put into the ClassLoader's
     * Package cache, so we see the same one next time. We don't create Package
     * objects for null arguments or for the default package.
     *

     * There a limited chance that we end up with multiple Package objects
     * representing the same package: It can happen when when a package is
     * scattered across different JAR files being loaded by different
     * ClassLoaders. Rather unlikely, and given that this whole thing is more or
     * less a workaround, probably not worth the effort.
     */
    @Override
    protected Package getPackage(String name) {
        if (name != null && !name.isEmpty()) {
            synchronized (this) {
                Package pack = super.getPackage(name);

                if (pack == null) {
                    pack = definePackage(name, "Unknown", "0.0", "Unknown", "Unknown", "0.0",
                            "Unknown", null);
                }

                return pack;
            }
        }

        return null;
    }

    @Override
    public URL getResource(String resName) {
        return findResource(resName);
    }

    @Override
    protected Class<?> loadClass(String className, boolean resolve)
           throws ClassNotFoundException {
        Class<?> clazz = findLoadedClass(className);

        if (clazz == null) {
            clazz = findClass(className);
        }

        return clazz;
    }

    @Override
    public Enumeration<URL> getResources(String resName) throws IOException {
        return findResources(resName);
    }
}

/**
 * TODO Open issues - Missing / empty methods - Signer stuff - Protection
 * domains - Assertions
 */


text:
<CartModifyResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
  <OperationRequest>
    <HTTPHeaders>

    </HTTPHeaders>
    <RequestId>0R6CNXCK30QNW2MNV4EY</RequestId>
    <Arguments>
      <Argument Name="AssociateTag" Value="XXXXXXXXXXXXXXX"/>
      <Argument Name="Service" Value="AWSECommerceService"/>
      <Argument Name="Signature" Value="XXXXXXXXXXXXXXX"/>
      <Argument Name="Item.1.Quantity" Value="-1"/>
      <Argument Name="Item.1.CartItemId" Value="0201896834"/>
      <Argument Name="HMAC" Value="xw2pgBIJekEgmH3uA2taSjRi5Gc="/>
      <Argument Name="Operation" Value="CartModify"/>
      <Argument Name="CartId" Value="275-5902239-8661153"/>
      <Argument Name="AWSAccessKeyId" Value="XXXXXXXXXXXXXXX"/>
      <Argument Name="Timestamp" Value="2011-11-08T21:47:24Z"/>
      <Argument Name="Version" Value="2011-08-01"/>
    </Arguments>
    <RequestProcessingTime>0.00368785858154297</RequestProcessingTime>
  </OperationRequest>
  <Cart>
    <Request>
      <IsValid>False</IsValid>
      <CartModifyRequest>
        <CartId>275-5902239-8661153</CartId>
        <HMAC>xw2pgBIJekEgmH3uA2taSjRi5Gc=</HMAC>
        <Items>
          <Item>
            <CartItemId>0201896834</CartItemId>
            <Quantity>-1</Quantity>
          </Item>
        </Items>
      </CartModifyRequest>
      <Errors>
        <Error>
          AWS.ParameterOutOfRange
          <Message>The value you specified for Quantity is invalid.  Valid values must be between 0 and 999.</Message>
        </Error>
      </Errors>
    </Request>
  </Cart>
</CartModifyResponse>


text:
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Scheduler;
using Microsoft.Phone.Shell;
using Services=WPAppStudio.Services;
using ViewModels=WPAppStudio.ViewModel;
using WPAppStudio.ViewModel.Base;

namespace WPAppStudio
{
    /// <summary>
    /// Application management.
    /// </summary>
    [CompilerGenerated]
    [GeneratedCode("Radarc", "4.0")]
    public partial class App
    {
		private bool _loadingfromInstance;
		private VMBase _vm;

        /// <summary>
        /// Application execution entry point.
        /// </summary>
		public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard Silverlight initialization
            InitializeComponent();

            InitializePhoneApplication();
        }

        /// <summary>
        /// Gets/Sets the phone application UI root frame.
        /// </summary>
        public static PhoneApplicationFrame RootFrame { get; private set; }

        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
        }

        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
			if (e.IsApplicationInstancePreserved)
            {
                if (_vm != null)
                    _vm.Initialize(new Dictionary<string, string>());
            }
        }

        private void Application_Deactivated(object sender, DeactivatedEventArgs e)
        {
			if (_vm != null)
				_vm = (VMBase)(RootFrame.Content as PhoneApplicationPage).DataContext;
        }

        private void Application_Closing(object sender, ClosingEventArgs e)
        {
        }

        private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            if (Debugger.IsAttached)
            {
                Debugger.Break();
            }
        }

        private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
        {
            if (Debugger.IsAttached)
            {
                Debugger.Break();
            }
        }

        private bool _phoneApplicationInitialized;

        private void InitializePhoneApplication()
        {
            if (_phoneApplicationInitialized)
                return;

            RootFrame = new TransitionFrame();
            RootFrame.Navigated += CompleteInitializePhoneApplication;
			RootFrame.Navigating += RootFrame_Navigating;

			// Handle navigation failures
            RootFrame.NavigationFailed += RootFrame_NavigationFailed;

			// Handle reset requests for clearing the backstack
            RootFrame.Navigated += CheckForResetNavigation;

            _phoneApplicationInitialized = true;
        }

		private void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e)
        {
            if (!e.Uri.ToString().Contains("Main_News") || !_loadingfromInstance) return;

            e.Cancel = true;
            _loadingfromInstance = false;
        }

		private void CheckForResetNavigation(object sender, NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New && _loadingfromInstance && RootFrame.CanGoBack)
                RootFrame.GoBack();

            // If the app has received a 'reset' navigation, then we need to check
            // on the next navigation to see if the page stack should be reset
            if (e.NavigationMode == NavigationMode.Reset)
                _loadingfromInstance = true;
        }

        private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
        {
			if (RootFrame != null && RootVisual != RootFrame)
                RootVisual = RootFrame;

            RootFrame.Navigated -= CompleteInitializePhoneApplication;
        }
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">AOPDroidTestApp</string>
    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>

</resources>


text:
import {MealIngredient} from './meal.ingredient';

export class Meal {
  name: string;
  ingredients: MealIngredient[];

  constructor(name: string, ingredients: MealIngredient[]) {
    this.name = name;
    this.ingredients = ingredients;
  }

  totalProteins(): number {
    return this.sumBy(i => i.proteins() || 0);
  }

  totalCarbohydrates(): number {
    return this.sumBy(i => i.carbohydrates() || 0);
  }

  totalFats(): number {
    return this.sumBy(i => i.fats() || 0);
  }

  totalNutritionValue(): number {
    return this.sumBy(i => i.nutritionValue() || 0);
  }

  totalWeight(): number {
    return this.sumBy(i => i.weight);
  }

  private sumBy(fn: (MealIngredient) => number): number {
    return this.ingredients.map(i => fn(i)).reduce((prev, current) => current + prev, 0);
  }
}


text:
using System;

namespace Gep13.Cake.Sample.WebApplication.Models
{
    public class ErrorViewModel
    {
        public string RequestId { get; set; }

        public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
    }
}


text:
package cmd

import (
	"strconv"

	"github.com/fatih/color"
	out "github.com/plouc/go-gitlab-client/cli/output"
	"github.com/spf13/cobra"
)

func init() {
	getCmd.AddCommand(getProjectMergeRequestNoteCmd)
}

var getProjectMergeRequestNoteCmd = &cobra.Command{
	Use:     resourceCmd("project-merge-request-note", "project-merge-request-note"),
	Aliases: []string{"project-mr-note", "merge-request-note", "mr-note"},
	Short:   "Get project merge request note",
	RunE: func(cmd *cobra.Command, args []string) error {
		ids, err := config.aliasIdsOrArgs(currentAlias, "project-merge-request-note", args)
		if err != nil {
			return err
		}

		mergeRequestIid, err := strconv.Atoi(ids["merge_request_iid"])
		if err != nil {
			return err
		}

		noteId, err := strconv.Atoi(ids["note_id"])
		if err != nil {
			return err
		}

		color.Yellow(
			"Fetching project's merge request note (project id: %s, merge request iid: %d, note id: %d)…",
			ids["project_id"], mergeRequestIid, noteId,
		)

		loader.Start()
		note, meta, err := client.ProjectMergeRequestNote(ids["project_id"], mergeRequestIid, noteId)
		loader.Stop()
		if err != nil {
			return err
		}

		out.Note(output, outputFormat, note)

		printMeta(meta, false)

		return nil
	},
}


text:
"""
Utilities useful for experiment setup
"""
__author__ = 'victor'
import json

class AttrDict(dict):
    """
    A dictionary object which keys can be referenced via attributes.

    Example:

    .. code-block:: python

        d = AttriDict(foo=1, bar='cool')
        print(d)
        print(d['foo'])
        print(d.foo)
        print(d.bar)
    """

    def __init__(self, *args, **kwargs):
        super(AttrDict, self).__init__(*args, **kwargs)
        self.__dict__ = self

    def save(self, fname):
        """ Saves the dictionary in json format
        :param fname: file to save to
        """
        with open(fname, 'wb') as f:
            json.dump(self, f)

    @classmethod
    def load(cls, fname):
        """ Loads the dictionary from json file
        :param fname: file to load from
        :return: loaded dictionary
        """
        with open(fname) as f:
            return Config(**json.load(f))


text:
<?php

namespace PHPMD\Rule\Design;

use PHPMD\AbstractTest;

/**
 * Test case for the weighted method count rule.
 *_Design
 * @author    Manuel Pichler <mapi@phpmd.org>
 * @copyright 2008-2014 Manuel Pichler. All rights reserved.
 * @license   http://www.opensource.org/licenses/bsd-license.php BSD License
 * @since      0.2.5
 *
 * @covers \PHPMD\Rule\Design\WeightedMethodCount
 * @group phpmd
 * @group phpmd::rule
 * @group unittest
 */
class WeightedMethodCountTest extends AbstractTest
{
    /**
     * testRuleAppliesForValueGreaterThanThreshold
     *
     * @return void
     */
    public function testRuleAppliesForValueGreaterThanThreshold()
    {
        $class  = $this->getClassMock('wmc', 42);
        $report = $this->getReportMock(1);

        $rule = new WeightedMethodCount();
        $rule->setReport($report);
        $rule->addProperty('maximum', '10');
        $rule->apply($class);
    }

    /**
     * testRuleAppliesForValueEqualToThreshold
     *
     * @return void
     */
    public function testRuleAppliesForValueEqualToThreshold()
    {
        $class  = $this->getClassMock('wmc', 42);
        $report = $this->getReportMock(1);

        $rule = new WeightedMethodCount();
        $rule->setReport($report);
        $rule->addProperty('maximum', '42');
        $rule->apply($class);
    }

    /**
     * testRuleNotAppliesForValueLowerThanThreshold
     *
     * @return void
     */
    public function testRuleNotAppliesForValueLowerThanThreshold()
    {
        $class  = $this->getClassMock('wmc', 42);
        $report = $this->getReportMock(0);

        $rule = new WeightedMethodCount();
        $rule->setReport($report);
        $rule->addProperty('maximum', '43');
        $rule->apply($class);
    }
}


text:
 Improve this Doc

Error: ngOptions:iexp

Invalid Expression

Expected expression in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got '{0}'. Element: {1}

Description

This error occurs when 'ngOptions' is passed an expression that isn't in an expected form.

Here's an example of correct syntax:

<select ng-model="color" ng-options="c.name for c in colors">

For more information on valid expression syntax, see 'ngOptions' in select directive docs.


text:
module.exports = (gulp) => () => {
  // TODO:(petebd): hook up with whatever builds need doing for the webapp
};


text:
using System;
using UIKit;

namespace zsquared
{
    public static class C_Common
    {
        public static UIColor Color_NoSiteOpen = UIColor.FromRGB(0x57, 0x57, 0x57);
        public static UIColor Color_OneAppt = UIColor.FromRGB(0xBB, 0xBA, 0x49);
        public static UIColor Color_TwoAppt = UIColor.FromRGB(0x2F, 0xA1, 0x80);
        public static UIColor Color_BadAppt = UIColor.FromRGB(0xA8, 0x00, 0x00);

        public static UIColor StandardBackground => UIColor.FromRGB(19, 67, 107); // #13436B

        public static UIColor StandardButton => UIColor.FromRGB(33, 96, 147);

        public static UIColor StandardButtonLight => UIColor.FromRGB(70, 123, 165);

        public static UIColor SwitchOn => UIColor.FromRGB(188, 196, 49);

        public static UIColor LogoutButton => UIColor.FromRGB(33, 122, 147); // #ff217a93

        public static UIColor OpenDefault = SwitchOn;
        public static UIColor ClosedDefault = StandardButtonLight;

        public static void DropFirstResponder(UIView view)
        {
            view.BackgroundColor = StandardBackground;

            foreach (UIView v in view.Subviews)
            {
                if (v is UIButton)
                {
                    UIButton b = v as UIButton;
                    b.ResignFirstResponder();
                }
                else if (v is UISwitch)
                {
                    UISwitch sw = v as UISwitch;
                    sw.ResignFirstResponder();
                }
                else if (v is UIWebView)
                {
                    UIWebView wv = v as UIWebView;
                    v.ResignFirstResponder();
                }
                else if (v is UICollectionView)
                {
                    UICollectionView cv = v as UICollectionView;
                    cv.ResignFirstResponder();
                }
                else if (v is UITextField)
                {
                    UITextField tf = v as UITextField;
                    tf.ResignFirstResponder();
                }
                else if (v is UITextView)
                {
                    UITextView tf = v as UITextView;
                    tf.ResignFirstResponder();
                }
                else if (v is UITableView)
                {
                    UITableView tv = v as UITableView;
                    tv.ResignFirstResponder();
                }
            }
        }

        public static void SetUIColors(UIView view)
        {
            view.BackgroundColor = StandardBackground;

            foreach (UIView v in view.Subviews)
            {
                if (v is UIButton)
                {
                    UIButton b = v as UIButton;
                    b.SetTitleColor(UIColor.FromRGBA(255, 255, 255, 255), UIControlState.Normal);
                    b.SetTitleColor(UIColor.FromRGBA(255, 255, 255, 64), UIControlState.Disabled);
                    string title = b.Title(UIControlState.Normal);
                    string titleLower = title.ToLower();
                    if (titleLower.Contains("logout"))
                        b.BackgroundColor = LogoutButton;
                    else if (titleLower.Contains("back"))
                        b.BackgroundColor = StandardBackground;
                    else
                        b.BackgroundColor = StandardButton;
                }
                else if (v is UISwitch)
                {
                    UISwitch sw = v as UISwitch;
                    sw.OnTintColor = C_Common.SwitchOn;
                }
                else if (v is UIWebView)
                {
                    UIWebView wv = v as UIWebView;
                    wv.BackgroundColor = StandardBackground;
                }
                else if (v is UICollectionView)
                {
                    UICollectionView cv = v as UICollectionView;
                    ((UICollectionView)v).BackgroundColor = StandardBackground;
                }
                else if (v is UITextField)
                {
                    UITextField tf = v as UITextField;
                    tf.BackgroundColor = StandardButton;
                    tf.TextColor = UIColor.White;
                }
                else if (v is UITextView)
                {
                    UITextView tf = v as UITextView;
                    tf.BackgroundColor = StandardButton;
                    tf.TextColor = UIColor.White;
                }
                else if (v is UITableView)
                {
                    UITableView tv = v as UITableView;
                    tv.BackgroundColor = StandardBackground;
                }
            }
        }

        public static void EnableUI(UIView view, bool en)
        {
            foreach (UIView v in view.Subviews)
            {
                if (v is UIButton)
                {
                    UIButton b = v as UIButton;
                    b.Enabled = en;
                }
                else if (v is UITableView)
                {
                    UITableView tv = v as UITableView;
                    tv.UserInteractionEnabled = en;
                }
                else if (v is UITextField)
                {
                    UITextField tf = v as UITextField;
                    tf.Enabled = en;
                }
                else if (v is UISwitch)
                {
                    UISwitch sw = v as UISwitch;
                    sw.Enabled = en;
                }
                else if (v is UIWebView)
                {
                    UIWebView wv = v as UIWebView;
                    wv.UserInteractionEnabled = en;
                }
                else if (v is UICollectionView)
                {
                    UICollectionView cv = v as UICollectionView;
                    cv.UserInteractionEnabled = en;
                }
                else if (v is UITextView)
                {
                    UITextView tf = v as UITextView;
                    tf.UserInteractionEnabled = en;
                }
            }
        }

        public static void SetEnabledColors(UITextField tf)
        {
            tf.TextColor = tf.Enabled ? UIColor.White : UIColor.Gray;
        }
    }
}


text:
import java.util.*;
import java.lang.*;
import java.io.*;

/**
 * Program that will manipulate a square based on user commands.
 * The Program will shift a row or column to the left or down.
 * The user enters two commands as a string of three chars.
 * @see Github Repo
 */

public class H9_nicholas {

    /**
     * Main method for the Square rotate and flip program
     * @param  args
     * @throws FileNotFoundException
     */
    public static void main(String[] args)
    throws FileNotFoundException {
        Scanner myFile = new Scanner(new File("square.txt"));
        Scanner scan = new Scanner(System.in);
        String myInput;
        int[][] myArr;
        int[][] newArr = new int[5][5];

        myArr = readFile(myFile);
        System.out.println("Enter you command: ");
        myInput = scan.nextLine();

        newArr = changeArr(myInput, myArr);

        for(int i = 0; i < myArr.length; i++) {
            System.out.println(Arrays.toString(newArr[i]));
        }
    }

    /**
     * changeArr takes in the original square and executes user commands on it.
     * @param  command Sting input with three chars, a space, and three chars
     * @param  arr     2-D array read from square.txt file
     * @return         the changed 2-D array is returned
     */
    public static int[][] changeArr(String command, int[][] arr) {
        String arg1 = String.valueOf(command.charAt(0));
        String arg2 = String.valueOf(command.charAt(1));
        int arg3 = Integer.parseInt(String.valueOf(command.charAt(2)));
        String arg4 = String.valueOf(command.charAt(4));
        String arg5 = String.valueOf(command.charAt(5));
        int arg6 = Integer.parseInt(String.valueOf(command.charAt(6)));

        int[][] newArr = new int[arr.length][arr.length];

        if(arg1.equals("s")) {
            int[] row = getRow(arr, arg3);
            //System.out.println(Arrays.toString(row));
            row = shiftLeft(row);
            //System.out.println(Arrays.toString(row));
            newArr = returnArr(arr, row, arg3);
            System.out.println(Arrays.deepToString(newArr));
        } else if(arg1.equals("f")) {
            newArr = flipCol(arr, arg3);
        }

        if(arg4.equals("s")) {
             int[] row = getRow(newArr, arg6);
             row = shiftLeft(row);
             newArr = returnArr(newArr, row, arg6);
         } else if(arg4.equals("f")) {
             newArr = flipCol(newArr, arg6);
         }
        return newArr;
    }

    /**
     * readFile takes in the square.txt file and converts it into a 2-D Array.
     * @param  myFile text file that contains the integers that make the 2-D array. The first int is ignored
     * @return        returns the 2-D array that will be used by the rest of the program.
     */
    public static int[][] readFile(Scanner myFile) {
        int[][] newArr = new int[5][5];
        int row = 0;
        String[] line;
        myFile.nextLine();
        while(myFile.hasNextLine()) {
            line = myFile.nextLine().split(" ");
            for(int i = 0; i < 5; i++) {
                newArr[row][i] = Integer.parseInt(line[i]);
            }
            row++;
        }
        return newArr;
    }

    /**
     * getRow will get the specific row that the user wants to manipulate
     * @param  arr 2-D array that is to be used
     * @param  row number of the row that the user wants
     * @return     returns the row as a single array that can then be shifted or flipped.
     */
    public static int[] getRow(int[][] arr, int row) {
      int[] newRow = new int[arr.length];
      for(int i = 0; i < arr.length; i++) {
         if(i == row - 1) {
            for(int j = 0; j < arr[i].length; j++) {
               newRow[j] = arr[i][j];
            }
         }
      }
      return newRow;
    }

    /**
     * returnArr is used to re-insert a single array back into the 2-D array
     * @param  arr    2-D array that the single array will be put into.
     * @param  rowArr Single array that is to be put into the 2-D array.
     * @param  rowNum number of the row that the user wants to replace
     * @return        returns the completed array after it has been shifted
     */
    public static int[][] returnArr(int[][] arr, int[] rowArr, int rowNum) {
        int[][] newArr = new int[arr.length][arr.length];
        for(int i = 0; i < arr.length; i++) {
            for(int j = 0; j < arr[i].length; j++) {
                if(i == rowNum - 1) {
                    newArr[i][j] = rowArr[j];
                } else {
                    newArr[i][j] = arr[i][j];
                }
            }
        }
        return newArr;
    }

    /**
     * flipCol swaps the top and bottom values in a column that the user selects
     * @param  arr       2-D array that is to be manipulated
     * @param  colChoice Column that the user wants to flip
     * @return           2-D array that has the selected column flipped.
     */
    public static int[][] flipCol(int[][] arr, int colChoice) {
        int[][] newArr = new int[arr.length][arr.length];
        int col = colChoice - 1;
        int temp = arr[0][col];
        arr[0][col] = arr[arr.length - 1][col];
        arr[arr.length - 1][col] = temp;

        for(int i = 0; i < arr.length; i++) {
            for(int j = 0; j < arr[i].length; j++) {
                newArr[i][j] = arr[i][j];
            }
        }
        return newArr;
    }

    /**
     * shiftLeft moves all the values of a single array one spot to the left.
     * The first value of the array is then moved to the back.
     * @param  arr single array that will be shifted
     * @return     single shifted array
     */
    public static int[] shiftLeft(int[] arr) {
        int[] newRow = new int[arr.length];
        int first = arr[0];
        for(int i = 0; i < arr.length - 1; i++) {
            newRow[i] = arr[i + 1];
        }
        newRow[newRow.length - 1] = first;
        return newRow;
    }

}


text:
class artifact {
    public:
        typedef std::chrono::system_clock clock;

        artifact() : name_{}, mod_time_{ clock::time_point{} } {}

        artifact(std::string const& name)
            : name_{name}, mod_time_{get_mod_time()}, variables_{nullptr}
        {}

        artifact(artifact&& source) noexcept
            : name_{ std::move(source.name_) },
              mod_time_{ std::move(source.mod_time_) },
              variables_{ source.variables_ }
        {
            source.variables_ = nullptr;
        }

        ~artifact() { delete variables_; }

        artifact& operator=(artifact&& source) noexcept {
            delete variables_;
            variables_ = source.variables_;
            source.variables_ = nullptr;
            name_ = std::move(source.name_);
            mod_time_ = std::move(source.mod_time_);
            return *this;
        }

        std::string const& name() const { return name_; }
        clock::time_point mod_time() const { return mod_time_; }

        std::string expand(std::string str) const
        {
            return ::expand(str, variables_);
        }

        clock::time_point get_mod_time() { return clock::now(); }

        void store_variable(std::string const& name,
                            std::string const& value)
        {
            if (nullptr == variables_)
                variables_ = new variable_map;
            (*variables_)[name] = value;
        }

    private:
        std::string name_;
        clock::time_point mod_time_;
        variable_map* variables_;
};

#endif // ARTIFACT_HPP_


text:
package org.dynamicloud.api.criteria;

/**
 * This enum represents the different Join types
 *
 * @author Eleazar Gomez
 * @version 1.0.0
 * @since 11/4/15
 **/
public enum JoinType {
    LEFT, RIGHT, INNER, LEFT_OUTER, RIGHT_OUTER;

    /**
     * This method returns the text according to this Join Type.
     *
     * @return the text according to this Join Type.
     */
    public String toString() {
        switch (this) {
            case LEFT:
                return "left";
            case RIGHT:
                return "right";
            case INNER:
                return "inner";
            case LEFT_OUTER:
                return "left outer";
            case RIGHT_OUTER:
                return "right outer";
            default:
                return "inner";
        }
    }
}