text:
package org.basex.query.value.type;

import static org.basex.query.QueryError.*;
import static org.basex.query.QueryText.*;
import static org.basex.util.Token.*;

import java.math.*;
import java.util.*;
import java.util.regex.*;

import javax.xml.namespace.*;

import org.basex.query.*;
import org.basex.query.util.*;
import org.basex.query.value.item.*;
import org.basex.util.*;

/**
 * XQuery atomic types.
 *
 * @author BaseX Team 2005-15, BSD License
 * @author Christian Gruen
 */
public enum AtomType implements Type {
  /** Item type. */
  ITEM("item", null, EMPTY, false, false, false, Type.ID.ITEM),

  /** Untyped type. */
  UTY("untyped", null, XS_URI, false, false, false, Type.ID.UTY),

  /** Any type. */
  ATY("anyType", null, XS_URI, false, false, false, Type.ID.ATY),

  /** Any simple type. */
  AST("anySimpleType", null, XS_URI, false, false, false, Type.ID.AST),

  /** Any atomic type. */
  AAT("anyAtomicType", ITEM, XS_URI, false, false, false, Type.ID.AAT) {
    @Override
    public Atm cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Atm(item.string(ii));
    }
    @Override
    public Atm cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) {
      return new Atm(value.toString());
    }
  },

  /** Untyped Atomic type. */
  ATM("untypedAtomic", AAT, XS_URI, false, true, false, Type.ID.ATM) {
    @Override
    public Atm cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Atm(item.string(ii));
    }
    @Override
    public Atm cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) {
      return new Atm(value.toString());
    }
  },

  /** String type. */
  STR("string", AAT, XS_URI, false, false, true, Type.ID.STR) {
    @Override
    public Str cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return Str.get(item.string(ii));
    }
    @Override
    public Str cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return Str.get(value, qc, ii);
    }
  },

  /** Normalized String type. */
  NST("normalizedString", STR, XS_URI, false, false, true, Type.ID.NST) {
    @Override
    public Str cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {

      final byte[] str = item.string(ii);
      final int sl = str.length;
      for(int s = 0; s < sl; s++) {
        final byte b = str[s];
        if(b == '\t' || b == '\r' || b == '\n') str[s] = ' ';
      }
      return new Str(str, this);
    }
    @Override
    public Str cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Token type. */
  TOK("token", NST, XS_URI, false, false, true, Type.ID.TOK) {
    @Override
    public Str cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Str(normalize(item.string(ii)), this);
    }
    @Override
    public Str cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Language type. */
  LAN("language", TOK, XS_URI, false, false, true, Type.ID.LAN) {
    @Override
    public Str cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      final byte[] v = normalize(item.string(ii));
      if(!LANGPATTERN.matcher(Token.string(v)).matches()) throw funCastErr(item, ii);
      return new Str(v, this);
    }
    @Override
    public Str cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** NMTOKEN type. */
  NMT("NMTOKEN", TOK, XS_URI, false, false, true, Type.ID.NMT) {
    @Override
    public Str cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      final byte[] v = normalize(item.string(ii));
      if(!XMLToken.isNMToken(v)) throw funCastErr(item, ii);
      return new Str(v, this);
    }
    @Override
    public Str cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Name type. */
  NAM("Name", TOK, XS_URI, false, false, true, Type.ID.NAM) {
    @Override
    public Str cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      final byte[] v = normalize(item.string(ii));
      if(!XMLToken.isName(v)) throw funCastErr(item, ii);
      return new Str(v, this);
    }
    @Override
    public Str cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** NCName type. */
  NCN("NCName", NAM, XS_URI, false, false, true, Type.ID.NCN) {
    @Override
    public Str cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Str(checkName(item, ii), this);
    }
    @Override
    public Str cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** ID type. */
  ID("ID", NCN, XS_URI, false, false, true, Type.ID.ID) {
    @Override
    public Str cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Str(checkName(item, ii), this);
    }
    @Override
    public Str cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** IDREF type. */
  IDR("IDREF", NCN, XS_URI, false, false, true, Type.ID.IDR) {
    @Override
    public Str cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Str(checkName(item, ii), this);
    }
    @Override
    public Str cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Entity type. */
  ENT("ENTITY", NCN, XS_URI, false, false, true, Type.ID.ENT) {
    @Override
    public Str cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Str(checkName(item, ii), this);
    }
    @Override
    public Str cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Numeric type. */
  NUM("numeric", AAT, XS_URI, true, false, false, Type.ID.NUM) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      // return double
      return item.type.isNumber() ? item : Dbl.get(checkNum(item, ii).dbl(ii));
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      // return double
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Float type. */
  FLT("float", NUM, XS_URI, true, false, false, Type.ID.FLT) {
    @Override
    public Flt cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return Flt.get(checkNum(item, ii).flt(ii));
    }
    @Override
    public Flt cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Double type. */
  DBL("double", NUM, XS_URI, true, false, false, Type.ID.DBL) {
    @Override
    public Dbl cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return Dbl.get(checkNum(item, ii).dbl(ii));
    }
    @Override
    public Dbl cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Decimal type. */
  DEC("decimal", NUM, XS_URI, true, false, false, Type.ID.DEC) {
    @Override
    public Dec cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return Dec.get(checkNum(item, ii).dec(ii));
    }
    @Override
    public Dec cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) {
      return Dec.get(new BigDecimal(value.toString()));
    }
  },

  /** Precision decimal type. */
  PDC("precisionDecimal", null, XS_URI, true, false, false, Type.ID.PDC),

  /** Integer type. */
  ITR("integer", DEC, XS_URI, true, false, false, Type.ID.ITR) {
    @Override
    public Int cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Int cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return Int.get(checkLong(value, 0, 0, ii));
    }
  },

  /** Non-positive integer type. */
  NPI("nonPositiveInteger", ITR, XS_URI, true, false, false, Type.ID.NPI) {
    @Override
    public Int cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Int cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Int(checkLong(value, Long.MIN_VALUE, 0, ii), this);
    }
  },

  /** Negative integer type. */
  NIN("negativeInteger", NPI, XS_URI, true, false, false, Type.ID.NIN) {
    @Override
    public Int cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Int cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Int(checkLong(value, Long.MIN_VALUE, -1, ii), this);
    }
  },

  /** Long type. */
  LNG("long", ITR, XS_URI, true, false, false, Type.ID.LNG) {
    @Override
    public Int cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Int cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Int(checkLong(value, 0, 0, ii), this);
    }
  },

  /** Int type. */
  INT("int", LNG, XS_URI, true, false, false, Type.ID.INT) {
    @Override
    public Int cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Int cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Int(checkLong(value, -0x80000000, 0x7FFFFFFF, ii), this);
    }
  },

  /** Short type. */
  SHR("short", INT, XS_URI, true, false, false, Type.ID.SHR) {
    @Override
    public Int cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Int cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Int(checkLong(value, -0x8000, 0x7FFF, ii), this);
    }
  },

  /** Byte type. */
  BYT("byte", SHR, XS_URI, true, false, false, Type.ID.BYT) {
    @Override
    public Int cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Int cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Int(checkLong(value, -0x80, 0x7F, ii), this);
    }
  },

  /** Non-negative integer type. */
  NNI("nonNegativeInteger", ITR, XS_URI, true, false, false, Type.ID.NNI) {
    @Override
    public Int cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Int cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Int(checkLong(value, 0, Long.MAX_VALUE, ii), this);
    }
  },

  /** Unsigned long type. */
  ULN("unsignedLong", NNI, XS_URI, true, false, false, Type.ID.ULN) {
    @Override
    public Uln cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Uln cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      final Item it = value instanceof Item ? (Item) value : Str.get(value.toString());
      final BigDecimal v = checkNum(it, ii).dec(ii), i = v.setScale(0, RoundingMode.DOWN);
      if(v.signum() < 0 || v.compareTo(Uln.MAXULN) > 0 ||
        it.type.isStringOrUntyped() && !v.equals(i)) throw funCastError(ii, this, it);
      return Uln.get(i.toBigInteger());
    }
  },

  /** Short type. */
  UIN("unsignedInt", ULN, XS_URI, true, false, false, Type.ID.UIN) {
    @Override
    public Int cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Int cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Int(checkLong(value, 0, 0xFFFFFFFFL, ii), this);
    }
  },

  /** Unsigned Short type. */
  USH("unsignedShort", UIN, XS_URI, true, false, false, Type.ID.USH) {
    @Override
    public Int cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Int cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Int(checkLong(value, 0, 0xFFFF, ii), this);
    }
  },

  /** Unsigned byte type. */
  UBY("unsignedByte", USH, XS_URI, true, false, false, Type.ID.UBY) {
    @Override
    public Int cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Int cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Int(checkLong(value, 0, 0xFF, ii), this);
    }
  },

  /** Positive integer type. */
  PIN("positiveInteger", NNI, XS_URI, true, false, false, Type.ID.PIN) {
    @Override
    public Int cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast((Object) item, qc, sc, ii);
    }
    @Override
    public Int cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Int(checkLong(value, 1, Long.MAX_VALUE, ii), this);
    }
  },

  /** Duration type. */
  DUR("duration", AAT, XS_URI, false, false, false, Type.ID.DUR) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item instanceof Dur) return new Dur((Dur) item);
      if(str(item)) return new Dur(item.string(ii), ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Year month duration type. */
  YMD("yearMonthDuration", DUR, XS_URI, false, false, false, Type.ID.YMD) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item instanceof Dur) return new YMDur((Dur) item);
      if(str(item)) return new YMDur(item.string(ii), ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Day time duration type. */
  DTD("dayTimeDuration", DUR, XS_URI, false, false, false, Type.ID.DTD) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item instanceof Dur) return new DTDur((Dur) item);
      if(str(item)) return new DTDur(item.string(ii), ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** DateTime type. */
  DTM("dateTime", AAT, XS_URI, false, false, false, Type.ID.DTM) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item.type == DAT) return new Dtm((ADate) item);
      if(str(item)) return new Dtm(item.string(ii), ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** DateTimeStamp type. */
  DTS("dateTimeStamp", null, XS_URI, false, false, false, Type.ID.DTS),

  /** Date type. */
  DAT("date", AAT, XS_URI, false, false, false, Type.ID.DAT) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item.type == DTM) return new Dat((ADate) item);
      if(str(item)) return new Dat(item.string(ii), ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Time type. */
  TIM("time", AAT, XS_URI, false, false, false, Type.ID.TIM) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item.type == DTM) return new Tim((ADate) item);
      if(str(item)) return new Tim(item.string(ii), ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Year month type. */
  YMO("gYearMonth", AAT, XS_URI, false, false, false, Type.ID.YMO) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item.type == DTM || item.type == DAT) return new GDt((ADate) item, this);
      if(str(item)) return new GDt(item.string(ii), this, ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Year type. */
  YEA("gYear", AAT, XS_URI, false, false, false, Type.ID.YEA) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item.type == DTM || item.type == DAT) return new GDt((ADate) item, this);
      if(str(item)) return new GDt(item.string(ii), this, ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Month day type. */
  MDA("gMonthDay", AAT, XS_URI, false, false, false, Type.ID.MDA) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item.type == DTM || item.type == DAT) return new GDt((ADate) item, this);
      if(str(item)) return new GDt(item.string(ii), this, ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Day type. */
  DAY("gDay", AAT, XS_URI, false, false, false, Type.ID.DAY) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item.type == DTM || item.type == DAT) return new GDt((ADate) item, this);
      if(str(item)) return new GDt(item.string(ii), this, ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Month type. */
  MON("gMonth", AAT, XS_URI, false, false, false, Type.ID.MON) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item.type == DTM || item.type == DAT) return new GDt((ADate) item, this);
      if(str(item)) return new GDt(item.string(ii), this, ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return cast(Str.get(value, qc, ii), qc, sc, ii);
    }
  },

  /** Boolean type. */
  BLN("boolean", AAT, XS_URI, false, false, false, Type.ID.BLN) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item instanceof ANum) return Bln.get(item.bool(ii));
      if(str(item)) return Bln.get(Bln.parse(item.string(ii), ii));
      throw castError(ii, item, this);
    }
    @Override
    public Bln cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) {
      return value instanceof Boolean ? Bln.get((Boolean) value) :
        Bln.get(Boolean.parseBoolean(value.toString()));
    }
  },

  /** Implementation specific: binary type. */
  BIN("binary", AAT, BASEX_URI, false, false, false, Type.ID.BIN),

  /** Base64 binary type. */
  B64("base64Binary", BIN, XS_URI, false, false, false, Type.ID.B64) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item instanceof Bin) return new B64((Bin) item, ii);
      if(str(item)) return new B64(item.string(ii), ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new B64(value instanceof byte[] ? (byte[]) value : token(value.toString()), ii);
    }
  },

  /** Hex binary type. */
  HEX("hexBinary", BIN, XS_URI, false, false, false, Type.ID.HEX) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      if(item instanceof Bin) return new Hex((Bin) item, ii);
      if(str(item)) return new Hex(item.string(ii), ii);
      throw castError(ii, item, this);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {
      return new Hex(value instanceof byte[] ? (byte[]) value : token(value.toString()), ii);
    }
  },

  /** Any URI type. */
  URI("anyURI", AAT, XS_URI, false, false, true, Type.ID.URI) {
    @Override
    public Uri cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {

      if(!item.type.isStringOrUntyped()) throw castError(ii, item, this);
      final Uri u = Uri.uri(item.string(ii));
      if(!u.isValid()) throw funCastErr(item, ii);
      return u;
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) {
      return Uri.uri(value.toString());
    }
  },

  /** QName Type. */
  QNM("QName", AAT, XS_URI, false, false, false, Type.ID.QNM) {
    @Override
    public QNm cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) throws QueryException {

      if(item.type != STR && !item.type.isUntyped()) throw castError(ii, item, this);
      final byte[] nm = trim(item.string(ii));
      if(!XMLToken.isQName(nm)) throw funCastErr(item, ii);
      final QNm qn = new QNm(nm, sc);
      if(!qn.hasURI() && qn.hasPrefix()) throw NSDECL_X.get(ii, qn.prefix());
      return qn;
    }
    @Override
    public QNm cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) {
      return value instanceof QName ? new QNm((QName) value) : new QNm(value.toString());
    }
  },

  /** NOTATION Type. */
  NOT("NOTATION", AAT, XS_URI, false, false, false, Type.ID.NOT),

  /** Java type. */
  JAVA("java", ITEM, BASEX_URI, true, true, true, Type.ID.JAVA) {
    @Override
    public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) {
      return new Jav(item, qc);
    }
    @Override
    public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
        final InputInfo ii) {
      return new Jav(value, qc);
    }
  };

  /** Language pattern. */
  static final Pattern LANGPATTERN = Pattern.compile("[A-Za-z]{1,8}(-[A-Za-z0-9]{1,8})*");

  /** Cached enums (faster). */
  public static final AtomType[] VALUES = values();
  /** Name. */
  public final QNm name;
  /** Parent type. */
  public final AtomType parent;
  /** Type id . */
  private final Type.ID id;

  /** Number flag. */
  private final boolean numeric;
  /** Untyped flag. */
  private final boolean untyped;
  /** String flag. */
  private final boolean string;

  /** Sequence type (lazy instantiation). */
  private SeqType seqType;

  /**
   * Constructor.
   * @param name string representation
   * @param parent parent type
   * @param uri uri
   * @param numeric numeric flag
   * @param untyped untyped flag
   * @param string string flag
   * @param id type id
   */
  AtomType(final String name, final AtomType parent, final byte[] uri, final boolean numeric,
      final boolean untyped, final boolean string, final Type.ID id) {
    this.name = new QNm(name, uri);
    this.parent = parent;
    this.numeric = numeric;
    this.untyped = untyped;
    this.string = string;
    this.id = id;
  }

  @Override
  public final boolean isNumber() {
    return numeric;
  }

  @Override
  public final boolean isUntyped() {
    return untyped;
  }

  @Override
  public final boolean isNumberOrUntyped() {
    return numeric || untyped;
  }

  @Override
  public final boolean isStringOrUntyped() {
    return string || untyped;
  }

  @Override
  public final byte[] string() {
    return name.string();
  }

  @Override
  public Item cast(final Item item, final QueryContext qc, final StaticContext sc,
      final InputInfo ii) throws QueryException {
    if(item.type == this) return item;
    throw castError(ii, item, this);
  }

  @Override
  public Item cast(final Object value, final QueryContext qc, final StaticContext sc,
      final InputInfo ii) throws QueryException {
    throw Util.notExpected(value);
  }

  @Override
  public final Item castString(final String value, final QueryContext qc, final StaticContext sc,
      final InputInfo ii) throws QueryException {
    return cast(value, qc, sc, ii);
  }

  @Override
  public final SeqType seqType() {
    // cannot be statically instantiated due to circular dependencies
    if(seqType == null) seqType = new SeqType(this);
    return seqType;
  }

  @Override
  public final boolean eq(final Type t) {
    return this == t;
  }

  @Override
  public final boolean instanceOf(final Type t) {
    return this == t || parent != null && parent.instanceOf(t);
  }

  @Override
  public final Type union(final Type t) {
    if(instanceOf(t)) return t;
    if(t.instanceOf(this)) return this;

    if(t instanceof AtomType) {
      final List<AtomType> arr = new ArrayList<>();
      for(AtomType at = (AtomType) t; (at = at.parent) != null;) arr.add(at);
      for(AtomType p = this; (p = p.parent) != null;)
        if(arr.contains(p)) return p;
    }
    return ITEM;
  }

  @Override
  public final Type intersect(final Type t) {
    return instanceOf(t) ? this : t.instanceOf(this) ? t : null;
  }

  @Override
  public final Type.ID id() {
    return id;
  }

  @Override
  public final String toString() {
    final boolean xs = Token.eq(XS_URI, name.uri());
    final TokenBuilder tb = new TokenBuilder();
    if(xs) tb.add(NSGlobal.prefix(name.uri())).add(':');
    tb.add(name.string());
    if(!xs) tb.add("()");
    return tb.toString();
  }

  /**
   * Throws an exception if the specified item cannot be converted to a number.
   * @param item item
   * @param ii input info
   * @return item argument
   * @throws QueryException query exception
   */
  final Item checkNum(final Item item, final InputInfo ii) throws QueryException {
    final Type ip = item.type;
    if(item instanceof ANum || ip.isStringOrUntyped() && ip != URI || ip == BLN) return item;
    throw castError(ii, item, this);
  }

  /**
   * Checks the validity of the specified object and returns its long value.
   * @param o value to be checked
   * @param min minimum value
   * @param max maximum value
   * @param ii input info
   * @return integer value
   * @throws QueryException query exception
   */
  final long checkLong(final Object o, final long min, final long max, final InputInfo ii)
      throws QueryException {

    final Item it = o instanceof Item ? (Item) o : Str.get(o.toString());
    checkNum(it, ii);

    final Type ip = it.type;
    if(ip == DBL || ip == FLT) {
      final double d = it.dbl(ii);
      if(Double.isNaN(d) || Double.isInfinite(d)) throw valueError(ii, this, it.string(ii));
      if(min != max && (d < min || d > max)) throw funCastError(ii, this, it);
      if(d < Long.MIN_VALUE || d > Long.MAX_VALUE) throw INTRANGE_X.get(ii, d);
      return (long) d;
    }
    if(min == max) {
      final double d = it.dbl(ii);
      if(d < Long.MIN_VALUE || d > Long.MAX_VALUE) throw funCastError(ii, this, it);
    }

    final long l = it.itr(ii);
    if(min != max && (l < min || l > max)) throw funCastError(ii, this, it);
    return l;
  }

  /**
   * Checks if the specified item is a string.
   * @param it item
   * @return item argument
   */
  static boolean str(final Item it) {
    final Type ip = it.type;
    return ip.isStringOrUntyped() && ip != URI;
  }

  /**
   * Checks the validity of the specified name.
   * @param it value to be checked
   * @param ii input info
   * @return name
   * @throws QueryException query exception
   */
  final byte[] checkName(final Item it, final InputInfo ii) throws QueryException {
    final byte[] v = normalize(it.string(ii));
    if(!XMLToken.isNCName(v)) throw funCastErr(it, ii);
    return v;
  }

  /**
   * Returns a casting exception.
   * @param it item to be included in the error message
   * @param ii input info
   * @return query exception
   */
  final QueryException funCastErr(final Item it, final InputInfo ii)  {
    return FUNCCAST_X_X_X.get(ii, it.type, this, it);
  }

  @Override
  public final boolean nsSensitive() {
    return instanceOf(QNM) || instanceOf(NOT);
  }

  /**
   * Finds and returns the specified type.
   * @param type type
   * @param all accept all types (including those without parent type)
   * @return type or {@code null}
   */
  public static AtomType find(final QNm type, final boolean all) {
    if(!Token.eq(type.uri(), BASEX_URI)) {
      for(final AtomType t : VALUES) {
        if(t.name.eq(type) && (all || t.parent != null)) return t;
      }
    }
    return null;
  }

  /**
   * Gets the type instance for the given ID.
   * @param id type ID
   * @return corresponding type if found, {@code null} otherwise
   */
  static Type getType(final Type.ID id) {
    for(final AtomType t : VALUES) if(t.id == id) return t;
    return null;
  }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright 2015 The Android Open Source Project

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.directshare"
    android:versionCode="1"
    android:versionName="1.0">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/DirectShareTheme">

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".SendMessageActivity"
            android:label="@string/app_name"
            android:theme="@style/DirectShareDialogTheme">
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="text/plain" />
            </intent-filter>
            <meta-data
                android:name="android.service.chooser.chooser_target_service"
                android:value=".SampleChooserTargetService" />
        </activity>

        <activity
            android:name=".SelectContactActivity"
            android:label="@string/app_name"
            android:theme="@style/DirectShareDialogTheme" />

        <service
            android:name=".SampleChooserTargetService"
            android:label="@string/app_name"
            android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE">
            <intent-filter>
                <action android:name="android.service.chooser.ChooserTargetService" />
            </intent-filter>
        </service>

    </application>

