text:
package org.apache.sqoop.util;

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;

public final class FileSystemUtil {
  private FileSystemUtil() {
  }

  /**
   * Creates a fully-qualified path object.
   * @param path the path to fully-qualify with its file system URI.
   * @param conf the current Hadoop configuration.
   * @return a new path representing the same location as the input path,
   * but with a fully-qualified URI. Returns {@code null} if provided path is {@code null};
   */
  public static Path makeQualified(Path path, Configuration conf)
      throws IOException {
    if (null == path) {
      return null;
    }

    return path.getFileSystem(conf).makeQualified(path);
  }
}

redpajama_set_name: RedPajamaGithub


text:
.DEFAULT_GOAL:=help
# image settings for the docker image name, tags and container name while running
IMAGE_NAME?=gcr.io/ci-30-162810/mysql
TAGS?=latest
NAME=ci-mysql

VERSIONS=5.7 5.6 5.5 5.1
BUILD_VERSIONS=$(addprefix build-,$(VERSIONS))
PUSH_VERSIONS=$(addprefix push-,$(VERSIONS))

# parent image name
FROM=$(shell head -n1 Dockerfile | cut -d " " -f 2)
# the first tag and the remaining tags split up
FIRST_TAG=$(firstword $(TAGS))
ADDITIONAL_TAGS=$(wordlist 2, $(words $(TAGS)), $(TAGS))
# the image name which will be build
IMAGE=$(IMAGE_NAME):$(FIRST_TAG)
# options to use for running the image, can be extended by FLAGS variable
OPTS=--name $(NAME) -t $(FLAGS)
# the docker command which can be configured by the DOCKER_OPTS variable
DOCKER=docker $(DOCKER_OPTS)

# default build settings
REMOVE=true
FORCE_RM=true
NO_CACHE=false

.PHONY: build
build: pull-from pull build-image test ## build the image for the first tag and tag it for additional tags, (includes dirty hack to create db2 database with privileged mode)

.PHONY: build-image
build-image: ## build the image
	$(DOCKER) build --rm=$(REMOVE) --force-rm=$(FORCE_RM) --no-cache=$(NO_CACHE) --build-arg TAG_NAME=$(TAGS) -t $(IMAGE) .
	@for tag in $(ADDITIONAL_TAGS); do \
		$(DOCKER) tag $(IMAGE) $(IMAGE_NAME):$$tag; \
	done

.PHONY: pull
pull: ## pull image from registry
	-$(DOCKER) pull $(IMAGE)

.PHONY: pull-from
pull-from: ## pull parent image
	$(DOCKER) pull $(FROM)

.PHONY: push
push: ## push container to registry
	@for tag in $(TAGS); do \
		$(DOCKER) push $(IMAGE_NAME):$$tag; \
	done

.PHONY: build-all
build-all: $(BUILD_VERSIONS) ## build Docker image for every MySQL version

.PHONY: build-%s
build-%:
	make build TAGS=$*v$(FIRST_TAG)

.PHONY: push-all
push-all: $(PUSH_VERSIONS) ## push Docker image for every MySQL version

.PHONY: push-%s
push-%:
	make push TAGS=$*v$(FIRST_TAG)

.PHONY: tag-all
tag-all:
	@for version in $(VERSIONS); do \
		echo "Tagging: $${version}$(FIRST_TAG)"; \
		git tag -a -f -m "$${version}$(FIRST_TAG)" $${version}$(FIRST_TAG); \
	done

.PHONY: run
run: ## run container
	$(DOCKER) run --rm $(OPTS) -p 3306:3306 $(IMAGE)

.PHONY: daemon
daemon: rmf ## run container in daemon mode
	$(DOCKER) run -d $(OPTS) -p 3306:3306 $(IMAGE)

.PHONY: shell
shell: ## start interactive container with bash
	$(DOCKER) run --rm -i --entrypoint=/bin/bash $(OPTS) $(IMAGE) --

.PHONY: test
test: daemon ## test if image starts and database becomes ready afterwards
	$(DOCKER) exec -t $(NAME) database_ready
	-$(DOCKER) rm -f $(NAME)

.PHONY: rmf
rmf: ## remove container by name
	-$(DOCKER) rm -f $(NAME)

.PHONY: rmi
rmi: ## remove image with all tags
	@for tag in $(TAGS); do \
		$(DOCKER) rmi $(IMAGE_NAME):$$tag; \
	done

.PHONY: help
help:
	@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'


text:
package datastore

import (
	"bytes"
	"encoding/base64"
	"errors"
	"fmt"
	"math"
	"reflect"
	"time"

	"go.chromium.org/luci/gae/service/blobstore"
)

var (
	minTime = time.Unix(int64(math.MinInt64)/1e6, (int64(math.MinInt64)%1e6)*1e3)
	maxTime = time.Unix(int64(math.MaxInt64)/1e6, (int64(math.MaxInt64)%1e6)*1e3)

	utcTestTime = time.Unix(0, 0)
)

// IndexSetting indicates whether or not a Property should be indexed by the
// datastore.
type IndexSetting bool

// ShouldIndex is the default, which is why it must assume the zero value,
// even though it's werid :(.
const (
	ShouldIndex IndexSetting = false
	NoIndex     IndexSetting = true
)

func (i IndexSetting) String() string {
	if i {
		return "NoIndex"
	}
	return "ShouldIndex"
}

// PropertyConverter may be implemented by the pointer-to a struct field which
// is serialized by the struct PropertyLoadSaver from GetPLS. Its ToProperty
// will be called on save, and it's FromProperty will be called on load (from
// datastore). The method may do arbitrary computation, and if it encounters an
// error, may return it.  This error will be a fatal error (as defined by
// PropertyLoadSaver) for the struct conversion.
//
// Example:
//   type Complex complex
//   func (c *Complex) ToProperty() (ret Property, err error) {
//     // something like:
//     err = ret.SetValue(fmt.Sprint(*c), true)
//     return
//   }
//   func (c *Complex) FromProperty(p Property) (err error) {
//     ... load *c from p ...
//   }
//
//   type MyStruct struct {
//     Complexity []Complex // acts like []complex, but can be serialized to DS
//   }
type PropertyConverter interface {
	// TODO(riannucci): Allow a convertable to return multiple values.  This is
	// eminently doable (as long as the single-slice restriction is kept).  It
	// could also cut down on the amount of reflection necessary when resolving
	// a path in a struct (in the struct loading routine in helper).

	ToProperty() (Property, error)
	FromProperty(Property) error
}

// PropertyType is a single-byte representation of the type of data contained
// in a Property. The specific values of this type information are chosen so
// that the types sort according to the order of types as sorted by the
// datastore.
//
// Note that indexes may only contain values of the following types:
//   PTNull
//   PTInt
//   PTBool
//   PTFloat
//   PTString
//   PTGeoPoint
//   PTKey
//
// The biggest impact of this is that if you do a Projection query, you'll only
// get back Properties with the above types (e.g. if you store a PTTime value,
// then Project on it, you'll get back a PTInt value). For convenience, Property
// has a Project(PropertyType) method which will side-cast to your intended
// type. If you project into a structure with the high-level Interface
// implementation, or use StructPLS, this conversion will be done for you
// automatically, using the type of the destination field to cast.
type PropertyType byte

//go:generate stringer -type=PropertyType

