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

<TITLE>Object (Groovy JDK)</TITLE>

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

                        Overview
                        Package
                        Class
                        Tree
                        Deprecated
                        Index
                        Help

            Groovy JDK

java.lang

Class Object

Method Summary

void

addShutdownHook(Closure closure)

Allows the usage of addShutdownHook without getting the runtime first.

boolean

any(Closure closure)

Iterates over the contents of an object or collection, and checks whether a
predicate is valid for at least one element.

boolean

any()

Iterates over the elements of a collection, and checks whether at least
one element is true according to the Groovy Truth.

boolean

asBoolean()

Coerce an object instance to a boolean value.

Object

asType(Class type)

Converts a given object to a type.

List

collect(Closure transform)

Iterates through this aggregate Object transforming each item into a new value using the
transform closure, returning a list of transformed values.

Collection

collect()

Iterates through this aggregate Object transforming each item into a new value using Closure.IDENTITY
as a transformer, basically returning a list of items copied from the original object.

Collection

collect(Collection collector, Closure transform)

Iterates through this aggregate Object transforming each item into a new value using the transform closure
and adding it to the supplied collector.

String

dump()

Generates a detailed dump string of an object showing its class,
hashCode and fields.

Object

each(Closure closure)

Iterates through an aggregate type or data structure,
passing each item to the given closure.

Object

eachWithIndex(Closure closure)

Iterates through an aggregate type or data structure,
passing each item and the item's index (a counter starting at
zero) to the given closure.

boolean

every(Closure closure)

Used to determine if the given predicate closure is valid (i.e.

boolean

every()

Iterates over every element of a collection, and checks whether all
elements are true according to the Groovy Truth.

Object

find(Closure closure)

Finds the first value matching the closure condition

Object

find()

Finds the first item matching the IDENTITY Closure (i.e. matching Groovy truth).

Collection

findAll(Closure closure)

Finds all items matching the closure condition.

Collection

findAll()

Finds all items matching the IDENTITY Closure (i.e. matching Groovy truth).

int

findIndexOf(Closure closure)

Iterates over the elements of an iterable collection of items and returns
the index of the first item that matches the condition specified in the closure.

int

findIndexOf(int startIndex, Closure closure)

Iterates over the elements of an iterable collection of items, starting from a
specified startIndex, and returns the index of the first item that matches the
condition specified in the closure.

List

findIndexValues(Closure closure)

Iterates over the elements of an iterable collection of items and returns
the index values of the items that match the condition specified in the closure.

List

findIndexValues(Number startIndex, Closure closure)

Iterates over the elements of an iterable collection of items, starting from
a specified startIndex, and returns the index values of the items that match
the condition specified in the closure.

int

findLastIndexOf(Closure closure)

Iterates over the elements of an iterable collection of items and returns
the index of the last item that matches the condition specified in the closure.

int

findLastIndexOf(int startIndex, Closure closure)

Iterates over the elements of an iterable collection of items, starting
from a specified startIndex, and returns the index of the last item that
matches the condition specified in the closure.

Object

findResult(Object defaultResult, Closure closure)

Treats the object as iterable, iterating through the values it represents and returns the first non-null result obtained from calling the closure, otherwise returns the defaultResult.

Object

findResult(Closure closure)

Treats the object as iterable, iterating through the values it represents and returns the first non-null result obtained from calling the closure, otherwise returns null.

Object

getAt(String property)

Allows the subscript operator to be used to lookup dynamic property values.

MetaClass

getMetaClass()

Obtains a MetaClass for an object either from the registry or in the case of
a GroovyObject from the object itself.

List

getMetaPropertyValues()

Retrieves the list of MetaProperty objects for 'self' and wraps it
in a list of PropertyValue objects that additionally provide
the value for each property of 'self'.

Map

getProperties()

Convenience method that calls Object#getMetaPropertyValues(self)
and provides the data in form of simple key/value pairs, i.e.

Collection

grep(Object filter)

Iterates over the collection of items which this Object represents and returns each item that matches
the given filter - calling the Object#isCase
method used by switch statements.

Collection

grep()

Iterates over the collection of items which this Object represents and returns each item that matches
using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth.

MetaProperty

hasProperty(String name)

Returns true of the implementing MetaClass has a property of the given name

Note that this method will only return true for realised properties and does not take into
account implementation of getProperty or propertyMissing

Object

identity(Closure closure)

Allows the closure to be called for the object reference self.

Object

inject(Closure closure)

Iterates through the given Object, passing in the first value to
the closure along with the first item.

Object

inject(Object initialValue, Closure closure)

Iterates through the given Object, passing in the initial value to
the closure along with the first item.

String

inspect()

Inspects returns the String that matches what would be typed into a
terminal to create this object.

Object

invokeMethod(String method, Object arguments)

Provide a dynamic method invocation method which can be overloaded in
classes to implement dynamic proxies easily.

boolean

is(Object other)

Identity check.

boolean

isCase(Object switchValue)

Method for overloading the behavior of the 'case' method in switch statements.

Iterator

iterator()

Attempts to create an Iterator for the given object by first
converting it to a Collection.

MetaClass

metaClass(Closure closure)

Sets/updates the metaclass for a given object to a closure.

void

print(Object value)

Print a value formatted Groovy style to self if it
is a Writer, otherwise to the standard output stream.

void

print(PrintWriter out)

Print to a console in interactive format.

void

printf(String format, Object[] values)

Printf to a console (Only works with JDK1.5 or later).

void

printf(String format, Object arg)

Prints a formatted string using the specified format string and
arguments.

void

println()

Print a linebreak to the standard output stream.

void

println(Object value)

Print a value formatted Groovy style (followed by a newline) to self
if it is a Writer, otherwise to the standard output stream.

void

println(PrintWriter out)

Print to a console in interactive format.

void

putAt(String property, Object newValue)

Allows the subscript operator to be used to set dynamically named property values.

List

respondsTo(String name, Object[] argTypes)

Returns an object satisfying Groovy truth if the implementing MetaClass responds to
a method with the given name and arguments types.

List

respondsTo(String name)

Returns an object satisfying Groovy truth if the implementing MetaClass responds to
a method with the given name regardless of the arguments.

void

setMetaClass(MetaClass metaClass)

Set the metaclass for an object.

static void

sleep(long milliseconds)

Sleep for so many milliseconds, even if interrupted.

static void

sleep(long milliseconds, Closure onInterrupt)

Sleep for so many milliseconds, using a given closure for interrupt processing.

Collection

split(Closure closure)

Splits all items into two lists based on the closure condition.

String

sprintf(String format, Object[] values)

Sprintf to a string (Only works with JDK1.5 or later).

String

sprintf(String format, Object arg)

Returns a formatted string using the specified format string and
arguments.

String

toString()

Create a String representation of this object.

Object

use(Class categoryClass, Closure closure)

Scoped use method

Object

use(List categoryClassList, Closure closure)

Scoped use method with list of categories.

Object

use(Object[] array)

Allows you to use a list of categories, specifying the list as varargs.

Object

with(Closure closure)

Allows the closure to be called for the object reference self.

Method Detail

addShutdownHook

public void addShutdownHook(Closure closure)

Allows the usage of addShutdownHook without getting the runtime first.

Parameters:

closure -  the shutdown hook action.

Since:

1.5.0

any

public boolean any(Closure closure)

Iterates over the contents of an object or collection, and checks whether a
predicate is valid for at least one element.

Parameters:

closure -  the closure predicate used for matching.

Returns:

true   if any iteration for the object matches the closure predicate

Since:

1.0

any

public boolean any()

Iterates over the elements of a collection, and checks whether at least
one element is true according to the Groovy Truth.
Equivalent to self.any({element -> element})

Returns:

true if any item in the collection matches the closure predicate

Since:

1.5.0

asBoolean

public boolean asBoolean()

Coerce an object instance to a boolean value.
An object is coerced to true if it's not null, to false if it is null.

Returns:

the boolean value

Since:

1.7.0

asType

public Object asType(Class type)

Converts a given object to a type. This method is used through
the "as" operator and is overloadable as any other operator.

Parameters:

type -  the goal type.

Returns:

the resulting object

Since:

1.0

collect

public List collect(Closure transform)

Iterates through this aggregate Object transforming each item into a new value using the
transform closure, returning a list of transformed values.
Example:

def list = [1, 'a', 1.23, true ]
def types = list.collect { it.class }
assert types == [Integer, String, BigDecimal, Boolean]

Parameters:

transform -  the closure used to transform each item of the aggregate object.

Returns:

a List of the transformed values

Since:

1.0

collect

public Collection collect()

Iterates through this aggregate Object transforming each item into a new value using Closure.IDENTITY
as a transformer, basically returning a list of items copied from the original object.

assert [1,2,3] == [1,2,3].iterator().collect()

Returns:

a List of the transformed values

Since:

1.8.5

See:

Closure#IDENTITY.

collect

public Collection collect(Collection collector, Closure transform)

Iterates through this aggregate Object transforming each item into a new value using the transform closure
and adding it to the supplied collector.

Parameters:

collector -  the Collection to which the transformed values are added.

transform -  the closure used to transform each item of the aggregate object.

Returns:

the collector with all transformed values added to it

Since:

1.0

dump

public String dump()

Generates a detailed dump string of an object showing its class,
hashCode and fields.

Returns:

the dump representation

Since:

1.0

each

public Object each(Closure closure)

Iterates through an aggregate type or data structure,
passing each item to the given closure.  Custom types may utilize this
method by simply providing an "iterator()" method.  The items returned
from the resulting iterator will be passed to the closure.

Parameters:

closure -  the closure applied on each element found.

Returns:

the self Object

Since:

1.0

eachWithIndex

public Object eachWithIndex(Closure closure)

Iterates through an aggregate type or data structure,
passing each item and the item's index (a counter starting at
zero) to the given closure.