</manifest>

redpajama_set_name: RedPajamaGithub


text:
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>W28782_text</title>
        <link rel="stylesheet" type="text/css" href="style.css" />

                «

    <p class="styleSans10.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">Williams, Donna J

From: Roth, Taylor J. <tjroth@nd.gov>
Sent: Monday, June 23, 2014 10:40 AM
To: Williams, Donna J
Subject: [EXTERNAL]Hammerhead 21—26TFH, 31—26-2MBH, 31~26TFH
Attachments: Cuttings pit removed » Hammerheadpdf

    <p class="styleSans10.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">Donna,
Can you please remove the cuttings pit from this pad as well? Please let us know what Burlington will be doing with the cuttings.
Thanks a lot;
Taylor J. Roth Survey & Permitting Technician NDIC, Dept. Mineral Resources
Oil and Gas Division 701-328-1720 (direct)
tjroth@nd.gov

    <p class="styleSans6.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">


text:
package org.activiti.examples.bpmn.tasklistener;

import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.HashMap;
import java.util.Map;

import org.activiti.engine.impl.test.PluggableActivitiTestCase;
import org.activiti.engine.task.Task;
import org.activiti.engine.test.Deployment;

/**

 */
public class CustomTaskAssignmentTest extends PluggableActivitiTestCase {