// These constants are in the order described by
//   https://cloud.google.com/appengine/docs/go/datastore/entities#Go_Value_type_ordering
// with a slight divergence for the Int/Time split.
//
// NOTE: this enum can only occupy 7 bits, because we use the high bit to encode
// indexed/non-indexed, and we additionally require that all valid values and
// all INVERTED valid values must never equal 0xFF or 0x00. The reason for this
// constraint is that we must always be able to create a byte that sorts before
// and after it.
//
// See "./serialize".WriteProperty and "impl/memory".increment for more info.
const (
	// PTNull represents the 'nil' value. This is only directly visible when
	// reading/writing a PropertyMap. If a PTNull value is loaded into a struct
	// field, the field will be initialized with its zero value. If a struct with
	// a zero value is saved from a struct, it will still retain the field's type,
	// not the 'nil' type. This is in contrast to other GAE languages such as
	// python where 'None' is a distinct value than the 'zero' value (e.g. a
	// StringProperty can have the value "" OR None).
	//
	// PTNull is a Projection-query type
	PTNull PropertyType = iota

	// PTInt is always an int64.
	//
	// This is a Projection-query type, and may be projected to PTTime.
	PTInt
	PTTime

	// PTBool represents true or false
	//
	// This is a Projection-query type.
	PTBool

	// PTBytes represents []byte
	PTBytes

	// PTString is used to represent all strings (text).
	//
	// PTString is a Projection-query type and may be projected to PTBytes or
	// PTBlobKey.
	PTString

	// PTFloat is always a float64.
	//
	// This is a Projection-query type.
	PTFloat

	// PTGeoPoint is a Projection-query type.
	PTGeoPoint

	// PTKey represents a *Key object.
	//
	// PTKey is a Projection-query type.
	PTKey

	// PTBlobKey represents a blobstore.Key
	PTBlobKey

	// PTPropertyMap represents a PropertyMap object.
	//
	// This is typicaly used to represent GAE *datastore.Entity objects.
	PTPropertyMap

	// PTUnknown is a placeholder value which should never show up in reality.
	//
	// NOTE: THIS MUST BE LAST VALUE FOR THE init() ASSERTION BELOW TO WORK.
	PTUnknown
)

func init() {
	if PTUnknown > 0x7e {
		panic(
			"PTUnknown (and therefore PropertyType) exceeds 0x7e. This conflicts " +
				"with serialize.WriteProperty's use of the high bit to indicate " +
				"NoIndex and/or \"impl/memory\".increment's ability to guarantee " +
				"incrementability.")
	}
}

// Property is a value plus an indicator of whether the value should be
// indexed. Name and Multiple are stored in the PropertyMap object.
type Property struct {
	// value is the Property's value. It is stored in an internal, opaque type and
	// should not be directly exported to consumers. Rather, it can be accessed
	// in its original value via Value().
	//
	// Specifically:
	//	- []byte- and string-based values are stored in a bytesByteSequence and
	//	  stringByteSequence respectively.
	value interface{}

	indexSetting IndexSetting
	propType     PropertyType
}

// MkProperty makes a new indexed* Property and returns it. If val is an
// invalid value, this panics (so don't do it). If you want to handle the error
// normally, use SetValue(..., ShouldIndex) instead.
//
// *indexed if val is not an unindexable type like []byte.
func MkProperty(val interface{}) Property {
	ret := Property{}
	if err := ret.SetValue(val, ShouldIndex); err != nil {
		panic(err)
	}
	return ret
}

// MkPropertyNI makes a new Property (with noindex set to true), and returns
// it. If val is an invalid value, this panics (so don't do it). If you want to
// handle the error normally, use SetValue(..., NoIndex) instead.
func MkPropertyNI(val interface{}) Property {
	ret := Property{}
	if err := ret.SetValue(val, NoIndex); err != nil {
		panic(err)
	}
	return ret
}

// PropertyTypeOf returns the PT* type of the given Property-compatible
// value v. If checkValid is true, this method will also ensure that time.Time
// and GeoPoint have valid values.
func PropertyTypeOf(v interface{}, checkValid bool) (PropertyType, error) {
	switch x := v.(type) {
	case nil:
		return PTNull, nil
	case int64:
		return PTInt, nil
	case float64:
		return PTFloat, nil
	case bool:
		return PTBool, nil
	case []byte:
		return PTBytes, nil
	case blobstore.Key:
		return PTBlobKey, nil
	case string:
		return PTString, nil
	case *Key:
		// TODO(riannucci): Check key for validity in its own namespace?
		return PTKey, nil
	case time.Time:
		err := error(nil)
		if checkValid && (x.Before(minTime) || x.After(maxTime)) {
			err = errors.New("time value out of range")
		}
		if checkValid && !timeLocationIsUTC(x.Location()) {
			err = fmt.Errorf("time value has wrong Location: %v", x.Location())
		}
		return PTTime, err
	case GeoPoint:
		err := error(nil)
		if checkValid && !x.Valid() {
			err = errors.New("invalid GeoPoint value")
		}
		return PTGeoPoint, err
	case PropertyMap:
		return PTPropertyMap, nil
	default:
		return PTUnknown, fmt.Errorf("gae: Property has bad type %T", v)
	}
}

// RoundTime rounds a time.Time to microseconds, which is the (undocumented)
// way that the AppEngine SDK stores it.
func RoundTime(t time.Time) time.Time {
	return t.Round(time.Microsecond)
}

// TimeToInt converts a time value to a datastore-appropriate integer value.
//
// This method truncates the time to microseconds and drops the timezone,
// because that's the (undocumented) way that the appengine SDK does it.
func TimeToInt(t time.Time) int64 {
	if t.IsZero() {
		return 0
	}

	t = RoundTime(t)
	return t.Unix()*1e6 + int64(t.Nanosecond()/1e3)
}

// IntToTime converts a datastore time integer into its time.Time value.
func IntToTime(v int64) time.Time {
	if v == 0 {
		return time.Time{}
	}
	return RoundTime(time.Unix(int64(v/1e6), int64((v%1e6)*1e3))).UTC()
}

// timeLocationIsUTC tests if two time.Location are equal.
//
// This is tricky using the standard time API, as time is implicitly normalized
// to UTC and all equality checks are performed relative to that normalized
// time. To compensate, we instantiate two new time.Time using the respective
// Locations.
func timeLocationIsUTC(l *time.Location) bool {
	return time.Date(1970, 1, 1, 0, 0, 0, 0, l).Equal(utcTestTime)
}

// UpconvertUnderlyingType takes an object o, and attempts to convert it to
// its native datastore-compatible type. e.g. int16 will convert to int64, and
// `type Foo string` will convert to `string`.
func UpconvertUnderlyingType(o interface{}) interface{} {
	if o == nil {
		return o
	}

	v := reflect.ValueOf(o)
	t := v.Type()
	switch v.Kind() {
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		o = v.Int()
	case reflect.Uint8, reflect.Uint16, reflect.Uint32:
		o = int64(v.Uint())
	case reflect.Bool:
		o = v.Bool()
	case reflect.String:
		if t != typeOfBSKey {
			o = v.String()
		}
	case reflect.Float32, reflect.Float64:
		o = v.Float()
	case reflect.Slice:
		if t.Elem().Kind() == reflect.Uint8 {
			o = v.Bytes()
		}
	case reflect.Struct:
		if t == typeOfTime {
			tim := v.Interface().(time.Time)
			if !tim.IsZero() {
				o = RoundTime(v.Interface().(time.Time))
			}
		}
	}

	switch t {
	case typeOfKey:
		if v.IsNil() {
			return nil
		}
	}
	return o
}

func (Property) isAPropertyData() {}