Parameters:

closure -  a Closure to operate on each item.

Returns:

the self Object

Since:

1.0

every

public boolean every(Closure closure)

Used to determine if the given predicate closure is valid (i.e.&nsbp;returns
true for all items in this data structure).
A simple example for a list:

def list = [3,4,5]
def greaterThanTwo = list.every { it > 2 }

Parameters:

closure -  the closure predicate used for matching.

Returns:

true if every iteration of the object matches the closure predicate

Since:

1.0

every

public boolean every()

Iterates over every element of a collection, and checks whether all
elements are true according to the Groovy Truth.
Equivalent to self.every({element -> element})

Returns:

true if every item in the collection matches the closure
        predicate

Since:

1.5.0

find

public Object find(Closure closure)

Finds the first value matching the closure condition

Parameters:

closure -  a closure condition.

Returns:

the first Object found or null if none was found

Since:

1.0

find

public Object find()

Finds the first item matching the IDENTITY Closure (i.e. matching Groovy truth).

Example:

def items = [null, 0, 0.0, false, '', [], 42, 43]
assert items.find() == 42

Returns:

the first Object found or null if none was found

Since:

1.8.1

See:

Closure#IDENTITY.

findAll

public Collection findAll(Closure closure)

Finds all items matching the closure condition.

Parameters:

closure -  a closure condition.

Returns:

a List of the values found

Since:

1.6.0

findAll

public Collection findAll()

Finds all items matching the IDENTITY Closure (i.e. matching Groovy truth).

Example:

def items = [1, 2, 0, false, true, '', 'foo', [], [4, 5], null]
assert items.findAll() == [1, 2, true, 'foo', [4, 5]]

Returns:

a List of the values found

Since:

1.8.1

See:

Closure#IDENTITY.

findIndexOf

public int findIndexOf(Closure closure)

Iterates over the elements of an iterable collection of items and returns
the index of the first item that matches the condition specified in the closure.

Parameters:

closure -  the filter to perform a match on the collection.

Returns:

an integer that is the index of the first matched object or -1 if no match was found

Since:

1.0

findIndexOf

public int findIndexOf(int startIndex, Closure closure)

Iterates over the elements of an iterable collection of items, starting from a
specified startIndex, and returns the index of the first item that matches the
condition specified in the closure.

Parameters:

startIndex -  start matching from this index.

closure -     the filter to perform a match on the collection.

Returns:

an integer that is the index of the first matched object or -1 if no match was found

Since:

1.5.0

findIndexValues

public List findIndexValues(Closure closure)

Iterates over the elements of an iterable collection of items and returns
the index values of the items that match the condition specified in the closure.

Parameters:

closure -  the filter to perform a match on the collection.

Returns:

a list of numbers corresponding to the index values of all matched objects

Since:

1.5.2

findIndexValues

public List findIndexValues(Number startIndex, Closure closure)

Iterates over the elements of an iterable collection of items, starting from
a specified startIndex, and returns the index values of the items that match
the condition specified in the closure.

Parameters:

startIndex -  start matching from this index.

closure -     the filter to perform a match on the collection.

Returns:

a list of numbers corresponding to the index values of all matched objects

Since:

1.5.2

findLastIndexOf

public int findLastIndexOf(Closure closure)

Iterates over the elements of an iterable collection of items and returns
the index of the last item that matches the condition specified in the closure.

Parameters:

closure -  the filter to perform a match on the collection.

Returns:

an integer that is the index of the last matched object or -1 if no match was found

Since:

1.5.2

findLastIndexOf

public int findLastIndexOf(int startIndex, Closure closure)

Iterates over the elements of an iterable collection of items, starting
from a specified startIndex, and returns the index of the last item that
matches the condition specified in the closure.

Parameters:

startIndex -  start matching from this index.

closure -     the filter to perform a match on the collection.

Returns:

an integer that is the index of the last matched object or -1 if no match was found

Since:

1.5.2

findResult

public Object findResult(Object defaultResult, Closure closure)

Treats the object as iterable, iterating through the values it represents and returns the first non-null result obtained from calling the closure, otherwise returns the defaultResult.

Parameters:

defaultResult -  an Object that should be returned if all closure results are null.

closure -  a closure that returns a non-null value when processing should stop.

Returns:

the first non-null result of the closure, otherwise the default value

Since:

1.7.5

findResult

public Object findResult(Closure closure)

Treats the object as iterable, iterating through the values it represents and returns the first non-null result obtained from calling the closure, otherwise returns null.

Parameters:

closure -  a closure that returns a non-null value when processing should stop.

Returns:

the first non-null result of the closure

Since:

1.7.5

getAt

public Object getAt(String property)

Allows the subscript operator to be used to lookup dynamic property values.
bean[somePropertyNameExpression]. The normal property notation
of groovy is neater and more concise but only works with compile-time known
property names.

Parameters:

property -  the property name of interest.

Returns:

the property value

Since:

1.0

getMetaClass

public MetaClass getMetaClass()

Obtains a MetaClass for an object either from the registry or in the case of
a GroovyObject from the object itself.

Returns:

The MetaClass

Since:

1.5.0

getMetaPropertyValues

public List getMetaPropertyValues()