  @Deployment
  public void testCandidateGroupAssignment() {
    runtimeService.startProcessInstanceByKey("customTaskAssignment");
    assertThat(taskService.createTaskQuery().taskCandidateGroup("management").count()).isEqualTo(1);
    assertThat(taskService.createTaskQuery().taskCandidateUser("kermit", asList("management")).count()).isEqualTo(1);
    assertThat(taskService.createTaskQuery().taskCandidateUser("fozzie",null).count()).isEqualTo(0);
  }

  @Deployment
  public void testCandidateUserAssignment() {
    runtimeService.startProcessInstanceByKey("customTaskAssignment");
    assertThat(taskService.createTaskQuery().taskCandidateUser("kermit",null).count()).isEqualTo(1);
    assertThat(taskService.createTaskQuery().taskCandidateUser("fozzie",null).count()).isEqualTo(1);
    assertThat(taskService.createTaskQuery().taskCandidateUser("gonzo",null).count()).isEqualTo(0);
  }

  @Deployment
  public void testAssigneeAssignment() {
    runtimeService.startProcessInstanceByKey("setAssigneeInListener");
    assertThat(taskService.createTaskQuery().taskAssignee("kermit").singleResult()).isNotNull();
    assertThat(taskService.createTaskQuery().taskAssignee("fozzie").count()).isEqualTo(0);
    assertThat(taskService.createTaskQuery().taskAssignee("gonzo").count()).isEqualTo(0);
  }

  @Deployment
  public void testOverwriteExistingAssignments() {
    runtimeService.startProcessInstanceByKey("overrideAssigneeInListener");
    assertThat(taskService.createTaskQuery().taskAssignee("kermit").singleResult()).isNotNull();
    assertThat(taskService.createTaskQuery().taskAssignee("fozzie").count()).isEqualTo(0);
    assertThat(taskService.createTaskQuery().taskAssignee("gonzo").count()).isEqualTo(0);
  }

  @Deployment
  public void testOverwriteExistingAssignmentsFromVariable() {
    // prepare variables
    Map<String, String> assigneeMappingTable = new HashMap<String, String>();
    assigneeMappingTable.put("fozzie", "gonzo");

    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("assigneeMappingTable", assigneeMappingTable);

    // start process instance
    runtimeService.startProcessInstanceByKey("customTaskAssignment", variables);

    // check task lists
    assertThat(taskService.createTaskQuery().taskAssignee("gonzo").singleResult()).isNotNull();
    assertThat(taskService.createTaskQuery().taskAssignee("fozzie").count()).isEqualTo(0);
    assertThat(taskService.createTaskQuery().taskAssignee("kermit").count()).isEqualTo(0);
  }