func (p Property) estimateSize() int64 { return p.EstimateSize() }

// Slice implements the PropertyData interface.
func (p Property) Slice() PropertySlice { return PropertySlice{p} }

// Clone implements the PropertyData interface.
func (p Property) Clone() PropertyData { return p }

// IsZero implements the PropertyData interface.
func (p Property) IsZero() bool {
	return reflect.ValueOf(p.Value()).IsZero()
}

func (p Property) String() string {
	switch p.propType {
	case PTString, PTBlobKey:
		return fmt.Sprintf("%s(%q)", p.propType, p.Value())
	case PTBytes:
		return fmt.Sprintf("%s(%#x)", p.propType, p.Value())
	default:
		return fmt.Sprintf("%s(%v)", p.propType, p.Value())
	}
}

// Value returns the current value held by this property. It's guaranteed to
// be a valid value type (i.e. `p.SetValue(p.Value(), true)` will never return
// an error).
func (p *Property) Value() interface{} {
	switch p.propType {
	case PTBytes:
		return p.value.(byteSequence).bytes()
	case PTString:
		return p.value.(byteSequence).string()
	case PTBlobKey:
		return blobstore.Key(p.value.(byteSequence).string())
	case PTPropertyMap:
		return p.value.(PropertyMap)
	default:
		return p.value
	}
}

// IndexSetting says whether or not the datastore should create indicies for
// this value.
func (p *Property) IndexSetting() IndexSetting { return p.indexSetting }

// Type is the PT* type of the data contained in Value().
func (p *Property) Type() PropertyType { return p.propType }

// SetValue sets the Value field of a Property, and ensures that its value
// conforms to the permissible types. That way, you're guaranteed that if you
// have a Property, its value is valid.
//
// value is the property value. The valid types are:
//	- int64
//	- time.Time
//	- bool
//	- string
//    (only the first 1500 bytes is indexable)
//	- []byte
//    (only the first 1500 bytes is indexable)
//	- blobstore.Key
//    (only the first 1500 bytes is indexable)
//	- float64
//	- *Key
//	- GeoPoint
// This set is smaller than the set of valid struct field types that the
// datastore can load and save. A Property Value cannot be a slice (apart
// from []byte); use multiple Properties instead. Also, a Value's type
// must be explicitly on the list above; it is not sufficient for the
// underlying type to be on that list. For example, a Value of "type
// myInt64 int64" is invalid. Smaller-width integers and floats are also
// invalid. Again, this is more restrictive than the set of valid struct
// field types.
//
// A value may also be the nil interface value; this is equivalent to
// Python's None but not directly representable by a Go struct. Loading
// a nil-valued property into a struct will set that field to the zero
// value.
func (p *Property) SetValue(value interface{}, is IndexSetting) (err error) {
	pt := PTNull
	if value != nil {
		value = UpconvertUnderlyingType(value)
		if pt, err = PropertyTypeOf(value, true); err != nil {
			return
		}
	}

	// Convert value to internal Property storage type.
	switch t := value.(type) {
	case string:
		value = stringByteSequence(t)
	case blobstore.Key:
		value = stringByteSequence(t)
	case []byte:
		value = bytesByteSequence(t)
	case time.Time:
		value = RoundTime(t)
	case PropertyMap:
		value = t.Clone()
	}

	p.propType = pt
	p.value = value
	p.indexSetting = is
	return
}

// IndexTypeAndValue returns the type and value of the Property as it would
// show up in a datastore index.
//
// This is used to operate on the Property as it would be stored in a datastore
// index, specifically for serialization and comparison.
//
// The returned type will be the PropertyType used in the index. The returned
// value will be one of:
//	- bool
//	- int64
//	- float64
//	- string
//	- []byte
//	- GeoPoint
//	- PropertyMap
//	- *Key
func (p Property) IndexTypeAndValue() (PropertyType, interface{}) {
	switch t := p.propType; t {
	case PTNull, PTInt, PTBool, PTFloat, PTGeoPoint, PTPropertyMap, PTKey:
		return t, p.Value()

	case PTTime:
		return PTInt, TimeToInt(p.value.(time.Time))

	case PTString, PTBytes, PTBlobKey:
		return PTString, p.value.(byteSequence).value()

	default:
		panic(fmt.Errorf("unknown PropertyType: %s", t))
	}
}

// Project can be used to project a Property retrieved from a Projection query
// into a different datatype. For example, if you have a PTInt property, you
// could Project(PTTime) to convert it to a time.Time. The following conversions
// are supported:
//   PTString <-> PTBlobKey
//   PTString <-> PTBytes
//   PTXXX <-> PTXXX (i.e. identity)
//   PTInt <-> PTTime
//   PTNull <-> Anything
func (p *Property) Project(to PropertyType) (interface{}, error) {
	if to == PTNull {
		return nil, nil
	}

	pt, v := p.propType, p.value
	switch pt {
	case PTBytes, PTString, PTBlobKey:
		v := v.(byteSequence)
		switch to {
		case PTBytes:
			return v.bytes(), nil
		case PTString:
			return v.string(), nil
		case PTBlobKey:
			return blobstore.Key(v.string()), nil
		}

	case PTTime:
		switch to {
		case PTInt:
			return TimeToInt(v.(time.Time)), nil
		case PTTime:
			return v, nil
		}

	case PTInt:
		switch to {
		case PTInt:
			return v, nil
		case PTTime:
			return IntToTime(v.(int64)), nil
		}

	case to:
		return v, nil

	case PTNull:
		switch to {
		case PTInt:
			return int64(0), nil
		case PTTime:
			return time.Time{}, nil
		case PTBool:
			return false, nil
		case PTBytes:
			return []byte(nil), nil
		case PTString:
			return "", nil
		case PTFloat:
			return float64(0), nil
		case PTGeoPoint:
			return GeoPoint{}, nil
		case PTKey:
			return nil, nil
		case PTBlobKey:
			return blobstore.Key(""), nil
		case PTPropertyMap:
			return PropertyMap{}, nil
		}
	}
	return nil, fmt.Errorf("unable to project %s to %s", pt, to)
}

func cmpFloat(a, b float64) int {
	if a == b {
		return 0
	}
	if a > b {
		return 1
	}
	return -1
}

// Less returns true iff p would sort before other.
//
// This uses datastore's index rules for sorting (see GetIndexTypeAndValue).
func (p *Property) Less(other *Property) bool {
	return p.Compare(other) < 0
}

// Equal returns true iff p and other have identical index representations.
//
// This uses datastore's index rules for sorting (see GetIndexTypeAndValue).
func (p *Property) Equal(other *Property) bool {
	return p.Compare(other) == 0
}