Retrieves the list of MetaProperty objects for 'self' and wraps it
in a list of PropertyValue objects that additionally provide
the value for each property of 'self'.

Returns:

list of {@link groovy.lang.PropertyValue} objects

Since:

1.0

See:

Expando#getMetaPropertyValues.

getProperties

public Map getProperties()

Convenience method that calls Object#getMetaPropertyValues(self)
and provides the data in form of simple key/value pairs, i.e.&nsbp;without
type() information.

Returns:

meta properties as Map of key/value pairs

Since:

1.0

grep

public Collection grep(Object filter)

Iterates over the collection of items which this Object represents and returns each item that matches
the given filter - calling the Object#isCase
method used by switch statements.  This method can be used with different
kinds of filters like regular expressions, classes, ranges etc.
Example:

def list = ['a', 'b', 'aa', 'bc', 3, 4.5]
assert list.grep( ~/a+/ )  == ['a', 'aa']
assert list.grep( ~/../ )  == ['aa', 'bc']
assert list.grep( Number ) == [ 3, 4.5 ]
assert list.grep{ it.toString().size() == 1 } == [ 'a', 'b', 3 ]

Parameters:

filter -  the filter to perform on the object (using the Object#isCase method).

Returns:

a collection of objects which match the filter

Since:

1.5.6

grep

public Collection grep()

Iterates over the collection of items which this Object represents and returns each item that matches
using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth.

Example:

def items = [1, 2, 0, false, true, '', 'foo', [], [4, 5], null]
assert items.grep() == [1, 2, true, 'foo', [4, 5]]

Returns:

a collection of objects which match the filter

Since:

1.8.1

See:

Closure#IDENTITY.

hasProperty

public MetaProperty hasProperty(String name)

Returns true of the implementing MetaClass has a property of the given name

Note that this method will only return true for realised properties and does not take into
account implementation of getProperty or propertyMissing

Parameters:

name -  The name of the property of interest.

Returns:

The found MetaProperty or null if it doesn't exist

Since:

1.6.1

See:

MetaObjectProtocol#hasProperty.

identity

public Object identity(Closure closure)

Allows the closure to be called for the object reference self.
Synonym for 'with()'.

Parameters:

closure -  the closure to call on the object.

Returns:

result of calling the closure

Since:

1.0

inject

public Object inject(Closure closure)

Iterates through the given Object, passing in the first value to
the closure along with the first item. The result is passed back (injected) into
the closure along with the second item. The new result is injected back into
the closure along with the third item and so on until further iteration of
the object is not possible. Also known as foldLeft in functional parlance.

Parameters:

closure -       a closure.

Returns:

the result of the last closure call

Since:

1.8.7

See:

Collection#inject(Object, Closure).

inject

public Object inject(Object initialValue, Closure closure)

Iterates through the given Object, passing in the initial value to
the closure along with the first item. The result is passed back (injected) into
the closure along with the second item. The new result is injected back into
the closure along with the third item and so on until further iteration of
the object is not possible. Also known as foldLeft in functional parlance.

Parameters:

initialValue -  some initial value.

closure -       a closure.

Returns:

the result of the last closure call

Since:

1.5.0

See:

Collection#inject(Object, Closure).

inspect

public String inspect()

Inspects returns the String that matches what would be typed into a
terminal to create this object.

Returns:

a String that matches what would be typed into a terminal to
        create this object. e.g. [1, 'hello'].inspect() -> [1, "hello"]

Since:

1.0

invokeMethod

public Object invokeMethod(String method, Object arguments)

Provide a dynamic method invocation method which can be overloaded in
classes to implement dynamic proxies easily.

Parameters:

method -     the name of the method to call.

arguments -  the arguments to use.

Returns:

the result of the method call

Since:

1.0

is

public boolean is(Object other)

Identity check. Since == is overridden in Groovy with the meaning of equality
we need some fallback to check for object identity.  Invoke using the
'is' method, like so: def same = this.is(that)

Parameters:

other -  an object to compare identity with.

Returns:

true if self and other are both references to the same
        instance, false otherwise

Since:

1.0

isCase

public boolean isCase(Object switchValue)

Method for overloading the behavior of the 'case' method in switch statements.
The default implementation handles arrays types but otherwise simply delegates
to Object#equals, but this may be overridden for other types. In this example:

 switch( a ) {
  case b: //some code
}

"some code" is called when b.isCase( a ) returns
true.

Parameters:

switchValue -  the switch value.

Returns:

true if the switchValue is deemed to be equal to the caseValue

Since:

1.0

iterator

public Iterator iterator()

Attempts to create an Iterator for the given object by first
converting it to a Collection.

Returns:

an Iterator for the given Object.

Since:

1.0

See:

DefaultTypeTransformation#asCollection.

metaClass

public MetaClass metaClass(Closure closure)

Sets/updates the metaclass for a given object to a closure.

Parameters:

closure -  the closure representing the new metaclass.

Returns:

the new metaclass value

Since:

1.6.0

print

public void print(Object value)

Print a value formatted Groovy style to self if it
is a Writer, otherwise to the standard output stream.

Parameters:

value -  the value to print.

Since:

1.0

print

public void print(PrintWriter out)

Print to a console in interactive format.

Parameters:

out -   the PrintWriter used for printing.

Since:

1.0

printf

public void printf(String format, Object[] values)

Printf to a console (Only works with JDK1.5 or later).

Parameters:

format -  a format string.

values -  values referenced by the format specifiers in the format string..

Since:

1.0

printf

public void printf(String format, Object arg)

Prints a formatted string using the specified format string and
arguments.

Examples:

printf ( "Hello, %s!\n" , [ "world" ] as String[] )
printf ( "Hello, %s!\n" , [ "Groovy" ])
printf ( "%d + %d = %d\n" , [ 1 , 2 , 1+2 ] as Integer[] )
printf ( "%d + %d = %d\n" , [ 3 , 3 , 3+3 ])

( 1..5 ).each { printf ( "-- %d\n" , [ it ] as Integer[] ) }
( 1..5 ).each { printf ( "-- %d\n" , [ it ] as int[] ) }
( 0x41..0x45 ).each { printf ( "-- %c\n" , [ it ] as char[] ) }
( 07..011 ).each { printf ( "-- %d\n" , [ it ] as byte[] ) }
( 7..11 ).each { printf ( "-- %d\n" , [ it ] as short[] ) }
( 7..11 ).each { printf ( "-- %d\n" , [ it ] as long[] ) }
( 7..11 ).each { printf ( "-- %5.2f\n" , [ it ] as float[] ) }
( 7..11 ).each { printf ( "-- %5.2g\n" , [ it ] as double[] ) }

Parameters:

format -  A format string.

arg

 -     Argument which is referenced by the format specifiers in the format
              string.  The type of arg should be one of Object[], List,
              int[], short[], byte[], char[], boolean[], long[], float[], or double[]..

Since:

1.0

println

public void println()

Print a linebreak to the standard output stream.

Since:

1.0

println

public void println(Object value)

Print a value formatted Groovy style (followed by a newline) to self
if it is a Writer, otherwise to the standard output stream.

Parameters:

value -  the value to print.

Since:

1.0

println

public void println(PrintWriter out)

Print to a console in interactive format.

Parameters:

out -   the PrintWriter used for printing.

Since:

1.0

putAt

public void putAt(String property, Object newValue)

Allows the subscript operator to be used to set dynamically named property values.
bean[somePropertyNameExpression] = foo. The normal property notation
of groovy is neater and more concise but only works with property names which
are known at compile time.

Parameters:

property -  the name of the property to set.

newValue -  the value to set.

Since:

1.0

respondsTo

public List respondsTo(String name, Object[] argTypes)

Returns an object satisfying Groovy truth if the implementing MetaClass responds to
a method with the given name and arguments types.

Note that this method's return value is based on realised methods and does not take into account
objects or classes that implement invokeMethod or methodMissing

This method is "safe" in that it will always return a value and never throw an exception

Parameters:

name -  The name of the method of interest.

argTypes -  The argument types to match against.

Returns:

A List of MetaMethods matching the argument types which will be empty if no matching methods exist

Since:

1.6.0

See:

MetaObjectProtocol#respondsTo.

respondsTo

public List respondsTo(String name)

Returns an object satisfying Groovy truth if the implementing MetaClass responds to
a method with the given name regardless of the arguments.

Note that this method's return value is based on realised methods and does not take into account
objects or classes that implement invokeMethod or methodMissing

This method is "safe" in that it will always return a value and never throw an exception

Parameters:

name -  The name of the method of interest.

Returns:

A List of MetaMethods matching the given name or an empty list if no matching methods exist

Since:

1.6.1

See:

MetaObjectProtocol#respondsTo.

setMetaClass

public void setMetaClass(MetaClass metaClass)

Set the metaclass for an object.

Parameters:

metaClass -  the new metaclass value.

Since:

1.6.0

sleep

public static void sleep(long milliseconds)

Sleep for so many milliseconds, even if interrupted.

Parameters:

milliseconds -  the number of milliseconds to sleep.

Since:

1.0

sleep

public static void sleep(long milliseconds, Closure onInterrupt)

Sleep for so many milliseconds, using a given closure for interrupt processing.

Parameters:

milliseconds -  the number of milliseconds to sleep.

onInterrupt
 -   interrupt handler, InterruptedException is passed to the Closure
                    as long as it returns false, the sleep continues.

Since:

1.0

split

public Collection split(Closure closure)

Splits all items into two lists based on the closure condition.
The first list contains all items matching the closure expression.
The second list all those that don't.

Parameters:

closure -  a closure condition.

Returns:

a List whose first item is the accepted values and whose second item is the rejected values

Since:

1.6.0

sprintf

public String sprintf(String format, Object[] values)

Sprintf to a string (Only works with JDK1.5 or later).

Parameters:

format -  a format string.

values -  values referenced by the format specifiers in the format string..

Returns:

the resulting formatted string

Since:

1.5.0

sprintf

public String sprintf(String format, Object arg)

Returns a formatted string using the specified format string and
arguments.

Parameters:

format -  A format string.

arg

 -     Argument which is referenced by the format specifiers in the format
              string.  The type of arg should be one of Object[], List,
              int[], short[], byte[], char[], boolean[], long[], float[], or double[]..

Returns:

the resulting printf'd string

Since:

1.5.0

toString

public String toString()

Create a String representation of this object.

Returns:

a string.

Since:

1.0

use

public Object use(Class categoryClass, Closure closure)

Scoped use method

Parameters:

categoryClass -  a category class to use.

closure -        the closure to invoke with the category in place.

Returns:

the value returned from the closure

Since:

1.0

use

public Object use(List categoryClassList, Closure closure)

Scoped use method with list of categories.

Parameters:

categoryClassList -  a list of category classes.

closure -            the closure to invoke with the categories in place.

Returns:

the value returned from the closure

Since:

1.0

use

public Object use(Object[] array)

Allows you to use a list of categories, specifying the list as varargs.
use(CategoryClass1, CategoryClass2) { ... }
This method saves having to wrap the the category
classes in a list.

Parameters:

array -  a list of category classes and a Closure.

Returns:

the value returned from the closure

Since:

1.0

with

public Object with(Closure closure)

Allows the closure to be called for the object reference self.

Any method invoked inside the closure will first be invoked on the
self reference. For instance, the following method calls to the append()
method are invoked on the StringBuilder instance:

def b = new StringBuilder().with {
  append('foo')
  append('bar')
  return it
}
assert b.toString() == 'foobar'

This is commonly used to simplify object creation, such as this example:

def p = new Person().with {
  firstName = 'John'
  lastName = 'Doe'
  return it
}

Parameters:

closure -  the closure to call on the object.

Returns:

result of calling the closure

Since:

1.5.0

                        Overview
                        Package
                        Class
                        Tree
                        Deprecated
                        Index
                        Help

            Groovy JDK


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

<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>CacheStats (Apache Jena ARQ)</title>
<meta name="date" content="2013-05-11">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

org.apache.jena.atlas.lib

Interface CacheStats<K,V>

All Superinterfaces:

Cache<K,V>

All Known Implementing Classes:

CacheStatsAtomic, CacheStatsSimple

public interface CacheStats<K,V>
extends Cache<K,V>

A cache with some readable statistics

Method Summary

Methods

Modifier and Type
Method and Description

long
getCacheEjects()

long
getCacheEntries()

long
getCacheHits()

long
getCacheMisses()

Methods inherited from interface org.apache.jena.atlas.lib.Cache

clear, containsKey, get, isEmpty, keys, put, remove, setDropHandler, size

Method Detail

getCacheEntries

long getCacheEntries()

getCacheHits

long getCacheHits()

getCacheMisses

long getCacheMisses()

getCacheEjects

long getCacheEjects()

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

Licenced under the Apache License, Version 2.0

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
    <settings type="mainUI">
        <setting class="com.bookmarkanator.core.SettingItem"
                 operation="com.bookmarkanator.ui.fxui.Main-class-com.bookmarkanator.bookmarks.HTMLTextBookmark">
            com.bookmarkanator.ui.fxui.bookmarks.TextBookmarkUI
        </setting>
        <setting class="com.bookmarkanator.core.SettingItem"
                 operation="com.bookmarkanator.ui.fxui.Main-class-com.bookmarkanator.bookmarks.TerminalBookmark">
            com.bookmarkanator.ui.fxui.bookmarks.TerminalBookmarkUI
        </setting>
        <setting class="com.bookmarkanator.core.SettingItem"
                 operation="com.bookmarkanator.ui.fxui.Main-class-com.bookmarkanator.bookmarks.SequenceBookmark">
            com.bookmarkanator.ui.fxui.bookmarks.SequenceBookmarkUI
        </setting>
        <setting class="com.bookmarkanator.core.SettingItem"
                 operation="com.bookmarkanator.ui.fxui.Main-class-com.bookmarkanator.bookmarks.FileBookmark">
            com.bookmarkanator.ui.fxui.bookmarks.FileBookmarkUI
        </setting>
        <setting class="com.bookmarkanator.core.SettingItem"
                 operation="com.bookmarkanator.ui.fxui.Main-class-com.bookmarkanator.bookmarks.WebBookmark">
            com.bookmarkanator.ui.fxui.bookmarks.WebBookmarkUI
        </setting>
        <setting class="com.bookmarkanator.core.SettingItem"
                 operation="com.bookmarkanator.ui.fxui.Main-class-com.bookmarkanator.bookmarks.EncryptedBookmark">
            com.bookmarkanator.ui.fxui.bookmarks.EncryptedBookmarkUI
        </setting>
    </settings>
    <settings type="bootstrap">
        <setting class="com.bookmarkanator.core.SettingItem" operation="com.bookmarkanator.bookmarks.TerminalBookmark">
            com.bookmarkanator.bookmarks.TerminalBookmark
        </setting>
        <setting class="com.bookmarkanator.core.SettingsItemList" operation="module-locations">/Users/lloyd1/Bookmark-anator</setting>
        <setting class="com.bookmarkanator.core.SettingItem" operation="com.bookmarkanator.bookmarks.SequenceBookmark">
            com.bookmarkanator.bookmarks.SequenceBookmark
        </setting>
        <setting class="com.bookmarkanator.core.SettingItem" operation="com.bookmarkanator.bookmarks.EncryptedBookmark">
            com.bookmarkanator.bookmarks.EncryptedBookmark
        </setting>
        <setting class="com.bookmarkanator.core.SettingsItemList" operation="bookmark-io-config">/Users/lloyd1/Bookmark-anator/bookmarks.xml</setting>
        <setting class="com.bookmarkanator.core.SettingItem" operation="com.bookmarkanator.bookmarks.TextBookmark">
            com.bookmarkanator.bookmarks.TextBookmark
        </setting>
        <setting class="com.bookmarkanator.core.SettingItem" operation="com.bookmarkanator.bookmarks.WebBookmark">
            com.bookmarkanator.bookmarks.WebBookmark
        </setting>
        <setting class="com.bookmarkanator.core.SettingsItemList" operation="bookmark-io-class">com.bookmarkanator.io.FileIO</setting>
    </settings>
</root>


text:
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Sample.RabbitMQ.SqlServer;

namespace Sample.RabbitMQ.SqlServer.Migrations
{
    [DbContext(typeof(AppDbContext))]
    [Migration("20191205032949_FirstMigration")]
    partial class FirstMigration
    {
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "3.0.0")
                .HasAnnotation("Relational:MaxIdentifierLength", 128)
                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

            modelBuilder.Entity("Sample.RabbitMQ.SqlServer.Person", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("int")
                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

                    b.Property<string>("Name")
                        .HasColumnType("nvarchar(max)");

                    b.HasKey("Id");

                    b.ToTable("Persons");
                });
#pragma warning restore 612, 618
        }
    }
}