  @Deployment
  public void testReleaseTask() throws Exception {
    runtimeService.startProcessInstanceByKey("releaseTaskProcess");

    Task task = taskService.createTaskQuery().taskAssignee("fozzie").singleResult();
    assertThat(task).isNotNull();
    String taskId = task.getId();

    // Set assignee to null
    taskService.setAssignee(taskId, null);

    task = taskService.createTaskQuery().taskAssignee("fozzie").singleResult();
    assertThat(task).isNull();

    task = taskService.createTaskQuery().taskId(taskId).singleResult();
    assertThat(task).isNotNull();
    assertThat(task.getAssignee()).isNull();
  }

}


text:
class RemoveColumnDateTypeOfMilestoneDelayRecords < ActiveRecord::Migration
  def self.up
  	remove_column :milestone_delay_records, :date_type
  end

  def self.down
	add_column :milestone_delay_records, :date_type, :text
  end
end


text:
package ftc.electronvolts.statemachine;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

import ftc.electronvolts.statemachine.State;
import ftc.electronvolts.statemachine.StateName;

public class Main {
	enum S implements StateName {
		DRIVE,
		WALL,
		TIMEOUT,
//		PRINT_TWICE,
//		BRANCH,
		STOP
	}

	public static void main(String[] args) throws StateNotFoundError {
		Map<StateName, State> stateMap = new HashMap<>();

		//TODO Abhi's checks on unused states
		//TODO Mark's counter instead of boolean

		List<Task> tasks = new ArrayList<>();
		tasks.add(TaskFactory.count(3, S.TIMEOUT));
		tasks.add(TaskFactory.count(2, S.WALL)); //TODO order based priority

		stateMap.put(S.DRIVE, StateFactory.behavior(BehaviorFactory.print("vroooooooooom"), tasks));

		stateMap.put(S.WALL, StateFactory.behavior(BehaviorFactory.print("hit a wall :("), TaskFactory.count(3, S.STOP)));
		stateMap.put(S.TIMEOUT, StateFactory.behavior(BehaviorFactory.print("timed out :("), TaskFactory.count(3, S.STOP)));
		//TODO ordering of next state for priority, possibly with orderedmap or just a list

//		stateMap.put(S.PRINT_TWICE, StateFactory.printTwice(S.BRANCH, "print twice state"));
//		stateMap.put(S.BRANCH, StateFactory.branch(S.STOP, S.PRINT_TWICE));
		stateMap.put(S.STOP, StateFactory.stop());

		StateMachine sm = new StateMachine(stateMap, S.DRIVE, S.values());

		while (true) {
			sm.act();

			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}

	}

}


text:
<?php

use Symfony\Polyfill\Php70 as p;