// Compare compares this Property to another, returning a trinary value
// indicating where it would sort relative to the other in datastore.
//
// It returns:
//	<0 if the Property would sort before `other`.
//	>0 if the Property would after before `other`.
//	0 if the Property equals `other`.
//
// This uses datastore's index rules for sorting (see GetIndexTypeAndValue).
func (p *Property) Compare(other *Property) int {
	if p.indexSetting && !other.indexSetting {
		return 1
	} else if !p.indexSetting && other.indexSetting {
		return -1
	}

	at, av := p.IndexTypeAndValue()
	bt, bv := other.IndexTypeAndValue()
	if cmp := int(at) - int(bt); cmp != 0 {
		return cmp
	}

	switch t := at; t {
	case PTNull:
		return 0

	case PTBool:
		a, b := av.(bool), bv.(bool)
		if a == b {
			return 0
		}
		if a && !b {
			return 1
		}
		return -1

	case PTInt:
		a, b := av.(int64), bv.(int64)
		if a == b {
			return 0
		}
		if a > b {
			return 1
		}
		return -1

	case PTString:
		return cmpByteSequence(p.value.(byteSequence), other.value.(byteSequence))

	case PTFloat:
		return cmpFloat(av.(float64), bv.(float64))

	case PTGeoPoint:
		a, b := av.(GeoPoint), bv.(GeoPoint)
		cmp := cmpFloat(a.Lat, b.Lat)
		if cmp != 0 {
			return cmp
		}
		return cmpFloat(a.Lng, b.Lng)

	case PTTime:
		a, b := av.(time.Time), bv.(time.Time)
		if a.Equal(b) {
			return 0
		}
		if a.Before(b) {
			return 1
		}
		return -1

	case PTKey:
		a, b := av.(*Key), bv.(*Key)
		if a.Equal(b) {
			return 0
		}
		if b.Less(a) {
			return 1
		}
		return -1

	default:
		panic(fmt.Errorf("uncomparable type: %s", t))
	}
}

// EstimateSize estimates the amount of space that this Property would consume
// if it were committed as part of an entity in the real production datastore.
//
// It uses https://cloud.google.com/appengine/articles/storage_breakdown?csw=1
// as a guide for these values.
func (p *Property) EstimateSize() int64 {
	switch p.Type() {
	case PTNull:
		return 1
	case PTBool:
		return 1 + 4
	case PTInt, PTTime, PTFloat:
		return 1 + 8
	case PTGeoPoint:
		return 1 + (8 * 2)
	case PTString:
		return 1 + int64(len(p.Value().(string)))
	case PTBlobKey:
		return 1 + int64(len(p.Value().(blobstore.Key)))
	case PTBytes:
		return 1 + int64(len(p.Value().([]byte)))
	case PTKey:
		return 1 + p.Value().(*Key).EstimateSize()
	}
	panic(fmt.Errorf("Unknown property type: %s", p.Type().String()))
}

// GQL returns a correctly formatted Cloud Datastore GQL literal which
// is valid for a comparison value in the `WHERE` clause.
//
// The flavor of GQL that this emits is defined here:
//   https://cloud.google.com/datastore/docs/apis/gql/gql_reference
//
// NOTE: GeoPoint values are emitted with speculated future syntax. There is
// currently no syntax for literal GeoPoint values.
func (p *Property) GQL() string {
	v := p.Value()
	switch p.propType {
	case PTNull:
		return "NULL"

	case PTInt, PTFloat, PTBool:
		return fmt.Sprint(v)

	case PTString:
		return gqlQuoteString(v.(string))

	case PTBytes:
		return fmt.Sprintf("BLOB(%q)",
			base64.URLEncoding.EncodeToString(v.([]byte)))

	case PTBlobKey:
		return fmt.Sprintf("BLOBKEY(%s)", gqlQuoteString(
			string(v.(blobstore.Key))))

	case PTKey:
		return v.(*Key).GQL()

	case PTTime:
		return fmt.Sprintf("DATETIME(%s)", v.(time.Time).Format(time.RFC3339Nano))

	case PTGeoPoint:
		// note that cloud SQL doesn't support this yet, but take a good guess at
		// it.
		v := v.(GeoPoint)
		return fmt.Sprintf("GEOPOINT(%v, %v)", v.Lat, v.Lng)
	}
	panic(fmt.Errorf("bad type: %s", p.propType))
}

// PropertySlice is a slice of Properties. It implements sort.Interface.
//
// PropertySlice holds multiple Properties. Writing a PropertySlice to datastore
// implicitly marks the property as "multiple", even if it only has one element.
type PropertySlice []Property

func (PropertySlice) isAPropertyData() {}

// Clone implements the PropertyData interface.
func (s PropertySlice) Clone() PropertyData { return s.Slice() }

// Slice implements the PropertyData interface.
func (s PropertySlice) Slice() PropertySlice {
	if len(s) == 0 {
		return nil
	}
	return append(make(PropertySlice, 0, len(s)), s...)
}

// IsZero implements the PropertyData interface.
func (s PropertySlice) IsZero() bool {
	return len(s) == 0
}

func (s PropertySlice) estimateSize() (v int64) {
	for _, prop := range s {
		// Use the public one so we don't have to copy.
		v += prop.estimateSize()
	}
	return
}

func (s PropertySlice) Len() int           { return len(s) }
func (s PropertySlice) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s PropertySlice) Less(i, j int) bool { return s[i].Less(&s[j]) }

// MetaGetter is a subinterface of PropertyLoadSaver, but is also used to
// abstract the meta argument for RawInterface.GetMulti.
type MetaGetter interface {
	// GetMeta will get information about the field which has the struct tag in
	// the form of `gae:"$<key>[,<default>]?"`.
	//
	// It returns the value, if any, and true iff the value was retrieved.
	//
	// Supported metadata types are:
	//   int64  - may have default (ascii encoded base-10)
	//   string - may have default
	//   Toggle - MUST have default ("true" or "false")
	//   *Key    - NO default allowed
	//
	// Struct fields of type Toggle (which is an Auto/On/Off) require you to
	// specify a value of 'true' or 'false' for the default value of the struct
	// tag, and GetMeta will return the combined value as a regular boolean true
	// or false value.
	// Example:
	//   type MyStruct struct {
	//     CoolField int64 `gae:"$id,1"`
	//   }
	//   val, err := helper.GetPLS(&MyStruct{}).GetMeta("id")
	//   // val == 1
	//   // err == nil
	//
	//   val, err := helper.GetPLS(&MyStruct{10}).GetMeta("id")
	//   // val == 10
	//   // err == nil
	//
	//   type MyStruct struct {
	//     TFlag Toggle `gae:"$flag1,true"`  // defaults to true
	//     FFlag Toggle `gae:"$flag2,false"` // defaults to false
	//     // BadFlag  Toggle `gae:"$flag3"` // ILLEGAL
	//   }
	GetMeta(key string) (interface{}, bool)
}

// PropertyLoadSaver may be implemented by a user type, and Interface will
// use this interface to serialize the type instead of trying to automatically
// create a serialization codec for it with helper.GetPLS.
type PropertyLoadSaver interface {
	// Load takes the values from the given map and attempts to save them into
	// the underlying object (usually a struct or a PropertyMap). If a fatal
	// error occurs, it's returned via error. If non-fatal conversion errors
	// occur, error will be a MultiError containing one or more ErrFieldMismatch
	// objects.
	Load(PropertyMap) error

	// Save returns the current property as a PropertyMap. if withMeta is true,
	// then the PropertyMap contains all the metadata (e.g. '$meta' fields)
	// which was held by this PropertyLoadSaver.
	Save(withMeta bool) (PropertyMap, error)
}

// MetaGetterSetter is the subset of PropertyLoadSaver which pertains to
// getting and saving metadata.
//
// A *struct may implement this interface to provide metadata which is
// supplimental to the variety described by GetPLS. For example, this could be
// used to implement a parsed-out $kind or $id.
type MetaGetterSetter interface {
	MetaGetter

	// GetAllMeta returns a PropertyMap with all of the metadata in this
	// MetaGetterSetter. If a metadata field has an error during serialization,
	// it is skipped.
	//
	// If a *struct is implementing this, then it only needs to return the
	// metadata fields which would be returned by its GetMeta implementation, and
	// the `GetPLS` implementation will add any statically-defined metadata
	// fields. So if GetMeta provides $id, but there's a simple tagged field for
	// $kind, this method is only expected to return a PropertyMap with "$id".
	GetAllMeta() PropertyMap

	// SetMeta allows you to set the current value of the meta-keyed field.
	// It returns true iff the field was set.
	SetMeta(key string, val interface{}) bool
}