text:
using System.Linq;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VSSDK.Tools.VsIdeTesting;
using NuPattern.ComponentModel.Composition;
using NuPattern.Runtime.Composition;
using NuPattern.Runtime.IntegrationTests.SampleVsix;

namespace NuPattern.Runtime.IntegrationTests
{
    [TestClass]
    public class EventsIntegrationSpec
    {
        internal static readonly IAssertion Assert = new Assertion();

        [TestClass]
        public class GivenExportedSourcePublisherAndSubscriber
        {
            private IComponentModel globalContainer;
            private INuPatternCompositionService compositionService;

            [TestInitialize]
            public void Initialize()
            {
                this.globalContainer = VsIdeTestHostContext.ServiceProvider.GetService<SComponentModel, IComponentModel>();
                this.compositionService = VsIdeTestHostContext.ServiceProvider.GetService<INuPatternCompositionService>();
            }

            [HostType("VS IDE")]
            [TestMethod, TestCategory("Integration")]
            public void WhenSourceRaised_ThenSubscriberNotified()
            {
                //// MefLogger.Log();

                var source = this.globalContainer.GetService<EventSource>();
                var subscriber = this.globalContainer.GetService<EventSubscriber>();

                Assert.Equal(0, subscriber.ChangedProperties.Count);

                source.RaisePropertyChanged("Foo");

                Assert.Contains("Foo", subscriber.ChangedProperties);

                source.RaisePropertyChanged("Bar");

                Assert.Contains("Bar", subscriber.ChangedProperties);
            }