if (PHP_VERSION_ID < 70000) {
    if (!defined('PHP_INT_MIN')) {
        define('PHP_INT_MIN', ~PHP_INT_MAX);
    }
    if (!function_exists('intdiv')) {
        function intdiv($dividend, $divisor) { return p\Php70::intdiv($dividend, $divisor); }
    }
    if (!function_exists('preg_replace_callback_array')) {
        function preg_replace_callback_array(array $patterns, $subject, $limit = -1, &$count = 0) { return p\Php70::preg_replace_callback_array($patterns, $subject, $limit, $count); }
    }
    if (!function_exists('error_clear_last')) {
        function error_clear_last() { return p\Php70::error_clear_last(); }
    }
}


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-parent</artifactId>
        <version>3.3.2.GA</version>
        <relativePath>../parent/pom.xml</relativePath>
    </parent>

    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-jbosscache</artifactId>
    <packaging>jar</packaging>

    <name>Hibernate JBossCache Integration</name>
    <description>Integration of Hibernate with JBossCache (based on JBossCache1.x APIs)</description>

    <dependencies>
        <dependency>
            <groupId>${groupId}</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${version}</version>
        </dependency>
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jboss-cache</artifactId>
            <version>1.4.1.GA</version>
        </dependency>
        <!-- jboss-cache (the one from the jboss repo, anyway) does not properly define its dependencies -->
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jboss-system</artifactId>
            <version>4.0.2</version>
        </dependency>
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jboss-common</artifactId>
            <version>4.0.2</version>
        </dependency>
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jboss-minimal</artifactId>
            <version>4.0.2</version>
        </dependency>
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jboss-j2se</artifactId>
            <version>200504122039</version>
        </dependency>
        <dependency>
            <groupId>concurrent</groupId>
            <artifactId>concurrent</artifactId>
            <version>1.3.4</version>
        </dependency>
        <dependency>
            <groupId>jgroups</groupId>
            <artifactId>jgroups-all</artifactId>
            <version>2.2.7</version>
        </dependency>

        <!-- testing deps -->
        <dependency>
            <groupId>${groupId}</groupId>
            <artifactId>hibernate-testing</artifactId>
            <version>${version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>1.8.0.2</version>
            <scope>test</scope>
        </dependency>
        <!-- these are optional on core... :( -->
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>


text:
package com.sequenceiq.datalake.controller.sdx;

import java.util.Objects;
import java.util.Optional;

import org.springframework.stereotype.Service;

import com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request;
import com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response;
import com.sequenceiq.common.model.UpgradeShowAvailableImages;
import com.sequenceiq.sdx.api.model.SdxUpgradeReplaceVms;
import com.sequenceiq.sdx.api.model.SdxUpgradeRequest;
import com.sequenceiq.sdx.api.model.SdxUpgradeResponse;

@Service
public class SdxUpgradeClusterConverter {

    public SdxUpgradeResponse upgradeResponseToSdxUpgradeResponse(UpgradeV4Response upgradeV4Response) {
        return new SdxUpgradeResponse(
                upgradeV4Response.getCurrent(),
                upgradeV4Response.getUpgradeCandidates(),
                upgradeV4Response.getReason(),
                upgradeV4Response.getFlowIdentifier());
    }

    public UpgradeV4Request sdxUpgradeRequestToUpgradeV4Request(SdxUpgradeRequest sdxUpgradeRequest) {
        UpgradeV4Request upgradeV4Request = new UpgradeV4Request();
        upgradeV4Request.setImageId(sdxUpgradeRequest.getImageId());
        upgradeV4Request.setRuntime(sdxUpgradeRequest.getRuntime());
        upgradeV4Request.setDryRun(sdxUpgradeRequest.isDryRun());
        upgradeV4Request.setLockComponents(sdxUpgradeRequest.getLockComponents());
        if (Objects.nonNull(sdxUpgradeRequest.getShowAvailableImages())) {
            upgradeV4Request.setShowAvailableImages(UpgradeShowAvailableImages.valueOf(sdxUpgradeRequest.getShowAvailableImages().name()));
        }
        upgradeV4Request.setReplaceVms(Optional.ofNullable(sdxUpgradeRequest.getReplaceVms()).orElse(SdxUpgradeReplaceVms.ENABLED).getBooleanValue());
        upgradeV4Request.setSkipDataHubValidation(sdxUpgradeRequest.getSkipDataHubValidation());
        return upgradeV4Request;
    }
}


text:
document.addEventListener('DOMContentLoaded', function(){

// Fetch elements
var $next = document.getElementById('next');
var $previous = document.getElementById('previous');
var $emulations = document.querySelectorAll('.main-emulation');
var $innerStyle = document.querySelectorAll('[data-style]');
var selectedExample = 0;

// Evaluate inner data-style attributes and apply as style attributes
for(var i = 0; i < $innerStyle.length; i++){
  var I = $innerStyle.item(i);
  var rawStyle = I.getAttribute('data-style');
  var style = eval(rawStyle);
  I.setAttribute('style', style);
  I.removeAttribute('data-style');
}

// Function for selecting an emulation
var selectExample = function(number){
  num = ((number % $emulations.length) + $emulations.length) % $emulations.length;
  $emulations.item(selectedExample).classList.remove('current');
  $emulations.item(num).classList.add('current');
  selectedExample = num;
}

// Bind behavior to controls
$next.addEventListener('click', function(){
  selectExample(selectedExample + 1);
});
$previous.addEventListener('click', function(){
  selectExample(selectedExample - 1);
});

// Initialize, select first emulation
selectExample(0);

});


text:
package fox.rdata;

import java.io.Serializable;

import fox.rdata.exception.InvalidKeyNameException;
import fox.rdata.exception.KeyNameNotFoundException;

public class RDataList extends RDataStructure implements Serializable {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	public RDataList(String arg1) {
		super(arg1);
		// TODO Auto-generated constructor stub
	}

	public RDataList addData(RDataBase data) {
		if (dataList == null) {
			return this.addData(data, 0);
		} else {
			return this.addData(data, dataList.length);
		}
	}

	public RDataList addData(RDataBase data, int index) {
		if (data == null) {
			throw new NullPointerException("RDataBase object cannot be null");
		}
		if (index < 0) {
			throw new IndexOutOfBoundsException("You may not have an index less than zero.");
		}
		if (dataList != null && dataList.length > 0) {
			RDataBase[] tempList = new RDataBase[dataList.length + 1];
			// TODO If misbehaving, increase initial memory allocation to
			// prevent overflows.
			data.setLayer(getLayer() + 1);
			data.setParent(this);
			boolean inserted = false;
			for (int i = 0; i < dataList.length; i++) {
				if (i == index) {
					tempList[i] = data;
					inserted = true;
				}
				if (inserted) {
					tempList[i + 1] = dataList[i];
				} else {
					tempList[i] = dataList[i];
				}
			}
			if (!inserted) {
				tempList[dataList.length] = data;
			}
			dataList = tempList;

		} else {
			dataList = new RDataBase[1];
			dataList[0] = data;
		}
		return this;
	}

	public RDataBase getData(int index) {
		checkDataListExists();
		checkIndex(index);
		return dataList[index];
	}

	public RDataList removeData(int index) {
		checkDataListExists();
		checkIndex(index);
		RDataBase[] tempList = new RDataBase[dataList.length - 1];
		boolean remove = false;
		for (int i = 0; i < (tempList.length); i++) {
			if (i == index) {
				remove = true;
			}
			if (remove) {
				tempList[i] = dataList[i + 1];
			} else {
				tempList[i] = dataList[i];
			}
		}
		dataList = tempList;
		return this;
	}

	public RDataList replaceData(RDataBase data, int index) {
		this.removeData(index);
		this.addData(data, index);
		return this;
	}

	public RDataList swapData(int index1, int index2) {
		RDataBase tempData = this.getData(index1);
		this.replaceData(this.getData(index2), index1);
		this.replaceData(tempData, index2);
		return this;
	}

	private void checkIndex(int index) {
		if (index < 0) {
			throw new IndexOutOfBoundsException("You may not have an index less than zero.");
		} else if (index >= dataList.length) {
			throw new IndexOutOfBoundsException("Index too high: " + index + " (Max: " + (dataList.length - 1) + ")");
		}
	}

	private void checkDataListExists() {
		if (dataList == null || dataList.length == 0) {
			throw new NullPointerException("Data structure is empty. Add some data first.");
		}
	}

	public RDataComponent getDataAsComponent(int index) throws KeyNameNotFoundException, InvalidKeyNameException {
		return (RDataComponent) this.getData(index);
	}

	public RDataList getDataAsList(int index) throws KeyNameNotFoundException, InvalidKeyNameException {
		return (RDataList) this.getData(index);
	}

	public RDataPrimative getDataAsPrimative(int index) throws KeyNameNotFoundException, InvalidKeyNameException {
		return (RDataPrimative) this.getData(index);
	}

	public String toString() {
		String string = new String("[\n");
		for (int i = 0; i < dataList.length; i++) {
			for (int j = 0; j < getLayer(); j++) {
				string = string.concat("\t");
			}
			string = string.concat(i + dataList[i].toString() + "\n");
		}
		for (int j = 0; j < getLayer() - 1; j++) {
			string = string.concat("\t");
		}
		string = string.concat("]");
		return string;
	}
}


text:
                        × {{'GENERAL.ACTION.CANCEL' | translate}}

{{'PROCESS.POPUP.IMPORT-TITLE' | translate}}

                    {{'PROCESS.POPUP.IMPORT-DESCRIPTION' | translate}}

                    <input type="file" ngf-select="" ngf-change="onFileSelect($files)" style="font-size: smaller; padding-top:6px;" >

                        {{'PROCESS.POPUP.IMPORT.DROPZONE' | translate}}

{{'PROCESS.POPUP.IMPORT.NO-DROP' | translate}}

                    <button class="btn btn-danger btn-sm"
                            ng-click="upload.abort()"
                            ng-disabled="!status.loading"
                            style="margin-bottom: 20px">
                        {{'PROCESS.POPUP.IMPORT.CANCEL-UPLOAD' | translate}}
                    </button>

                    <loading></loading>

                        {{'PROCESS.POPUP.IMPORT.ERROR' | translate}}  : {{model.errorMessage}}


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

<title>KeyValueNode</title>
<meta name="date" content="2017-02-11">
<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 Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

structures.node

Class KeyValueNode<K,V>

java.lang.Object

structures.node.Node<V>

structures.node.KeyValueNode<K,V>

All Implemented Interfaces:

java.io.Serializable

Direct Known Subclasses:

BinaryTreeNode

public class KeyValueNode<K,V>
extends Node<V>

See Also:

Serialized Form

Field Summary

Fields

Modifier and Type
Field and Description

protected K
key

Constructor Summary

Constructors

Constructor and Description

KeyValueNode(K key,
            V val)

Method Summary

All Methods Instance Methods Concrete Methods

Modifier and Type
Method and Description

K
getKey()

void
setKey(K key)

Methods inherited from class structures.node.Node

getValue, setValue

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

key

protected K key

Constructor Detail

KeyValueNode

public KeyValueNode(K key,
                    V val)

Method Detail

setKey

public void setKey(K key)

getKey

public K getKey()

Skip navigation links

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method


text:
declare namespace javax {
  namespace naming {
    namespace directory {

      class AttributeModificationException extends javax.naming.NamingException {
        public constructor(arg0: java.lang.String | string)
        public constructor()
        public setUnexecutedModifications(arg0: javax.naming.directory.ModificationItem[]): void
        public getUnexecutedModifications(): javax.naming.directory.ModificationItem[]
        public toString(): java.lang.String
      }

    }
  }
}


text:
package org.activiti.web.simple.webapp.util;

import java.util.HashMap;
import java.util.Map;

import jodd.util.StringUtil;

import org.apache.commons.beanutils.ConvertUtils;

public class Variable {

	private String keys;
	private String values;
	private String types;

	public String getKeys() {
		return keys;
	}

	public void setKeys(String keys) {
		this.keys = keys;
	}

	public String getValues() {
		return values;
	}

	public void setValues(String values) {
		this.values = values;
	}

	public String getTypes() {
		return types;
	}

	public void setTypes(String types) {
		this.types = types;
	}

	public Map<String, Object> getVariableMap() {
		Map<String, Object> vars = new HashMap<String, Object>();

		ConvertUtils.register(new DateConverter(), java.util.Date.class);

		if (StringUtil.isBlank(keys)) {
			return vars;
		}

		String[] arrayKey = keys.split(",");
		String[] arrayValue = values.split(",");
		String[] arrayType = types.split(",");
		for (int i = 0; i < arrayKey.length; i++) {
			String key = arrayKey[i];
			String value = arrayValue[i];
			String type = arrayType[i];

			Class<?> targetType = Enum.valueOf(PropertyType.class, type).getValue();
			Object objectValue = ConvertUtils.convert(value, targetType);
			vars.put(key, objectValue);
		}
		return vars;
	}

}


text:
<?php

class Google_Service_DLP_GooglePrivacyDlpV2beta1InspectContentRequest extends Google_Collection
{
  protected $collection_key = 'items';
  protected $inspectConfigType = 'Google_Service_DLP_GooglePrivacyDlpV2beta1InspectConfig';
  protected $inspectConfigDataType = '';
  protected $itemsType = 'Google_Service_DLP_GooglePrivacyDlpV2beta1ContentItem';
  protected $itemsDataType = 'array';

  /**
   * @param Google_Service_DLP_GooglePrivacyDlpV2beta1InspectConfig
   */
  public function setInspectConfig(Google_Service_DLP_GooglePrivacyDlpV2beta1InspectConfig $inspectConfig)
  {
    $this->inspectConfig = $inspectConfig;
  }
  /**
   * @return Google_Service_DLP_GooglePrivacyDlpV2beta1InspectConfig
   */
  public function getInspectConfig()
  {
    return $this->inspectConfig;
  }
  /**
   * @param Google_Service_DLP_GooglePrivacyDlpV2beta1ContentItem
   */
  public function setItems($items)
  {
    $this->items = $items;
  }
  /**
   * @return Google_Service_DLP_GooglePrivacyDlpV2beta1ContentItem
   */
  public function getItems()
  {
    return $this->items;
  }
}


text:
package org.neo4j.legacy.consistency.checking.full;

import java.util.List;
import java.util.Set;

import org.neo4j.collection.primitive.PrimitiveLongIterator;
import org.neo4j.collection.primitive.PrimitiveLongPeekingIterator;
import org.neo4j.kernel.api.index.IndexReader;
import org.neo4j.kernel.impl.api.LookupFilter;
import org.neo4j.kernel.impl.store.record.IndexRule;
import org.neo4j.kernel.impl.store.record.NodeRecord;
import org.neo4j.kernel.impl.store.record.PropertyBlock;
import org.neo4j.legacy.consistency.checking.CheckerEngine;
import org.neo4j.legacy.consistency.checking.RecordCheck;
import org.neo4j.legacy.consistency.checking.index.IndexAccessors;
import org.neo4j.legacy.consistency.report.ConsistencyReport;
import org.neo4j.legacy.consistency.store.DiffRecordAccess;
import org.neo4j.legacy.consistency.store.RecordAccess;

public class NodeCorrectlyIndexedCheck implements RecordCheck<NodeRecord, ConsistencyReport.NodeConsistencyReport>
{
    private final IndexAccessors indexes;
    private final PropertyReader propertyReader;

    public NodeCorrectlyIndexedCheck( IndexAccessors indexes,
                                      PropertyReader propertyReader )
    {
        this.indexes = indexes;
        this.propertyReader = propertyReader;
    }

    @Override
    public void check( NodeRecord record,
                       CheckerEngine<NodeRecord, ConsistencyReport.NodeConsistencyReport> engine,
                       RecordAccess records )
    {
        Set<Long> labels = NodeLabelReader.getListOfLabels( record, records, engine );
        for ( IndexRule indexRule : indexes.rules() )
        {
            if ( !labels.contains( (long) indexRule.getLabel() ) )
            {
                continue;
            }

            List<PropertyBlock> properties = propertyReader.propertyBlocks( record );
            PropertyBlock property = propertyWithKey( properties, indexRule.getPropertyKey() );

            if ( property == null )
            {
                continue;
            }

            try ( IndexReader reader = indexes.accessorFor( indexRule ).newReader() )
            {
                Object propertyValue = propertyReader.propertyValue( property ).value();
                long nodeId = record.getId();

                if ( indexRule.isConstraintIndex() )
                {
                    verifyNodeCorrectlyIndexedUniquely( nodeId, property.getKeyIndexId(), propertyValue, engine,
                            indexRule, reader );
                }
                else
                {
                    verifyNodeCorrectlyIndexed( nodeId, propertyValue, engine, indexRule, reader );
                }
            }
        }
    }

    private void verifyNodeCorrectlyIndexedUniquely( long nodeId, int propertyKeyId, Object propertyValue,
            CheckerEngine<NodeRecord,ConsistencyReport.NodeConsistencyReport> engine, IndexRule indexRule,
            IndexReader reader )
    {
        PrimitiveLongIterator indexedNodeIds = reader.seek( propertyValue );

        // For verifying node indexed uniquely in offline CC, if one match found in the first stage match,
        // then there is no need to filter the result. The result is a exact match.
        // If multiple matches found, we need to filter the result to get exact matches.
        indexedNodeIds = filterIfMultipleValuesFound( indexedNodeIds, propertyKeyId, propertyValue );

        boolean found = false;

        while ( indexedNodeIds.hasNext() )
        {
            long indexedNodeId = indexedNodeIds.next();

            if ( nodeId == indexedNodeId )
            {
                found = true;
            }
            else
            {
                engine.report().uniqueIndexNotUnique( indexRule, propertyValue, indexedNodeId );
            }
        }

        if ( !found )
        {
            engine.report().notIndexed( indexRule, propertyValue );
        }
    }

    private PrimitiveLongIterator filterIfMultipleValuesFound( PrimitiveLongIterator indexedNodeIds, int propertyKeyId,
            Object propertyValue )
    {
        PrimitiveLongIterator filteredIndexedNodeIds = new PrimitiveLongPeekingIterator( indexedNodeIds );
        if ( ((PrimitiveLongPeekingIterator) filteredIndexedNodeIds).hasMultipleValues() )
        {
            filteredIndexedNodeIds = LookupFilter.exactIndexMatches( propertyReader, filteredIndexedNodeIds,
                    propertyKeyId, propertyValue );
        }
        return filteredIndexedNodeIds;
    }

    private void verifyNodeCorrectlyIndexed(
            long nodeId,
            Object propertyValue,
            CheckerEngine<NodeRecord, ConsistencyReport.NodeConsistencyReport> engine,
            IndexRule indexRule,
            IndexReader reader )
    {
        int count = reader.countIndexedNodes( nodeId, propertyValue );
        if ( count == 0 )
        {
            engine.report().notIndexed( indexRule, propertyValue );
        }
        else if ( count == 1 )
        {   // Nothing to report, all good
        }
        else
        {
            engine.report().indexedMultipleTimes( indexRule, propertyValue, count );
        }
    }

    private PropertyBlock propertyWithKey( List<PropertyBlock> propertyBlocks, int propertyKey )
    {
        for ( PropertyBlock propertyBlock : propertyBlocks )
        {
            if ( propertyBlock.getKeyIndexId() == propertyKey )
            {
                return propertyBlock;
            }
        }
        return null;
    }

    @Override
    public void checkChange( NodeRecord oldRecord, NodeRecord newRecord,
                             CheckerEngine<NodeRecord, ConsistencyReport.NodeConsistencyReport> engine,
                             DiffRecordAccess records )
    {
        check( newRecord, engine, records );
    }
}


text:
package android.widget.cts;

import android.app.Activity;
import android.os.Bundle;
import com.android.cts.stub.R;

/**
 * A minimal application for layout direction test.
 */
public class LayoutDirectionStubActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layoutdirection_layout);
    }
}