// PropertyData is an interface implemented by Property and PropertySlice to
// identify themselves as valid PropertyMap values.
type PropertyData interface {
	// isAPropertyData is a tag that forces PropertyData implementations to only
	// be supplied by this package.
	isAPropertyData()

	// Slice returns a PropertySlice representation of this PropertyData.
	//
	// The returned PropertySlice is a clone of the original data. Consequently,
	// Property-modifying methods such as SetValue should NOT be
	// called on the results.
	Slice() PropertySlice

	// estimateSize estimates the aggregate size of the property data.
	estimateSize() int64

	// Clone creates a duplicate copy of this PropertyData.
	Clone() PropertyData

	// IsZero returns true if the property has the zero value or is an empty PropertySlice.
	IsZero() bool
}

// PropertyMap represents the contents of a datastore entity in a generic way.
// It maps from property name to a list of property values which correspond to
// that property name. It is the spiritual successor to PropertyList from the
// original SDK.
//
// PropertyMap may contain "meta" values, which are keyed with a '$' prefix.
// Technically the datastore allows arbitrary property names, but all of the
// SDKs go out of their way to try to make all property names valid programming
// language tokens. Special values must correspond to a single Property...
// corresponding to 0 is equivalent to unset, and corresponding to >1 is an
// error. So:
//
//   {
//     "$id": {MkProperty(1)}, // GetProperty("id") -> 1, nil
//     "$foo": {}, // GetProperty("foo") -> nil, ErrMetaFieldUnset
//     // GetProperty("bar") -> nil, ErrMetaFieldUnset
//     "$meep": {
//       MkProperty("hi"),
//       MkProperty("there")}, // GetProperty("meep") -> nil, error!
//   }
//
// Additionally, Save returns a copy of the map with the meta keys omitted (e.g.
// these keys are not going to be serialized to the datastore).
type PropertyMap map[string]PropertyData

var _ PropertyLoadSaver = PropertyMap(nil)

// Load implements PropertyLoadSaver.Load
func (pm PropertyMap) Load(props PropertyMap) error {
	for k, v := range props {
		pm[k] = v.Clone()
	}
	return nil
}

// Save implements PropertyLoadSaver.Save by returning a copy of the
// current map data.
func (pm PropertyMap) Save(withMeta bool) (PropertyMap, error) {
	if len(pm) == 0 {
		return PropertyMap{}, nil
	}
	ret := make(PropertyMap, len(pm))
	for k, v := range pm {
		if withMeta || !isMetaKey(k) {
			ret[k] = v.Clone()
		}
	}
	return ret, nil
}

// Clone returns a copy of this PropertyMap.
func (pm PropertyMap) Clone() PropertyMap {
	ret := PropertyMap{}
	for k, v := range pm {
		ret[k] = v.Clone()
	}
	return ret
}

// GetMeta implements PropertyLoadSaver.GetMeta, and returns the current value
// associated with the metadata key.
func (pm PropertyMap) GetMeta(key string) (interface{}, bool) {
	pslice := pm.Slice("$" + key)
	if len(pslice) > 0 {
		return pslice[0].Value(), true
	}
	return nil, false
}

// GetAllMeta implements PropertyLoadSaver.GetAllMeta.
func (pm PropertyMap) GetAllMeta() PropertyMap {
	ret := make(PropertyMap, 8)
	for k, v := range pm {
		if isMetaKey(k) {
			ret[k] = v.Clone()
		}
	}
	return ret
}

// SetMeta implements PropertyLoadSaver.SetMeta. It will only return an error
// if `val` has an invalid type (e.g. not one supported by Property).
func (pm PropertyMap) SetMeta(key string, val interface{}) bool {
	prop := Property{}
	if err := prop.SetValue(val, NoIndex); err != nil {
		return false
	}
	pm["$"+key] = prop
	return true
}

// Problem implements PropertyLoadSaver.Problem. It ALWAYS returns nil.
func (pm PropertyMap) Problem() error {
	return nil
}

// Slice returns a PropertySlice for the given key
//
// If the value associated with that key is nil, an empty slice will be
// returned. If the value is single Property, a slice of size 1 with that
// Property in it will be returned.
func (pm PropertyMap) Slice(key string) PropertySlice {
	if pdata := pm[key]; pdata != nil {
		return pdata.Slice()
	}
	return nil
}

// EstimateSize estimates the size that it would take to encode this PropertyMap
// in the production Appengine datastore. The calculation excludes metadata
// fields in the map.
//
// It uses https://cloud.google.com/appengine/articles/storage_breakdown?csw=1
// as a guide for sizes.
func (pm PropertyMap) EstimateSize() int64 {
	ret := int64(0)
	for k, vals := range pm {
		if !isMetaKey(k) {
			ret += int64(len(k))
			ret += vals.estimateSize()
		}
	}
	return ret
}

// TurnOffIdx sets NoIndex for all properties in the map.
// This method modifies the map in-place.
func (pm PropertyMap) TurnOffIdx() {
	for key, val := range pm {
		switch d := val.(type) {
		case Property:
			pm[key] = MkPropertyNI(d.Value())
		case PropertySlice:
			for i := range d {
				d[i].indexSetting = NoIndex
			}
		default:
			panic("unexpected property type")
		}
	}
}

func isMetaKey(k string) bool {
	// empty counts as a metakey since it's not a valid data key, but it's
	// not really a valid metakey either.
	return k == "" || k[0] == '$'
}

// GetMetaDefault is a helper for GetMeta, allowing a default value.
//
// If the metadata key is not available, or its type doesn't equal the
// homogenized type of dflt, then dflt will be returned.
//
// Type homogenization:
//   signed integer types -> int64
//   bool                 -> Toggle fields (bool)
//
// Example:
//   pls.GetMetaDefault("foo", 100).(int64)
func GetMetaDefault(getter MetaGetter, key string, dflt interface{}) interface{} {
	dflt = UpconvertUnderlyingType(dflt)
	cur, ok := getter.GetMeta(key)
	if !ok || (dflt != nil && reflect.TypeOf(cur) != reflect.TypeOf(dflt)) {
		return dflt
	}
	return cur
}

// byteSequence is a generic interface for an object that can be represented as
// a sequence of bytes. Its implementations are used internally by Property to
// enable zero-copy conversion and comparisons between byte sequence types.
type byteSequence interface {
	// len returns the number of bytes in the sequence.
	len() int
	// get returns the byte at the specified index.
	get(int) byte
	// value returns the sequence's primitive type.
	value() interface{}
	// string returns the sequence as a string (may cause a copy if not native).
	string() string
	// bytes returns the sequence as a []byte (may cause a copy if not native).
	bytes() []byte
	// fastCmp is an implementation-specific comparison method. If it returns
	// true in its second return value, the comparison was performed and its
	// result is in the first return value. Otherwise, the fast comparison could
	// not be performed.
	fastCmp(o byteSequence) (int, bool)
}

func cmpByteSequence(a, b byteSequence) int {
	if v, ok := a.fastCmp(b); ok {
		return v
	}

	// Byte-by-byte "slow" comparison.
	ln := a.len()
	if bln := b.len(); bln < ln {
		ln = bln
	}

	for i := 0; i < ln; i++ {
		av, bv := a.get(i), b.get(i)
		switch {
		case av < bv:
			return -1
		case av > bv:
			return 1
		}
	}

	return a.len() - b.len()
}