            [HostType("VS IDE")]
            [TestMethod, TestCategory("Integration")]
            public void WhenRetrievingEventExportMetadata_ThenContainsDescription()
            {
                var info = this.compositionService
                    .GetExports<IObservableEvent, IComponentMetadata>()
                    .Where(x => x.Metadata.ExportingType == typeof(EventPublisher))
                    .First();

                Assert.Equal("Raised when the source property changes", info.Metadata.Description);
            }
        }
    }
}


text:
package de.codemakers.bot.supreme.commands.impl.moderation.util;

import de.codemakers.bot.supreme.commands.Command;
import de.codemakers.bot.supreme.commands.CommandCategory;
import de.codemakers.bot.supreme.commands.arguments.ArgumentList;
import de.codemakers.bot.supreme.commands.invoking.Invoker;
import de.codemakers.bot.supreme.entities.MessageEvent;
import de.codemakers.bot.supreme.util.Standard;
import de.codemakers.util.XMLUtil;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.MessageBuilder;
import net.dv8tion.jda.core.entities.Guild;
import org.jdom2.Element;
import org.jdom2.output.Format;
import de.codemakers.bot.supreme.permission.PermissionFilter;

/**
 * BackupCommand
 *
 * @author Panzer1119
 */
public class BackupCommand extends Command {

    public static final String GUILD = "guild";
    public static final String ID = "id";
    public static final String NAME = "name";
    public static final String GUILD_AFK_CHANNEL_ID = "afk_channel_id";
    public static final String GUILD_AFK_CHANNEL_NAME = "afk_channel_name";
    public static final String GUILD_AFK_TIMEOUT = "afk_timeout";
    public static final String GUILD_VERIFICATION_LEVEL_KEY = "verification_level";
    public static final String GUILD_EXPLICIT_CONTENT_LEVEL_KEY = "explicit_content_level";
    public static final String GUILD_REGION_KEY = "region";
    public static final String GUILD_MFA_LEVEL_KEY = "mfa_level";
    public static final String ICON_ID = "icon_id";
    public static final String ICON_URL = "icon_url";
    public static final String SPLASH_ID = "splash_id";
    public static final String SPLASH_URL = "splash_url";
    public static final String ROLE = "role";
    public static final String ROLE_ID = "role_id";
    public static final String ROLE_NAME = "role_name";
    public static final String MEMBER = "member";
    public static final String USER_ID = "member_id";
    public static final String USER_NAME = "member_name";
    public static final String POSITION = "position";
    public static final String POSITION_RAW = "position_raw";
    public static final String COLOR = "color";
    public static final String HOISTED = "hoisted";
    public static final String MANAGED = "managed";
    public static final String MENTIONABLE = "mentionable";
    public static final String STANDARD = "standard";
    public static final String PERMISSIONS_RAW = "permissions_raw";
    public static final String PERMISSION = "permission";
    public static final String PERMISSION_OVERRIDE_ROLE = "permission_override_role";
    public static final String PERMISSION_OVERRIDE_MEMBER = "permission_override_member";
    public static final String PERMISSION_OVERRIDE_ALLOWED_RAW = "permission_override_allowed_raw";
    public static final String PERMISSION_OVERRIDE_INHERIT_RAW = "permission_override_inherit_raw";
    public static final String PERMISSION_OVERRIDE_DENIED_RAW = "permission_override_denied_raw";
    public static final String TEXT_CHANNEL = "text_channel";
    public static final String TOPIC = "topic";
    public static final String NSFW = "nsfw";
    public static final String VOICE_CHANNEL = "voice_channel";
    public static final String BITRATE = "bitrate";
    public static final String USER_LIMIT = "user_limit";
    public static final String EMOTE = "emote";
    public static final String IMAGE_URL = "image_url";

    @Override
    public void initInvokers() {
        addInvokers(Invoker.createInvoker("backup", this));
    }

    @Override
    public boolean called(Invoker invoker, ArgumentList arguments, MessageEvent event) {
        return true;
    }