text:
A list of group 5's projinda projects.

For the course DD1349 _Project in Introduction to Computer Science_ at KTH Royal Institute of Technology.

Send a PR adding a short description of your project to the list 🚀

## How to
Add your entry in this format to the list below:
- [Project name](https://github.com/mictab/) - short description ([@member](https://github.com/mictab), [@member](https://github.com/mictab))

Please don't forget to add a newline after your entry.

# List

- [Passman](https://github.com/hrunelov/passman) - Manage account passwords without storing them by deterministically generating strong passwords from strings. ([@hrunelov](https://github.com/hrunelov))

- [Music Map](https://github.com/beichenc/MusicMap) - A website where users log in with Spotify, and can map their currently playing song on a map. Users can view previously mapped songs by other users at their current location or any other location, to get location based music inspiration. Implemented using React. ([@beichenc](https://github.com/beichenc), [@amyychen](https://github.com/amyychen))

- [HOUSEFINDER](https://github.com/worldyn/crawler) - A SaaS that will help you easily look for an apartment/house rental contract via a web crawler that collects the latest info from several websites with rental contracts. Created by Adam Jacobs ([@worldyn](https://github.com/worldyn)) and Olle Berglöf ([@osobo](https://github.com/osobo)).

- [2D puzzle platformer](https://github.com/AxlLind/2D-platformer) - A 2D puzzle platformer. We will be using Unity and therefore writing it in C#. ([@Axel](https://github.com/axlLind), [@Jonatan](https://github.com/Jontpan))

- [Lifelink](https://github.com/johnnil/Lifelink/) - An MTG life counter using LAN connectivity to improve UI. Developed for Andriod in Java. ([@John](https://github.com/johnnil), [@Angus](https://github.com/angloth)).

- [PhotoFullStack](https://github.com/gustaver/fullstack-photo-applcation) - Application we are building using Go backend and Swift/Android front end. MongoDB for database. ([@Gustave](https://github.com/gustaver), [@Oskar](https://github.com/oskaerik)).

- [SystemWallSolna](https://github.com/emilabr/Board) - A system wall application, used by climbers to mark their route on the system wall located at Klättercentret Solna. Developed for Android in Java. ([@Emil](https://github.com/emilabr), [@David](https://github.com/davyie), [@Richard](https://github.com/ricliu89))


text:
import DotPVect ( dotp )

import Control.Exception (evaluate)
import System.Console.GetOpt
import qualified System.Random as R

import qualified Data.Array.Parallel.Unlifted as U
import qualified Data.Array.Parallel.PArray   as P
import Data.Array.Parallel.PArray (PArray)

generateVectorU :: Int -> IO (U.Array Double)
generateVectorU n =
  do
    let seed = 42742
    let rg   = R.mkStdGen seed
    let -- The std random function is too slow to generate really big vectors
        -- with.  Instead, we generate a short random vector and repeat that.
        randvec = U.randomRs k (-100, 100) rg
        vec     = U.map (\i -> U.index "generateVectorU" randvec (i `mod` k)) (U.enumFromTo 0 (n-1))
    evaluate vec
    return vec
  where
    k = 1000

generateVector :: Int -> IO (PArray Double)
generateVector n
  = do
      vec <- generateVectorU n
      return $ P.fromUArray vec

generateVectors :: Int -> IO (PArray Double, PArray Double)
generateVectors n =
  do
    v <- generateVector n
    w <- generateVector n
    return (v,w)

main
 = do	-- compute dot product with NDP
	vectors			<- generateVectors 100000
	let resultViaNDP	= (uncurry dotp) vectors

	-- compute with lists
	let (aVecX, aVecY) = vectors
	let vecX		= P.toList aVecX
	let vecY		= P.toList aVecY
	let resultViaList	= sum $ zipWith (*) vecX vecY

	-- ignore wibbles in low order bits
	putStr $ (take 12 $ show resultViaNDP) ++ "\n"
	putStr $ (take 12 $ show resultViaList) ++ "\n"


text:
FROM node:16.13.0-slim

COPY ./ ./

RUN npm install
RUN npm run build

ENV NODE_ENV production
ENV DATABASE_CONFIGURATION_PROFILE mongodb
ENV FRAMEWORK express

EXPOSE 8080
CMD ["node", "dist/main"]


text:
jasmine.pp = function(obj) {
  return JSON.stringify(obj, undefined, 2);
};

beforeEach(() => {
  jasmine.addMatchers({
    toBeEmpty() {
      return {
        compare(actual) {
          const pass = Array.isArray(actual) ? !actual.length : !Object.keys(actual || {}).length;
          return {pass};
        }
      };
    }
  });
});


text:
<?php

/**
 * This code was generated by
 * \ / _    _  _|   _  _
 * | (_)\/(_)(_|\/| |(/_  v1.0.0
 * /       /
 */

namespace Twilio\Rest\IpMessaging\V1\Service\Channel;

use Twilio\Deserialize;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;

/**
 * @property string sid
 * @property string accountSid
 * @property string channelSid
 * @property string serviceSid
 * @property string identity
 * @property \DateTime dateCreated
 * @property \DateTime dateUpdated
 * @property string roleSid
 * @property integer lastConsumedMessageIndex
 * @property \DateTime lastConsumptionTimestamp
 * @property string url
 */
class MemberInstance extends InstanceResource {
    /**
     * Initialize the MemberInstance
     *
     * @param \Twilio\Version $version Version that contains the resource
     * @param mixed[] $payload The response payload
     * @param string $serviceSid The service_sid
     * @param string $channelSid The channel_sid
     * @param string $sid The sid
     * @return \Twilio\Rest\IpMessaging\V1\Service\Channel\MemberInstance
     */
    public function __construct(Version $version, array $payload, $serviceSid, $channelSid, $sid = null) {
        parent::__construct($version);

        // Marshaled Properties
        $this->properties = array(
            'sid' => Values::array_get($payload, 'sid'),
            'accountSid' => Values::array_get($payload, 'account_sid'),
            'channelSid' => Values::array_get($payload, 'channel_sid'),
            'serviceSid' => Values::array_get($payload, 'service_sid'),
            'identity' => Values::array_get($payload, 'identity'),
            'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
            'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
            'roleSid' => Values::array_get($payload, 'role_sid'),
            'lastConsumedMessageIndex' => Values::array_get($payload, 'last_consumed_message_index'),
            'lastConsumptionTimestamp' => Deserialize::dateTime(Values::array_get($payload, 'last_consumption_timestamp')),
            'url' => Values::array_get($payload, 'url'),
        );

        $this->solution = array(
            'serviceSid' => $serviceSid,
            'channelSid' => $channelSid,
            'sid' => $sid ?: $this->properties['sid'],
        );
    }

    /**
     * Generate an instance context for the instance, the context is capable of
     * performing various actions.  All instance actions are proxied to the context
     *
     * @return \Twilio\Rest\IpMessaging\V1\Service\Channel\MemberContext Context
     *                                                                   for this
     *                                                                   MemberInstance
     */
    protected function proxy() {
        if (!$this->context) {
            $this->context = new MemberContext(
                $this->version,
                $this->solution['serviceSid'],
                $this->solution['channelSid'],
                $this->solution['sid']
            );
        }

        return $this->context;
    }

    /**
     * Fetch a MemberInstance
     *
     * @return MemberInstance Fetched MemberInstance
     */
    public function fetch() {
        return $this->proxy()->fetch();
    }

    /**
     * Deletes the MemberInstance
     *
     * @return boolean True if delete succeeds, false otherwise
     */
    public function delete() {
        return $this->proxy()->delete();
    }

    /**
     * Update the MemberInstance
     *
     * @param array|Options $options Optional Arguments
     * @return MemberInstance Updated MemberInstance
     */
    public function update($options = array()) {
        return $this->proxy()->update(
            $options
        );
    }

    /**
     * Magic getter to access properties
     *
     * @param string $name Property to access
     * @return mixed The requested property
     * @throws TwilioException For unknown properties
     */
    public function __get($name) {
        if (array_key_exists($name, $this->properties)) {
            return $this->properties[$name];
        }

        if (property_exists($this, '_' . $name)) {
            $method = 'get' . ucfirst($name);
            return $this->$method();
        }

        throw new TwilioException('Unknown property: ' . $name);
    }

    /**
     * Provide a friendly representation
     *
     * @return string Machine friendly representation
     */
    public function __toString() {
        $context = array();
        foreach ($this->solution as $key => $value) {
            $context[] = "$key=$value";
        }
        return '[Twilio.IpMessaging.V1.MemberInstance ' . implode(' ', $context) . ']';
    }
}


text:
@interface MOBProjectionEPSG24346 : MOBProjection

@end


text:
package leetcode;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * https://leetcode.com/problems/first-bad-version/
 */
public class LC278FirstBadVersion {
    public class VersionControl {
        public int badVersion = 0;

        public boolean isBadVersion(int version) {
            return badVersion <= version;
        }
    }

    public class Solution extends VersionControl {
        public int firstBadVersion(int n) {
            long a = 1, z = n;
            while (a != z) {
                int i = (int) ((a + z) / 2);
                if (!isBadVersion(i)) {
                    a = i + 1;
                } else {
                    z = i;
                }
            }
            return (int) a;
        }
    }

    @Test
    public void test_example() {
        Solution solution = new Solution();
        solution.badVersion = 456;
        assertEquals(456, solution.firstBadVersion(8000));
    }

    @Test
    public void test_big_example() {
        Solution solution = new Solution();
        solution.badVersion = 1702766719;
        assertEquals(1702766719, solution.firstBadVersion(2126753390));
    }

    @Test
    public void test_small_example() {
        Solution solution = new Solution();
        solution.badVersion = 1;
        assertEquals(1, solution.firstBadVersion(1));
    }
}


text:
using Burrows.Configuration;
using Burrows.Configuration.BusConfigurators;
using Burrows.Tests.Framework;

namespace Burrows.Tests.Subscriptions
{
    using Magnum.Extensions;
    using Magnum.TestFramework;
    using NUnit.Framework;
    using TextFixtures;

    [TestFixture]
	public class When_a_message_is_received_that_is_polymorphic :
		LoopbackLocalAndRemoteTestFixture
	{
		Future<BaseMessage> _baseMessage;
		Future<Message> _message;

		protected override void EstablishContext()
		{
			base.EstablishContext();

			LocalBus.ShouldHaveSubscriptionFor<Message>();
			LocalBus.ShouldHaveSubscriptionFor<BaseMessage>();

			LocalBus.Publish(new Message());
		}

		protected override void ConfigureRemoteBus(IServiceBusConfigurator configurator)
		{
			base.ConfigureRemoteBus(configurator);

			_baseMessage = new Future<BaseMessage>();
			_message = new Future<Message>();

			configurator.Subscribe(cf =>
				{
					cf.Handler<BaseMessage>(message => _baseMessage.Complete(message));
					cf.Handler<Message>(message => _message.Complete(message));
				});
		}

		public class BaseMessage
		{
		}

		public class Message :
			BaseMessage
		{
		}

		[Test]
		public void Should_be_received_as_base_message()
		{
			_baseMessage.WaitUntilCompleted(8.Seconds()).ShouldBeTrue();
		}

		[Test]
		public void Should_be_received_as_message()
		{
			_message.WaitUntilCompleted(8.Seconds()).ShouldBeTrue();
		}
	}
}


text:
layout: home
permalink: /
image:
  feature: aspen-1600x800.jpg
---

Arbor is web-based software for carrying out phylogenetic comparative analyses of the tree of life.

Develop tools

Create your own functions and workflows

  Developers

Teach

Use Arbor in the classroom

  ArborEd

Get help

How to use Arbor

  Documentation


text:
<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
  <DefaultLanguage xmlns="" code="en-GB" />
  <Languages xmlns="">
    <Language code="en-GB" />
  </Languages>
  <App xmlns="" ProductID="{c1288bef-80f4-4c9b-bc12-524289e0cfed}" Title="Pokermetrix" RuntimeType="Silverlight" Version="1.0.0.1" Genre="apps.normal" Author="Adam Hill" Description="Texas Holdem Poker hand analysis tool. Significantly improves the odds of winning for beginner players by informing them whether a hand should be played or not." Publisher="Dootrix" PublisherID="{80a483b8-a51a-4d86-9d5e-e71b62c185f2}">
    <IconPath IsRelative="true" IsResource="false">Assets\ApplicationIcon.png</IconPath>
    <Capabilities>
    </Capabilities>
    <Tasks>
      <DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
    </Tasks>
    <Tokens>
      <PrimaryToken TokenID="PokermetrixToken" TaskName="_default">
        <TemplateFlip>
          <SmallImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileSmall.png</SmallImageURI>
          <Count>0</Count>
          <BackgroundImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileMedium.png</BackgroundImageURI>
          <Title>Pokermetrix</Title>
          <BackContent>
          </BackContent>
          <BackBackgroundImageURI IsRelative="true" IsResource="false">
          </BackBackgroundImageURI>
          <BackTitle>
          </BackTitle>
          <LargeBackgroundImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileLarge.png</LargeBackgroundImageURI>
          <LargeBackContent />
          <LargeBackBackgroundImageURI IsRelative="true" IsResource="false">
          </LargeBackBackgroundImageURI>
          <DeviceLockImageURI IsRelative="true" IsResource="false">
          </DeviceLockImageURI>
          <HasLarge>True</HasLarge>
        </TemplateFlip>
      </PrimaryToken>
    </Tokens>
    <ScreenResolutions>
      <ScreenResolution Name="ID_RESOLUTION_WXGA" />
      <ScreenResolution Name="ID_RESOLUTION_WVGA" />
      <ScreenResolution Name="ID_RESOLUTION_HD720P" />
    </ScreenResolutions>
  </App>
</Deployment>


text:
<?php if (function_exists('bcn_display') && !is_front_page() && !get_theme_mod('hide-breadcrumbs')) {
  /** breadcrumbs **/
  get_template_part('templates/components/breadcrumbs');
} ?>

<?php if (!get_theme_mod('hide-jumbotron')) {
  get_template_part('templates/components/jumbotron');
}


text:
var tempNamesArray = new Array("Ammo Set 1", "Ammo Set 2", "Ammo Set 3", "Ammo Set 4", "Ammo Set 5", "Ammo Set 6", "Ammo Set 7",
"Ammo Set 8", "Ammo Set 9", "Ammo Set 10");
var namesArray = new String[10];
var clipsArray = new int[10];
var maxClipsArray = new int[10];
var infiniteArray = new boolean[10];


text:
/**
* Component.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs        :: http://sailsjs.org/#!documentation/models
*/

module.exports = {

  attributes: {
  	format: {
    	type: 'string',
    	required: true,
    	enum: ['svg', 'png', 'description', 'mml']
    },
    source: {
    	type: 'string',
    	required: true
    },
    equation: {
    	model: 'equation'
    }
  }
};


text:
var scrypt = require("scrypt"),
    SimpleDynamo = require("node-simple-dynamo");

var database = SimpleDynamo({}, {
    region: "eu-west-1",
    dynamodb: '2012-08-10',
    // endpoint: "http://localhost:8088"
});

exports.createUser = function(user) {

    if (!process.env.SALT) {
        throw new Error("Authentication salt is not defined");
    }

    return scrypt.hash(user.password, {
        "N": 16,
        "r": 1,
        "p": 1
    }, 64, process.env.SALT).then(function(result) {

        user.password = result.toString("hex");
        return database.create("is-users", user);

    });

};

exports.getUsers = function(email) {

    return database.list("is-users", [{
        key: "email",
        operator: "EQ",
        value: email
    }]);

};

exports.getUserByEmailAndPassword = function(email, password) {

    if (!process.env.SALT) {
        throw new Error("Authentication salt is not defined");
    }

    // Cannot use as promise, lack of fail handler
    var result = scrypt.hashSync(password, {
        "N": 16,
        "r": 1,
        "p": 1
    }, 64, process.env.SALT);

    return database.query("is-users", [{
        key: "email",
        operator: "EQ",
        value: email
    },{
        key: "password",
        operator: "EQ",
        value: result.toString("hex")
    }], "EmailPasswordIndex").then(function(users) {

        if (users.length !== 1) {
            throw new Error(["User not found"]);
        }

        return users[0];

    });

};

exports.getUserByEmail = function(email) {

    return database.query("is-users", [{
        key: "email",
        operator: "EQ",
        value: email
    }], "EmailIndex").then(function(users) {

        if (users.length !== 1) {
            throw new Error(["User not found"]);
        }

        return users[0];

    });

};

exports.getUser = function(id) {

    return database.get("is-users", id);

};

exports.updateUser = function(user) {

    if (!user.id) {
        throw new Error("A user Id must be specified");
    }

    return database.update("is-users", user);

};


text:
package com.amazonaws.services.simplesystemsmanagement.model;

import com.amazonaws.AmazonServiceException;

/**
 * <p>
 * There are concurrent updates for a resource that supports one update at a
 * time.
 * </p>
 */
public class TooManyUpdatesException extends AmazonServiceException {
    private static final long serialVersionUID = 1L;

    /**
     * Constructs a new TooManyUpdatesException with the specified error
     * message.
     *
     * @param message
     *        Describes the error encountered.
     */
    public TooManyUpdatesException(String message) {
        super(message);
    }

}


text:
package androidx.camera.camera2.internal.compat;

import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.params.OutputConfiguration;
import android.util.Size;
import android.view.Surface;

import androidx.annotation.DoNotInline;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;

/**
 * A helper class to address ClassVerificationFailure.
 *
 * <p>See b/188451897.
 */
public final class ApiCompat {

    private ApiCompat() {
    }

    /**
     * Nested class to avoid verification errors for methods introduced in Android 5.0 (API 21).
     */
    @RequiresApi(21)
    public static class Api21Impl {

        private Api21Impl() {
        }

        /**
         * @see CameraDevice#close()
         */
        @DoNotInline
        public static void close(@NonNull CameraDevice cameraDevice) {
            cameraDevice.close();
        }
    }

    /**
     * Nested class to avoid verification errors for methods introduced in Android 6.0 (API 23).
     */
    @RequiresApi(23)
    public static class Api23Impl {

        private Api23Impl() {
        }

        /**
         * @see CameraCaptureSession.StateCallback#onSurfacePrepared(CameraCaptureSession, Surface)
         */
        @DoNotInline
        public static void onSurfacePrepared(
                @NonNull CameraCaptureSession.StateCallback callback,
                @NonNull CameraCaptureSession session,
                @NonNull Surface surface) {
            callback.onSurfacePrepared(session, surface);
        }
    }

    /**
     * Nested class to avoid verification errors for methods introduced in Android 7.0 (API 24).
     */
    @RequiresApi(24)
    public static class Api24Impl {

        private Api24Impl() {
        }

        /**
         * @see CameraCaptureSession.CaptureCallback#onCaptureBufferLost(CameraCaptureSession,
         * CaptureRequest, Surface, long)
         */
        @DoNotInline
        public static void onCaptureBufferLost(
                @NonNull CameraCaptureSession.CaptureCallback callback,
                @NonNull CameraCaptureSession session,
                @NonNull CaptureRequest request,
                @NonNull Surface surface,
                long frame) {
            callback.onCaptureBufferLost(session, request, surface, frame);
        }
    }

    /**
     * Nested class to avoid verification errors for methods introduced in Android 8.0 (API 26).
     */
    @RequiresApi(26)
    public static class Api26Impl {

        private Api26Impl() {
        }

        /**
         * @see CameraCaptureSession.StateCallback#onCaptureQueueEmpty(CameraCaptureSession)
         */
        @DoNotInline
        public static void onCaptureQueueEmpty(
                @NonNull CameraCaptureSession.StateCallback callback,
                @NonNull CameraCaptureSession session) {
            callback.onCaptureQueueEmpty(session);
        }

        /**
         * @see OutputConfiguration
         */
        @DoNotInline
        @NonNull
        public static <T> OutputConfiguration newOutputConfiguration(@NonNull Size surfaceSize,
                @NonNull Class<T> klass) {
            return new OutputConfiguration(surfaceSize, klass);
        }
    }

    /**
     * Nested class to avoid verification errors for methods introduced in Android 10 (API 29).
     */
    @RequiresApi(29)
    public static class Api29Impl {

        private Api29Impl() {
        }

        /**
         * @see CameraManager.AvailabilityCallback#onCameraAccessPrioritiesChanged()
         */
        @DoNotInline
        public static void onCameraAccessPrioritiesChanged(
                @NonNull CameraManager.AvailabilityCallback callback) {
            callback.onCameraAccessPrioritiesChanged();
        }
    }
}