// bytesByteSequence is a byteSequence implementation for a byte slice.
type bytesByteSequence []byte

func (s bytesByteSequence) len() int           { return len(s) }
func (s bytesByteSequence) get(i int) byte     { return s[i] }
func (s bytesByteSequence) value() interface{} { return []byte(s) }
func (s bytesByteSequence) string() string     { return string(s) }
func (s bytesByteSequence) bytes() []byte      { return []byte(s) }
func (s bytesByteSequence) fastCmp(o byteSequence) (int, bool) {
	if t, ok := o.(bytesByteSequence); ok {
		return bytes.Compare([]byte(s), []byte(t)), true
	}
	return 0, false
}

// stringByteSequence is a byteSequence implementation for a string.
type stringByteSequence string

func (s stringByteSequence) len() int           { return len(s) }
func (s stringByteSequence) get(i int) byte     { return s[i] }
func (s stringByteSequence) value() interface{} { return string(s) }
func (s stringByteSequence) string() string     { return string(s) }
func (s stringByteSequence) bytes() []byte      { return []byte(s) }
func (s stringByteSequence) fastCmp(o byteSequence) (int, bool) {
	if t, ok := o.(stringByteSequence); ok {
		// This pattern is used for string comparison in strings.Compare.
		if string(s) == string(t) {
			return 0, true
		}
		if string(s) < string(t) {
			return -1, true
		}
		return 1, true
	}
	return 0, false
}


text:
"use strict";
function __export(m) {
    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./AggregatedReporter"));
__export(require("./FilesChange"));
__export(require("./reporter-rpc/ReporterRpcClient"));
__export(require("./reporter-rpc/ReporterRpcService"));


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>Myo Android SDK Beta Release 2: src/main/java/com/thalmic/myo Directory Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>

<link href="navtree.css" rel="stylesheet" type="text/css"/>

<link href="search/search.css" rel="stylesheet" type="text/css"/>

<link href="customdoxygen.css" rel="stylesheet" type="text/css" />

Myo Android SDK – Beta Release 2

          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)"
               onblur="searchBox.OnSearchFieldFocus(false)"
               onkeyup="searchBox.OnSearchFieldChange(event)"/>

 All Classes Functions Pages

myo Directory Reference

Directories

directory  	internal

directory  	scanner

Files

file  	AbstractDeviceListener.java

file  	Arm.java

file  	ClassifierEvent.java

file  	ControlCommand.java

file  	DeviceListener.java

file  	FirmwareVersion.java

file  	GattCallback.java

file  	GattConstants.java

file  	Hub.java

file  	Internal.java

file  	MultiListener.java

file  	Myo.java

file  	MyoGatt.java

file  	MyoUpdateParser.java

file  	Pose.java

file  	Quaternion.java

file  	Raw.java

file  	RawListener.java

file  	RawUpdateParser.java

file  	Reporter.java

file  	ScanListener.java

file  	Vector3.java

file  	XDirection.java

src

main

java

com

thalmic

myo

Copyright © 2014 Thalmic Labs Inc. Distributed under the Myo SDK license agreement. See LICENSE.txt for details.


text:
        <title>Properties</title>

Name

name

srcFile

        <title>Methods</title>

Name

srcFile


text:
namespace Disqus.NET
{
    /// <summary>
    /// <remarks>https://disqus.com/api/docs/errors/</remarks>
    /// </summary>
    public enum DisqusApiResponseCode
    {
        /// <summary>
        /// Success
        /// </summary>
        Success = 0,
        /// <summary>
        /// Endpoint not valid
        /// </summary>
        InvalidEndpoint = 1,
        /// <summary>
        /// Missing or invalid argument
        /// </summary>
        MissingOrInvalidArgument = 2,
        /// <summary>
        /// Endpoint resource not valid
        /// </summary>
        InvalidResource = 3,
        /// <summary>
        /// You must be authenticated to perform this action
        /// </summary>
        AuthenticationRequired = 4,
        /// <summary>
        /// Invalid API key
        /// </summary>
        InvalidApiKey = 5,
        /// <summary>
        /// Invalid API version
        /// </summary>
        InvalidApiVersion = 6,
        /// <summary>
        /// You cannot access this resource using %(request_method)s
        /// </summary>
        InvalidResourceHttpMethod = 7,
        /// <summary>
        /// A requested object was not found
        /// </summary>
        RequestedObjectNotFound = 8,
        /// <summary>
        /// You cannot access this resource using your %(access_type)s API key
        /// </summary>
        NoAccessToResourceWithApiKey = 9,
        /// <summary>
        /// This operation is not supported
        /// </summary>
        NotSupportedOperation = 10,
        /// <summary>
        /// Your API key is not valid on this domain
        /// </summary>
        InvalidApiKeyOnThisDomain = 11,
        /// <summary>
        /// This application does not have enough privileges to access this resource
        /// </summary>
        ApplicationHaveNoAccessToResource = 12,
        /// <summary>
        /// You have exceeded the rate limit for this resource
        /// </summary>
        ExceededResourceRateLimit = 13,
        /// <summary>
        /// You have exceeded the rate limit for your account
        /// </summary>
        ExceededAccountRateLimit = 14,
        /// <summary>
        /// There was internal server error while processing your request
        /// </summary>
        InternalServerError = 15,
        /// <summary>
        /// Your request timed out
        /// </summary>
        Timeout = 16,
        /// <summary>
        /// The authenticated user does not have access to this feature
        /// </summary>
        AuthenticatedUserHaveNoAccessToFeature = 17,
        /// <summary>
        /// The authorization signature you passed was not valid
        /// </summary>
        InvalidAuthorizationSignature = 18,
        /// <summary>
        /// You must re-submit this request with a response to the captcha challenge
        /// </summary>
        CaptchaRequired = 19,
        /// <summary>
        /// The API is currently undergoing maintenance, and your changes were saved, but will not be visible yet.
        /// </summary>
        ApiUndergoingMaintenanceAndChangesWereSaved = 20,
        /// <summary>
        /// The API is currently undergoing maintenance, and your changes could not be saved.
        /// </summary>
        ApiUndergoingMaintenanceAndChangesCouldNotBeSaved = 21,
        /// <summary>
        /// You do not have the appropriate permissions to access this resource
        /// </summary>
        NoAppropriatePermissionsToResource = 22,
        /// <summary>
        /// You must be authenticated and verified by the forum owner to perform this action
        /// </summary>
        VerificationRequired = 23,
    }
}


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

<title>R-Index</title>
<meta name="date" content="2015-01-04">
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Letter

Next Letter

Frames

No Frames

All Classes

A C D E F G I L N P R S U _

R

Review - Class in fr.jweb.app.entities

Review model class
 Contains a username, some content and a rating
 It is also associated with a product with a product PK

Review() - Constructor for class fr.jweb.app.entities.Review

Review model constructor

ReviewPosterMB - Class in fr.jweb.app.mbeans

ReviewPoster ManagedBean
 Handle the posting of a new review for a selected product

ReviewPosterMB() - Constructor for class fr.jweb.app.mbeans.ReviewPosterMB

A C D E F G I L N P R S U _

Skip navigation links

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Letter

Next Letter

Frames

No Frames

All Classes


text:
package de.ailis.gramath;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;

import java.util.Arrays;