    @Override
    public void action(Invoker invoker, ArgumentList arguments, MessageEvent event) {
        try {
            final Guild guild = event.getGuild();
            final Element rootElement = new Element(GUILD);
            rootElement.addContent(new Element(ID).setText(guild.getId()));
            rootElement.addContent(new Element(NAME).setText(guild.getName()));
            rootElement.addContent(new Element(GUILD_AFK_CHANNEL_ID).setText(((guild.getAfkChannel() == null) ? "" : guild.getAfkChannel().getId())));
            rootElement.addContent(new Element(GUILD_AFK_CHANNEL_NAME).setText(((guild.getAfkChannel() == null) ? "" : guild.getAfkChannel().getName())));
            rootElement.addContent(new Element(GUILD_AFK_TIMEOUT).setText("" + guild.getAfkTimeout().getSeconds()));
            rootElement.addContent(new Element(GUILD_VERIFICATION_LEVEL_KEY).setText("" + guild.getVerificationLevel().getKey()));
            rootElement.addContent(new Element(GUILD_EXPLICIT_CONTENT_LEVEL_KEY).setText("" + guild.getExplicitContentLevel().getKey()));
            rootElement.addContent(new Element(GUILD_REGION_KEY).setText("" + guild.getRegion().getKey()));
            rootElement.addContent(new Element(GUILD_MFA_LEVEL_KEY).setText("" + guild.getRequiredMFALevel().getKey()));
            rootElement.addContent(new Element(ICON_ID).setText(((guild.getIconId()) == null) ? "" : guild.getIconId()));
            rootElement.addContent(new Element(ICON_URL).setText(((guild.getIconUrl()) == null) ? "" : guild.getIconUrl()));
            rootElement.addContent(new Element(SPLASH_ID).setText(((guild.getSplashId()) == null) ? "" : guild.getSplashId()));
            rootElement.addContent(new Element(SPLASH_URL).setText(((guild.getSplashUrl()) == null) ? "" : guild.getSplashUrl()));
            try {
                guild.getRoles().stream().filter((role) -> !role.isManaged()).forEach((role) -> {
                    try {
                        final Element element = new Element(ROLE);
                        rootElement.addContent(element);
                        element.addContent(new Element(ID).setText(role.getId()));
                        element.addContent(new Element(NAME).setText(role.getName()));
                        element.addContent(new Element(POSITION).setText("" + role.getPosition()));
                        element.addContent(new Element(POSITION_RAW).setText("" + role.getPositionRaw()));
                        element.addContent(new Element(COLOR).setText(((role.getColor() == null) ? "" : ("" + role.getColor().getRGB()))));
                        element.addContent(new Element(PERMISSIONS_RAW).setText("" + role.getPermissionsRaw()));
                        element.addContent(new Element(HOISTED).setText("" + role.isHoisted()));
                        //element.addContent(new Element(MANAGED).setText("" + role.isManaged())); //TODO Shouldn't managed things also be saved?
                        element.addContent(new Element(MENTIONABLE).setText("" + role.isMentionable()));
                        if (role.isPublicRole()) {
                            element.addContent(new Element(STANDARD));
                        }
                    } catch (Exception ex) {
                        System.err.println("BACKUP Role Intern Error: " + ex);
                    }
                });
            } catch (Exception ex) {
                System.err.println("BACKUP Role Error: " + ex);
            }
            try {
                guild.getTextChannels().stream().forEach((textChannel) -> {
                    try {
                        final Element element = new Element(TEXT_CHANNEL);
                        rootElement.addContent(element);
                        element.addContent(new Element(ID).setText(textChannel.getId()));
                        element.addContent(new Element(NAME).setText(textChannel.getName()));
                        element.addContent(new Element(POSITION).setText("" + textChannel.getPosition()));
                        element.addContent(new Element(POSITION_RAW).setText("" + textChannel.getPositionRaw()));
                        element.addContent(new Element(TOPIC).setText(((textChannel.getTopic()) == null) ? "" : textChannel.getTopic()));
                        element.addContent(new Element(NSFW).setText("" + textChannel.isNSFW()));
                        if (textChannel.getIdLong() == (guild.getSystemChannel() != null ? guild.getSystemChannel() : guild.getDefaultChannel()).getIdLong()) {
                            element.addContent(new Element(STANDARD));
                        }
                        textChannel.getPermissionOverrides().stream().forEach((permissionOverride) -> {
                            if (permissionOverride.isRoleOverride()) {
                                final Element element_permission_override = new Element(PERMISSION_OVERRIDE_ROLE);
                                element.addContent(element_permission_override);
                                element_permission_override.addContent(new Element(ROLE_ID).setText(permissionOverride.getRole().getId()));
                                element_permission_override.addContent(new Element(ROLE_NAME).setText(permissionOverride.getRole().getName()));
                                element_permission_override.addContent(new Element(PERMISSION_OVERRIDE_ALLOWED_RAW).setText("" + permissionOverride.getAllowedRaw()));
                                element_permission_override.addContent(new Element(PERMISSION_OVERRIDE_INHERIT_RAW).setText("" + permissionOverride.getInheritRaw()));
                                element_permission_override.addContent(new Element(PERMISSION_OVERRIDE_DENIED_RAW).setText("" + permissionOverride.getDeniedRaw()));
                            } else if (permissionOverride.isMemberOverride()) {
                                final Element element_permission_override = new Element(PERMISSION_OVERRIDE_MEMBER);
                                element.addContent(element_permission_override);
                                element_permission_override.addContent(new Element(USER_ID).setText(permissionOverride.getMember().getUser().getId()));
                                element_permission_override.addContent(new Element(USER_NAME).setText(permissionOverride.getMember().getUser().getName()));
                                element_permission_override.addContent(new Element(PERMISSION_OVERRIDE_ALLOWED_RAW).setText("" + permissionOverride.getAllowedRaw()));
                                element_permission_override.addContent(new Element(PERMISSION_OVERRIDE_INHERIT_RAW).setText("" + permissionOverride.getInheritRaw()));
                                element_permission_override.addContent(new Element(PERMISSION_OVERRIDE_DENIED_RAW).setText("" + permissionOverride.getDeniedRaw()));
                            }
                        });
                    } catch (Exception ex) {
                        System.err.println("BACKUP TextChannel Intern Error: " + ex);
                    }
                });
            } catch (Exception ex) {
                System.err.println("BACKUP TextChannel Error: " + ex);
            }
            try {
                guild.getVoiceChannels().stream().forEach((voiceChannel) -> {
                    try {
                        final Element element = new Element(VOICE_CHANNEL);
                        rootElement.addContent(element);
                        element.addContent(new Element(ID).setText(voiceChannel.getId()));
                        element.addContent(new Element(NAME).setText(voiceChannel.getName()));
                        element.addContent(new Element(POSITION).setText("" + voiceChannel.getPosition()));
                        element.addContent(new Element(POSITION_RAW).setText("" + voiceChannel.getPositionRaw()));
                        element.addContent(new Element(BITRATE).setText("" + voiceChannel.getBitrate()));
                        element.addContent(new Element(USER_LIMIT).setText("" + voiceChannel.getUserLimit()));
                        if (voiceChannel.getIdLong() == guild.getAfkChannel().getIdLong()) {
                            element.addContent(new Element(STANDARD));
                        }
                        voiceChannel.getPermissionOverrides().stream().forEach((permissionOverride) -> {
                            if (permissionOverride.isRoleOverride()) {
                                final Element element_permission_override = new Element(PERMISSION_OVERRIDE_ROLE);
                                element.addContent(element_permission_override);
                                element_permission_override.addContent(new Element(ROLE_ID).setText(permissionOverride.getRole().getId()));
                                element_permission_override.addContent(new Element(ROLE_NAME).setText(permissionOverride.getRole().getName()));
                                element_permission_override.addContent(new Element(PERMISSION_OVERRIDE_ALLOWED_RAW).setText("" + permissionOverride.getAllowedRaw()));
                                element_permission_override.addContent(new Element(PERMISSION_OVERRIDE_INHERIT_RAW).setText("" + permissionOverride.getInheritRaw()));
                                element_permission_override.addContent(new Element(PERMISSION_OVERRIDE_DENIED_RAW).setText("" + permissionOverride.getDeniedRaw()));
                            } else if (permissionOverride.isMemberOverride()) {
                                final Element element_permission_override = new Element(PERMISSION_OVERRIDE_MEMBER);
                                element.addContent(element_permission_override);
                                element_permission_override.addContent(new Element(USER_ID).setText(permissionOverride.getMember().getUser().getId()));
                                element_permission_override.addContent(new Element(USER_NAME).setText(permissionOverride.getMember().getUser().getName()));
                                element_permission_override.addContent(new Element(PERMISSION_OVERRIDE_ALLOWED_RAW).setText("" + permissionOverride.getAllowedRaw()));
                                element_permission_override.addContent(new Element(PERMISSION_OVERRIDE_INHERIT_RAW).setText("" + permissionOverride.getInheritRaw()));
                                element_permission_override.addContent(new Element(PERMISSION_OVERRIDE_DENIED_RAW).setText("" + permissionOverride.getDeniedRaw()));
                            }
                        });
                    } catch (Exception ex) {
                        System.err.println("BACKUP VoiceChannel Intern Error: " + ex);
                    }
                });
            } catch (Exception ex) {
                System.err.println("BACKUP VoiceChannel Error: " + ex);
            }
            try {
                guild.getEmotes().stream().filter((emote) -> !emote.isManaged()).forEach((emote) -> {
                    try {
                        final Element element = new Element(EMOTE);
                        rootElement.addContent(element);
                        element.addContent(new Element(ID).setText(emote.getId()));
                        element.addContent(new Element(NAME).setText(emote.getName()));
                        element.addContent(new Element(IMAGE_URL).setText(emote.getImageUrl()));
                        //element.addContent(new Element(MANAGED).setText("" + emote.isManaged())); //TODO Shouldn't managed things also be saved?
                    } catch (Exception ex) {
                        System.err.println("BACKUP Emote Intern Error: " + ex);
                    }
                });
            } catch (Exception ex) {
                System.err.println("BACKUP Emote Error: " + ex);
            }
            final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            XMLUtil.save(rootElement, Format.getPrettyFormat(), byteArrayOutputStream); //TODO Make the Format changable
            event.sendFile(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()), guild.getId() + ".xml", new MessageBuilder().appendFormat("Saved all Roles, Emotes, Text- and VoiceChannels from \"%s\" (ID: %s)", guild.getName(), guild.getId()).build());
            byteArrayOutputStream.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    @Override
    public void executed(boolean success, MessageEvent event) {
        System.out.println("[INFO] Command '" + getCommandID() + "' was executed!");
    }

    @Override
    public EmbedBuilder getHelp(Invoker invoker, EmbedBuilder builder) {
        builder.addField("SOON", "This command is not fully implemented yet!", false);
        return builder;
    }

    @Override
    public PermissionFilter getPermissionFilter() {
        return Standard.STANDARD_PERMISSIONFILTER_GUILD_OWNER_BOT_COMMANDER_BOT_ADMIN;
    }

    @Override
    public String getCommandID() {
        return getClass().getName();
    }

    @Override
    public CommandCategory getCommandCategory() {
        return Standard.COMMANDCATEGORY_MODERATION_UTIL;
    }

}


text:
package org.adonai.reader.chordpro;

import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.adonai.Chord;
import org.adonai.ChordPart;
import org.adonai.InvalidChordException;
import org.adonai.NoteEntryType;
import org.adonai.model.Line;
import org.adonai.model.LinePart;
import org.adonai.model.Song;
import org.adonai.model.SongPart;
import org.adonai.model.SongPartType;
import org.adonai.model.SongStructItem;
import org.adonai.reader.ReaderUtil;
import org.adonai.reader.text.TextfileReader;
import org.adonai.reader.text.TextfileReaderParam;
import org.adonai.services.SongRepairer;

@Slf4j public class ChordProFileReader {

  private ReaderUtil readerUtil = new ReaderUtil();

  private String strip(final String identifier, final String line) {
    if (line.startsWith(identifier)) {
      String stripped = line.substring(identifier.length()).replace("}", "");
      return stripped;
    }

    return null;

  }

  public Song read(final List<String> lines) {

    Song newSong = new Song();

    //Textfile extracted
    if (! String.join(",", lines).contains("{")) {
      String text = String.join("#", lines);
      String subtext = text.substring(0, text.indexOf("CCLI-Liednummer"));
      List<String> asText = Arrays.asList(subtext.split("#"));

      TextfileReaderParam textfileReaderParam = new TextfileReaderParam();
      textfileReaderParam.setEmptyLineIsNewPart(true);
      textfileReaderParam.setWithTitle(true);
      TextfileReader textfileReader = new TextfileReader();
      newSong = textfileReader.read(asText,textfileReaderParam);
    }
    else { //Ordinary chordpro

      SongPart newSongPart = null;

      for (String next : lines) {

        if (next.startsWith("CCLI-Liednummer"))
          break;

        String stripped = strip("{title: ", next);
        if (stripped != null) {
          newSong.setTitle(stripped.toUpperCase());
          continue;
        }

        stripped = strip("{key: ", next);
        if (stripped != null) {
          ChordPart chordPart = new ChordPart(stripped);
          if (chordPart.isMoll()) {
            chordPart.transpose(3, NoteEntryType.INCREMENT);
            stripped = chordPart.getNote().toString();
          }
          newSong.setOriginalKey(stripped);
          newSong.setCurrentKey(stripped);
          continue;
        }

        stripped = strip("{comment: ", next);
        if (stripped != null) {
          stripped = stripped.replaceAll("\\d", "").trim().toUpperCase();
          newSongPart = new SongPart();
          newSongPart.setId(UUID.randomUUID().toString());
          newSong.getSongParts().add(newSongPart);
          if (!newSong.getSongParts().contains(newSongPart)) //TODO extract to lib
            newSong.getSongParts().add(newSongPart);
          SongStructItem songStructItem = new SongStructItem();
          songStructItem.setPartId(newSongPart.getId());
          newSong.getStructItems().add(songStructItem);

          newSongPart.setSongPartType(readerUtil.extractTypeOrDefault(stripped));

          continue;

        } else if (next.startsWith("{")) {
          log.warn("Data " + next + " is not imported yet");
          continue;
        }

        if (!next.trim().isEmpty()) {
          log.debug("Line " + next + " is imported");
          String[] tokens = next.trim().split("\\[");
          Line newLine = new Line();
          newSongPart.getLines().add(newLine);
          for (String nextToken : tokens) {
            String[] innerTokens = nextToken.split("]");

            LinePart newLinePart = new LinePart();

            if (innerTokens.length > 1) {
              String nextChord = innerTokens[0];
              try {
                Chord chord = new Chord(nextChord);
                newLinePart.setChord(chord.toString());
              } catch (InvalidChordException e) {
                log.warn("Chord " + nextChord + " could not be extracted");
              }
              newLinePart.setText(innerTokens[1]);
            } else {
              if (nextToken.contains("]")) {
                String nextChord = nextToken.replace("]", "");
                try {
                  Chord chord = new Chord(nextChord);
                  newLinePart.setChord(chord.toString());
                } catch (InvalidChordException e) {
                  log.warn("Chord " + nextChord + " could not be extracted");
                }
              } else
                newLinePart.setText(nextToken);

            }
            log.debug("Extracted linepart: " + newLinePart);
            newLine.getLineParts().add(newLinePart);

          }

        }

      }
    }

    SongRepairer songRepairer = new SongRepairer();
    songRepairer.repairSong(newSong);

    return newSong;

  }

}


text:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_design_support_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    >