import org.junit.Test;

/**
 * Tests the Matrix3d class.
 *
 * @author Klaus Reimer (k@ailis.de)
 * @version $Revision$
 */

public class Matrix3dTest
{
    /** A test pattern for testing matrix elements */
    private static final double[] TEST_PATTERN = new double[] { 1, 2, 3, 4, 5, 6,
        7, 8, 9 };

    /** The transposed test pattern */
    private static final double[] TEST_TRANSPOSED = new double[] { 1, 4, 7, 2, 5,
        8, 3, 6, 9 };

    /** Another test pattern for testing matrix elements */
    private static final double[] TEST_PATTERN2 = new double[] { 10, 11, 12, 13,
        14, 15, 16, 17, 18 };

    /** Array with both test patterns in it */
    private static final double[] TEST_PATTERNS = new double[] { 1, 2, 3, 4, 5,
        6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 };

    /**
     * Tests the constructors.
     */

    @Test
    public void testConstructors()
    {
        Matrix3d matrix = new ImmutableMatrix3d(TEST_PATTERN);
        assertNotSame(TEST_PATTERN, matrix.m);
        assertTrue(Arrays.equals(TEST_PATTERN, matrix.m));

        matrix = new ImmutableMatrix3d(TEST_PATTERNS, 9);
        assertNotSame(TEST_PATTERN2, matrix.m);
        assertTrue(Arrays.equals(TEST_PATTERN2, matrix.m));

        final Matrix3d matrix2 = new ImmutableMatrix3d(matrix);
        assertNotSame(matrix.m, matrix2.m);
        assertTrue(Arrays.equals(matrix.m, matrix2.m));
    }

    /**
     * Tests the toString() method.
     */

    @Test
    public void testToString()
    {
        final String s = new ImmutableMatrix3d(TEST_PATTERN).toString();
        assertEquals("[[ 1.0, 4.0, 7.0 ], [ 2.0, 5.0, 8.0 ], " +
                "[ 3.0, 6.0, 9.0 ]]", s);
    }

    /**
     * Tests the hash code method.
     */

    @Test
    public void testHashCode()
    {
        final int hash1 = new ImmutableMatrix3d(TEST_PATTERN).hashCode();
        final int hash2 = new ImmutableMatrix3d(TEST_PATTERN2).hashCode();
        assertNotEquals(hash1, hash2);
    }

    /**
     * Tests the equals method.
     */

    @Test
    public void testEquals()
    {
        final Matrix3d m1 = new ImmutableMatrix3d(TEST_PATTERN);
        final Matrix3d m2 = new ImmutableMatrix3d(TEST_PATTERN);
        final Matrix3d m3 = new ImmutableMatrix3d(TEST_PATTERN2);
        final Matrix3d m4 = new MutableMatrix3d(TEST_PATTERN);
        assertTrue(m1.equals(m1));
        assertFalse(m1.equals(null));
        assertFalse(m1.equals(m4));
        assertTrue(m1.equals(m2));
        assertFalse(m1.equals(m3));
    }

    /**
     * Tests the transpose method.
     */

    @Test
    public void testTranspose()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(TEST_PATTERN);
        final ImmutableMatrix3d result = Matrix3d.transpose(matrix);
        assertArrayEquals(TEST_TRANSPOSED, result.m, 0.001f);
    }

    /**
     * Tests the adjoint() method.
     */

    @Test
    public void testAdjoint()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(
            1, 0, 1,
            2, 4, 0,
            3, 5, 6);
        final ImmutableMatrix3d adjoint = Matrix3d.adjoint(matrix);
        assertNotSame(matrix, adjoint);
        assertArrayEquals(new double[] {
            24, 5, -4,
            -12, 3, 2,
            -2, -5, 4 }, adjoint.m, 0.001f);
    }

    /**
     * Tests the cofactor() method.
     */

    @Test
    public void testCofactor()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(
            1, 0, 1,
            2, 4, 0,
            3, 5, 6);
        final ImmutableMatrix3d cofactor = Matrix3d.cofactor(matrix);
        assertNotSame(matrix, cofactor);
        assertArrayEquals(new double[] {
            24, -12, -2,
            5, 3, -5,
            -4, 2, 4 }, cofactor.m, 0.001f);
    }

    /**
     * Tests the rotate() method.
     */

    @Test
    public void testRotate()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(
            1, 0, 0,
            0, 1, 0,
            2, 3, 1);
        final ImmutableMatrix3d result = Matrix3d
            .rotate(matrix, Math.PI / 2);
        assertNotSame(matrix, result);
        assertArrayEquals(new double[] {
            0, 1, 0,
            -1, 0, 0,
            2, 3, 1 }, result.m, 0.001f);
    }

    /**
     * Tests the translate() method.
     */

    @Test
    public void testTranslate()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(
            1, 0, 0,
            0, 1, 0,
            2, 3, 1);
        final ImmutableMatrix3d result = Matrix3d.translate(matrix, 1, 2);
        assertNotSame(matrix, result);
        assertArrayEquals(new double[] {
            1, 0, 0,
            0, 1, 0,
            3, 5, 1 }, result.m, 0.001f);
    }

    /**
     * Tests the translateX() method.
     */

    @Test
    public void testTranslateX()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(
            1, 0, 0,
            0, 1, 0,
            2, 3, 1);
        final ImmutableMatrix3d result = Matrix3d.translateX(matrix, 1);
        assertNotSame(matrix, result);
        assertArrayEquals(new double[] {
            1, 0, 0,
            0, 1, 0,
            3, 3, 1 }, result.m, 0.001f);
    }

    /**
     * Tests the translateY() method.
     */

    @Test
    public void testTranslateY()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(
            1, 0, 0,
            0, 1, 0,
            2, 3, 1);
        final ImmutableMatrix3d result = Matrix3d.translateY(matrix, 2);
        assertNotSame(matrix, result);
        assertArrayEquals(new double[] {
            1, 0, 0,
            0, 1, 0,
            2, 5, 1 }, result.m, 0.001f);
    }

    /**
     * Tests the scale() method.
     */

    @Test
    public void testScale()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(
            1, 0, 0,
            0, 1, 0,
            2, 3, 1);
        final ImmutableMatrix3d result = Matrix3d.scale(matrix, 2, 3);
        assertNotSame(matrix, result);
        assertArrayEquals(new double[] {
            2, 0, 0,
            0, 3, 0,
            2, 3, 1 }, result.m, 0.001f);
    }

    /**
     * Tests the scale() method with a single factor.
     */

    @Test
    public void testScaleWithSingleFactor()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(
            1, 0, 0,
            0, 1, 0,
            2, 3, 1);
        final ImmutableMatrix3d result = Matrix3d.scale(matrix, 2);
        assertNotSame(matrix, result);
        assertArrayEquals(new double[] {
            2, 0, 0,
            0, 2, 0,
            2, 3, 1 }, result.m, 0.001f);
    }

    /**
     * Tests the scaleX() method.
     */

    @Test
    public void testScaleX()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(
            1, 0, 0,
            0, 1, 0,
            2, 3, 1);
        final ImmutableMatrix3d result = Matrix3d.scaleX(matrix, 2);
        assertNotSame(matrix, result);
        assertArrayEquals(new double[] {
            2, 0, 0,
            0, 1, 0,
            2, 3, 1 }, result.m, 0.001f);
    }

    /**
     * Tests the scaleY() method.
     */

    @Test
    public void testScaleY()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(
            1, 0, 0,
            0, 1, 0,
            2, 3, 1);
        final ImmutableMatrix3d result = Matrix3d.scaleY(matrix, 2);
        assertNotSame(matrix, result);
        assertArrayEquals(new double[] {
            1, 0, 0,
            0, 2, 0,
            2, 3, 1 }, result.m, 0.001f);
    }

    /**
     * tests the getElement() method.
     */

    @Test
    public void testGetElement()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(
            1, 2, 3,
            4, 5, 6,
            7, 8, 9);
        assertEquals(1, matrix.getElement(0, 0), 0.001f);
        assertEquals(8, matrix.getElement(1, 2), 0.001f);
        assertEquals(9, matrix.getElement(2, 2), 0.001f);
    }

    /**
     * Tests the getElements() method.
     */

    @Test
    public void testGetElements()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(
            1, 2, 3,
            4, 5, 6,
            7, 8, 9);
        final double[] result = new double[9];
        matrix.getElements(result);
        assertNotSame(matrix.m, result);
        assertArrayEquals(matrix.m, result, 0.001f);
    }

    /**
     * Tests the multiply() method with a immutable matrix as first matrix.
     */

    @Test
    public void testMultiplyMatrixWithImmutableAsFirst()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(1, 2, 3, 4, 5,
            6, 7, 8, 9);
        final ImmutableMatrix3d result = Matrix3d
            .multiply(matrix, new MutableMatrix3d(9, 8, 7, 6, 5, 4, 3, 2, 1));
        assertNotSame(matrix, result);
        assertArrayEquals(new double[] { 90, 114, 138, 54, 69, 84, 18, 24, 30 }, result.m, 0.001f);
    }

    /**
     * Tests the multiply() method with a mutable matrix as first matrix.
     */

    @Test
    public void testMultiplyMatrixWithMutableAsFirst()
    {
        final MutableMatrix3d matrix = new MutableMatrix3d(new double[] { 1, 2,
            3, 4, 5, 6, 7, 8, 9 });
        final MutableMatrix3d result = Matrix3d
            .multiply(matrix, new ImmutableMatrix3d(new double[] {
                9, 8, 7, 6, 5, 4, 3, 2, 1 }));
        assertNotSame(matrix, result);
        assertArrayEquals(new double[] { 90, 114, 138, 54, 69, 84, 18, 24, 30 }, result.m, 0.001f);
    }

    /**
     * Tests the multiply() method.
     */

    @Test
    public void testMultiplyWithArray()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(1, 2, 3, 4, 5,
            6, 7, 8, 9);
        final ImmutableMatrix3d result = Matrix3d
            .multiply(matrix, new double[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 });
        assertNotSame(matrix, result);
        assertArrayEquals(new double[] { 90, 114, 138, 54, 69, 84, 18, 24, 30 }, result.m, 0.001f);
    }

    /**
     * Tests the multiply() method.
     */

    @Test
    public void testMultiplyArray()
    {
        final ImmutableMatrix3d matrix = new ImmutableMatrix3d(9, 8, 7, 6, 5,
            4, 3, 2, 1);
        final ImmutableMatrix3d result = Matrix3d
            .multiply(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, matrix);
        assertNotSame(matrix, result);
        assertArrayEquals(new double[] { 90, 114, 138, 54, 69, 84, 18, 24, 30 }, result.m, 0.001f);
    }
}