  <android.support.design.widget.CoordinatorLayout
      android:id="@+id/rootLayout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      >

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >

      <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="?attr/colorPrimary"
          app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
          app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
          />
      <android.support.design.widget.TabLayout
          android:id="@+id/tab_layout"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

    </android.support.design.widget.AppBarLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="100dp"
        android:orientation="vertical"
        >

      <android.support.v4.view.ViewPager
          android:id="@+id/pager"
          android:layout_width="wrap_content"
          android:layout_height="match_parent">

      </android.support.v4.view.ViewPager>
    </LinearLayout>

  </android.support.design.widget.CoordinatorLayout>
  <android.support.design.widget.NavigationView
      android:id="@+id/navigation_view"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_gravity="start"
      app:headerLayout="@layout/nav_header"
      app:itemIconTint="#484848"
      app:itemTextColor="#484848"
      app:menu="@menu/nav_menu"
      />

</android.support.v4.widget.DrawerLayout>


text:
//----------------------------------------------------------------------
//This code is developed as part of the Java CoG Kit project
//The terms of the license can be found at http://www.cogkit.org/license
//This message may not be removed or altered.
//----------------------------------------------------------------------

/*
 * Created on Mar 28, 2014
 */
package org.griphyn.vdl.mapping.nodes;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import k.rt.FutureListener;
import k.thr.Yield;

import org.globus.cog.karajan.compiled.nodes.Node;
import org.globus.cog.karajan.futures.FutureNotYetAvailable;
import org.griphyn.vdl.karajan.WaitingThreadsMonitor;
import org.griphyn.vdl.mapping.OOBYield;
import org.griphyn.vdl.mapping.RootHandle;
import org.griphyn.vdl.type.Field;

public abstract class AbstractFutureDataNode extends AbstractDataNode {
	private volatile boolean closed;
	private List<FutureListener> listeners;
	private AtomicInteger writeRefCount;

	public AbstractFutureDataNode(Field field) {
	    super(field);
    }

	@Override
    protected boolean addListener0(FutureListener l) {
        if (this.listeners == null) {
            this.listeners = new ArrayList<FutureListener>();
        }
        this.listeners.add(l);
        return this.isClosed();
    }

	@Override
	protected void notifyListeners() {
        List<FutureListener> l;
        synchronized(this) {
            l = this.listeners;
            this.listeners = null;
        }
        if (l != null) {
            for (FutureListener ll : l) {
                ll.futureUpdated(this);
                WaitingThreadsMonitor.removeThread(ll);
            }
        }
    }

    @Override
    public boolean isClosed() {
        return closed;
    }

    protected void setClosed(boolean closed) {
        this.closed = closed;
    }

    public void closeShallow() {
        if (this.closed) {
            return;
        }
        this.closed = true;
        postCloseActions();
    }

    public void closeDeep() {
        closeShallow();
    }

    public void setValue(Object value) {
        throw new IllegalArgumentException(this.getFullName()
            + " cannot set the value of a " + this.getType());
    }

    @Override
    protected void clean0() {
        listeners = null;
        super.clean0();
    }

    @Override
    public synchronized void setWriteRefCount(int count) {
        this.writeRefCount = new AtomicInteger(count);
    }

    @Override
    public int updateWriteRefCount(int delta) {
        int count = this.writeRefCount.addAndGet(delta);

        if (count < 0) {
            throw new IllegalArgumentException("Write reference count mismatch for " + this + ". Count is " + count);
        }

        if (logger.isDebugEnabled()) {
            logger.debug(this + " writeRefCount " + count);
        }
        if (variableTracer.isEnabled()) {
            RootHandle root = getRoot();
            variableTracer.trace(root.getThread(), root.getLine(), getDisplayableName() + " WRITE_REF_COUNT " + delta + " -> " + count);
        }
        if (count == 0) {
            if (variableTracer.isEnabled()) {
                RootHandle root = getRoot();
                variableTracer.trace(root.getThread(), root.getLine(), getDisplayableName() + " CLOSE write ref count is zero");
            }
            closeDeep();
            this.writeRefCount = null;
        }
        return count;
    }

    @Override
    public synchronized void waitFor(Node who) {
        if (!closed) {
            if (logger.isDebugEnabled()) {
                logger.debug("Waiting for " + this);
            }

            Yield y = new FutureNotYetAvailable(this);
            y.getState().addTraceElement(who);
            throw y;
        }
        else {
            if (logger.isDebugEnabled()) {
                logger.debug("Do not need to wait for " + this);
            }
            checkNoValue();
        }
    }

    @Override
    public synchronized void waitFor() throws OOBYield {
        if (!closed) {
            if (logger.isDebugEnabled()) {
                logger.debug("Waiting for " + this);
            }

            throw new OOBYield(new FutureNotYetAvailable(this), this);
        }
        else {
            if (logger.isDebugEnabled()) {
                logger.debug("Do not need to wait for " + this);
            }
            checkNoValue();
        }
    }

    protected abstract void checkNoValue();
}


text:
package swing;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;

public class Test {

    static void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        JPanel jPanel = new javax.swing.JPanel();
        UIDefaults defaults = UIManager.getDefaults();
        Object cl = defaults.get("ClassLoader");
        ClassLoader uiClassLoader =
          (cl != null) ? (ClassLoader)cl : jPanel.getClass().getClassLoader();
        try {
                String className = (String)defaults.get(jPanel.getUIClassID());
                if (className != null) {
                    Class cls = (Class)defaults.get(className);
                    if (cls == null) {
                        if (uiClassLoader == null) {
                            Method m = SwingUtilities.class.getDeclaredMethod("loadSystemClass", String.class);
                            m.setAccessible(true);
                            m.invoke(null, className);
                            // cls = SwingUtilities.loadSystemClass(className);
                            throw new RuntimeException("FAIL");
                        }
                        else {
                            cls = uiClassLoader.loadClass(className);
                        }
                    }
                }
            }
            catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            catch (ClassCastException e) {
                e.printStackTrace();
            }

        jPanel.setVisible(true);
    }
}


text:
'use strict';

// https://github.com/gulpjs/gulp/blob/master/docs/README.md
let gulp = require('gulp');
// https://github.com/shama/webpack-stream
let webpackStream = require('webpack-stream');

let WebpackConfig = require('./WebpackConfig');
let descriptor = require('./package.json');

let config = new WebpackConfig(descriptor, {
  src: './src',
  dist: './dist'
});

gulp.task(
  `${config.name}/build`,
  function () {
    return gulp
      .src(config.path.src)
      .pipe(webpackStream(config.get()))
      .pipe(gulp.dest(config.path.dist));
  }
);

gulp.task(
  `${config.name}/watch`, function () {
    return gulp
      .watch(`${config.path.src}**/*.*`, [
        `${config.name}/build`
      ]);
  }
);


text:
<!DOCTYPE html>

<title>海报生成器</title>
<meta charset="utf-8">
<meta name="format-detection" content="telephone=no" />
<meta name="format-detection" content="email=no" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

		我也要玩

长按图片保存