text:
Searchkick 3 no longer uses types, since they are deprecated in Elasticsearch 6.

If you use inheritance, add to your parent model:

```ruby
class Animal < ApplicationRecord
  searchkick inheritance: true
end
```

And do a full reindex before upgrading.

## Upgrading

Update your Gemfile:

```ruby
gem 'searchkick', '~> 3'
```

And run:

```sh
bundle update searchkick
```

We recommend you don't stem conversions anymore, so conversions for `pepper` don't affect `peppers`, but if you want to keep the old behavior, use:

```ruby
Searchkick.model_options = {
  stem_conversions: true
}
```

Searchkick 3 disables the `_all` field by default, since Elasticsearch 6 removes the ability to reindex with it. If you're on Elasticsearch 5 and still need it, add to your model:

```ruby
class Product < ApplicationRecord
  searchkick _all: true
end
```

If you use `record.reindex_async` or `record.reindex(async: true)`, replace it with:

```ruby
record.reindex(mode: :async)
```

If you use `log: true` with `boost_by`, replace it with `modifier: "ln2p"`.

If you use the `body` option and have warnings about incompatible options, remove them, as they now throw an `ArgumentError`.

Check out the [changelog](https://github.com/ankane/searchkick/blob/master/CHANGELOG.md) for the full list of changes.


text:
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
/**
 * Namespace: System.Web.UI.WebControls
 * Class:     RepeaterItemCollection
 *
 * Author:  Gaurav Vaish
 * Maintainer: gvaish@iitk.ac.in
 * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
 * Implementation: yes
 * Status:  100%
 *
 * (C) Gaurav Vaish (2002)
 */

using System;
using System.Collections;
using System.Web;
using System.Web.UI;

namespace System.Web.UI.WebControls
{
	public sealed class RepeaterItemCollection : ICollection, IEnumerable
	{
		private ArrayList items;

		public RepeaterItemCollection(ArrayList items)
		{
			this.items = items;
		}

		public int Count
		{
			get
			{
				return items.Count;
			}
		}

		public bool IsReadOnly
		{
			get
			{
				return false;
			}
		}

		public bool IsSynchronized
		{
			get
			{
				return false;
			}
		}

		public RepeaterItem this[int index]
		{
			get
			{
				return (RepeaterItem)(items[index]);
			}
		}

		public object SyncRoot
		{
			get
			{
				return this;
			}
		}

		public void CopyTo(Array array, int index)
		{
			foreach(RepeaterItem current in this)
			{
				array.SetValue(current, index++);
			}
		}

		public IEnumerator GetEnumerator()
		{
			return items.GetEnumerator();
		}
	}
}


text:
By: Yaz Khoury

## Description

Given an application for reading feeds and headlines in RSS, we must perform
a number of tests to ensure the application behaves as we expect.

> The application has been given by Udacity for the Front-End Developer Nanodegree

The following screenshot displays the application that we performed tests on:

![app preview](assets/app-prev.jpg)

The following screenshot displays the results of our test with jasmine:

![test preview](assets/test-prev.jpg)

To view the application and the test results, simply open index.html.

To view the test suites and tests performed, simply open jasmine/spec/feedreader.js

## Tests Performed

1. Ensure all feed variables are defined.
2. Ensure all feed url values are not empty.
3. Ensure all feed name values are not empty.
4. Ensure menu bar is hidden by default.
5. Ensure menu displays when clicked and disappears when clicked again.
6. Ensure feed entries are populated in the DOM upon performing asynchronous requests.
7. Ensure new feed entries are loaded upon making a new asynchronous request.

For contacting me, email me at: yaz.khoury@gmail.com


text:
import {Component, Input, Output, EventEmitter} from '@angular/core';

@Component({
  selector: 'add-site-view',
  templateUrl: 'app/add-site.template.html',
  styles: [`
    h3 {
      font-weight: bold;
      color: maroon;
    }
  `]
})
export class AddSiteComponent {
  @Input() siteId: number;
  @Output() onAdded = new EventEmitter<string>();
  @Output() onCancel = new EventEmitter();
  siteName: string;

  added() {
    if (this.siteName) {
      this.onAdded.emit(this.siteName);
    }
  }

  cancel() {
    this.onCancel.emit(null);
  }
}