text:
<?php

/**
 * Base static class for performing query and update operations on the 'item' table.
 *
 *
 *
 * @package    propel.generator..om
 */
abstract class BaseItemPeer {

	/** the default database name for this class */
	const DATABASE_NAME = GB_DATABASE;

	/** the table name for this class */
	const TABLE_NAME = 'item';

	/** the related Propel class for this table */
	const OM_CLASS = 'Item';

	/** the related TableMap class for this table */
	const TM_CLASS = 'ItemTableMap';

	/** The total number of columns. */
	const NUM_COLUMNS = 21;

	/** The number of lazy-loaded columns. */
	const NUM_LAZY_LOAD_COLUMNS = 0;

	/** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
	const NUM_HYDRATE_COLUMNS = 21;

	/** the column name for the ID field */
	const ID = 'item.ID';

	/** the column name for the ISBN field */
	const ISBN = 'item.ISBN';

	/** the column name for the PACKAGE_ID field */
	const PACKAGE_ID = 'item.PACKAGE_ID';

	/** the column name for the IS_PACKAGE field */
	const IS_PACKAGE = 'item.IS_PACKAGE';

	/** the column name for the TITLE field */
	const TITLE = 'item.TITLE';

	/** the column name for the AUTHOR field */
	const AUTHOR = 'item.AUTHOR';

	/** the column name for the EDITION field */
	const EDITION = 'item.EDITION';

	/** the column name for the PUBLISHER field */
	const PUBLISHER = 'item.PUBLISHER';

	/** the column name for the B_NEW field */
	const B_NEW = 'item.B_NEW';

	/** the column name for the B_USED field */
	const B_USED = 'item.B_USED';

	/** the column name for the B_EBOOK field */
	const B_EBOOK = 'item.B_EBOOK';

	/** the column name for the IMAGE_URL field */
	const IMAGE_URL = 'item.IMAGE_URL';

	/** the column name for the PRODUCT_ID field */
	const PRODUCT_ID = 'item.PRODUCT_ID';

	/** the column name for the PART_NUMBER field */
	const PART_NUMBER = 'item.PART_NUMBER';

	/** the column name for the SPIDERED_AT field */
	const SPIDERED_AT = 'item.SPIDERED_AT';

	/** the column name for the SHALLOW_SPIDERED_AT field */
	const SHALLOW_SPIDERED_AT = 'item.SHALLOW_SPIDERED_AT';

	/** the column name for the TOUCHED field */
	const TOUCHED = 'item.TOUCHED';

	/** the column name for the B_ID field */
	const B_ID = 'item.B_ID';

	/** the column name for the BOOKSTORE_TYPE field */
	const BOOKSTORE_TYPE = 'item.BOOKSTORE_TYPE';

	/** the column name for the CREATED_AT field */
	const CREATED_AT = 'item.CREATED_AT';

	/** the column name for the UPDATED_AT field */
	const UPDATED_AT = 'item.UPDATED_AT';

	/** The default string format for model objects of the related table **/
	const DEFAULT_STRING_FORMAT = 'YAML';

	/**
	 * An identiy map to hold any loaded instances of Item objects.
	 * This must be public so that other peer classes can access this when hydrating from JOIN
	 * queries.
	 * @var        array Item[]
	 */
	public static $instances = array();

	/**
	 * holds an array of fieldnames
	 *
	 * first dimension keys are the type constants
	 * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
	 */
	protected static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('Id', 'Isbn', 'PackageId', 'IsPackage', 'Title', 'Author', 'Edition', 'Publisher', 'BNew', 'BUsed', 'BEbook', 'ImageUrl', 'ProductId', 'PartNumber', 'SpideredAt', 'ShallowSpideredAt', 'Touched', 'BId', 'BookstoreType', 'CreatedAt', 'UpdatedAt', ),
		BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'isbn', 'packageId', 'isPackage', 'title', 'author', 'edition', 'publisher', 'bNew', 'bUsed', 'bEbook', 'imageUrl', 'productId', 'partNumber', 'spideredAt', 'shallowSpideredAt', 'touched', 'bId', 'bookstoreType', 'createdAt', 'updatedAt', ),
		BasePeer::TYPE_COLNAME => array (self::ID, self::ISBN, self::PACKAGE_ID, self::IS_PACKAGE, self::TITLE, self::AUTHOR, self::EDITION, self::PUBLISHER, self::B_NEW, self::B_USED, self::B_EBOOK, self::IMAGE_URL, self::PRODUCT_ID, self::PART_NUMBER, self::SPIDERED_AT, self::SHALLOW_SPIDERED_AT, self::TOUCHED, self::B_ID, self::BOOKSTORE_TYPE, self::CREATED_AT, self::UPDATED_AT, ),
		BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ISBN', 'PACKAGE_ID', 'IS_PACKAGE', 'TITLE', 'AUTHOR', 'EDITION', 'PUBLISHER', 'B_NEW', 'B_USED', 'B_EBOOK', 'IMAGE_URL', 'PRODUCT_ID', 'PART_NUMBER', 'SPIDERED_AT', 'SHALLOW_SPIDERED_AT', 'TOUCHED', 'B_ID', 'BOOKSTORE_TYPE', 'CREATED_AT', 'UPDATED_AT', ),
		BasePeer::TYPE_FIELDNAME => array ('id', 'isbn', 'package_id', 'is_package', 'title', 'author', 'edition', 'publisher', 'b_new', 'b_used', 'b_ebook', 'image_url', 'product_id', 'part_number', 'spidered_at', 'shallow_spidered_at', 'touched', 'b_id', 'bookstore_type', 'created_at', 'updated_at', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, )
	);

	/**
	 * holds an array of keys for quick access to the fieldnames array
	 *
	 * first dimension keys are the type constants
	 * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
	 */
	protected static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Isbn' => 1, 'PackageId' => 2, 'IsPackage' => 3, 'Title' => 4, 'Author' => 5, 'Edition' => 6, 'Publisher' => 7, 'BNew' => 8, 'BUsed' => 9, 'BEbook' => 10, 'ImageUrl' => 11, 'ProductId' => 12, 'PartNumber' => 13, 'SpideredAt' => 14, 'ShallowSpideredAt' => 15, 'Touched' => 16, 'BId' => 17, 'BookstoreType' => 18, 'CreatedAt' => 19, 'UpdatedAt' => 20, ),
		BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'isbn' => 1, 'packageId' => 2, 'isPackage' => 3, 'title' => 4, 'author' => 5, 'edition' => 6, 'publisher' => 7, 'bNew' => 8, 'bUsed' => 9, 'bEbook' => 10, 'imageUrl' => 11, 'productId' => 12, 'partNumber' => 13, 'spideredAt' => 14, 'shallowSpideredAt' => 15, 'touched' => 16, 'bId' => 17, 'bookstoreType' => 18, 'createdAt' => 19, 'updatedAt' => 20, ),
		BasePeer::TYPE_COLNAME => array (self::ID => 0, self::ISBN => 1, self::PACKAGE_ID => 2, self::IS_PACKAGE => 3, self::TITLE => 4, self::AUTHOR => 5, self::EDITION => 6, self::PUBLISHER => 7, self::B_NEW => 8, self::B_USED => 9, self::B_EBOOK => 10, self::IMAGE_URL => 11, self::PRODUCT_ID => 12, self::PART_NUMBER => 13, self::SPIDERED_AT => 14, self::SHALLOW_SPIDERED_AT => 15, self::TOUCHED => 16, self::B_ID => 17, self::BOOKSTORE_TYPE => 18, self::CREATED_AT => 19, self::UPDATED_AT => 20, ),
		BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ISBN' => 1, 'PACKAGE_ID' => 2, 'IS_PACKAGE' => 3, 'TITLE' => 4, 'AUTHOR' => 5, 'EDITION' => 6, 'PUBLISHER' => 7, 'B_NEW' => 8, 'B_USED' => 9, 'B_EBOOK' => 10, 'IMAGE_URL' => 11, 'PRODUCT_ID' => 12, 'PART_NUMBER' => 13, 'SPIDERED_AT' => 14, 'SHALLOW_SPIDERED_AT' => 15, 'TOUCHED' => 16, 'B_ID' => 17, 'BOOKSTORE_TYPE' => 18, 'CREATED_AT' => 19, 'UPDATED_AT' => 20, ),
		BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'isbn' => 1, 'package_id' => 2, 'is_package' => 3, 'title' => 4, 'author' => 5, 'edition' => 6, 'publisher' => 7, 'b_new' => 8, 'b_used' => 9, 'b_ebook' => 10, 'image_url' => 11, 'product_id' => 12, 'part_number' => 13, 'spidered_at' => 14, 'shallow_spidered_at' => 15, 'touched' => 16, 'b_id' => 17, 'bookstore_type' => 18, 'created_at' => 19, 'updated_at' => 20, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, )
	);

	/**
	 * Translates a fieldname to another type
	 *
	 * @param      string $name field name
	 * @param      string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
	 *                         BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
	 * @param      string $toType   One of the class type constants
	 * @return     string translated name of the field.
	 * @throws     PropelException - if the specified name could not be found in the fieldname mappings.
	 */
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	/**
	 * Returns an array of field names.
	 *
	 * @param      string $type The type of fieldnames to return:
	 *                      One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
	 *                      BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
	 * @return     array A list of field names
	 */

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	/**
	 * Convenience method which changes table.column to alias.column.
	 *
	 * Using this method you can maintain SQL abstraction while using column aliases.
	 * <code>
	 *		$c->addAlias("alias1", TablePeer::TABLE_NAME);
	 *		$c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
	 * </code>
	 * @param      string $alias The alias for the current table.
	 * @param      string $column The column name for current table. (i.e. ItemPeer::COLUMN_NAME).
	 * @return     string
	 */
	public static function alias($alias, $column)
	{
		return str_replace(ItemPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	/**
	 * Add all the columns needed to create a new object.
	 *
	 * Note: any columns that were marked with lazyLoad="true" in the
	 * XML schema will not be added to the select list and only loaded
	 * on demand.
	 *
	 * @param      Criteria $criteria object containing the columns to add.
	 * @param      string   $alias    optional table alias
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function addSelectColumns(Criteria $criteria, $alias = null)
	{
		if (null === $alias) {
			$criteria->addSelectColumn(ItemPeer::ID);
			$criteria->addSelectColumn(ItemPeer::ISBN);
			$criteria->addSelectColumn(ItemPeer::PACKAGE_ID);
			$criteria->addSelectColumn(ItemPeer::IS_PACKAGE);
			$criteria->addSelectColumn(ItemPeer::TITLE);
			$criteria->addSelectColumn(ItemPeer::AUTHOR);
			$criteria->addSelectColumn(ItemPeer::EDITION);
			$criteria->addSelectColumn(ItemPeer::PUBLISHER);
			$criteria->addSelectColumn(ItemPeer::B_NEW);
			$criteria->addSelectColumn(ItemPeer::B_USED);
			$criteria->addSelectColumn(ItemPeer::B_EBOOK);
			$criteria->addSelectColumn(ItemPeer::IMAGE_URL);
			$criteria->addSelectColumn(ItemPeer::PRODUCT_ID);
			$criteria->addSelectColumn(ItemPeer::PART_NUMBER);
			$criteria->addSelectColumn(ItemPeer::SPIDERED_AT);
			$criteria->addSelectColumn(ItemPeer::SHALLOW_SPIDERED_AT);
			$criteria->addSelectColumn(ItemPeer::TOUCHED);
			$criteria->addSelectColumn(ItemPeer::B_ID);
			$criteria->addSelectColumn(ItemPeer::BOOKSTORE_TYPE);
			$criteria->addSelectColumn(ItemPeer::CREATED_AT);
			$criteria->addSelectColumn(ItemPeer::UPDATED_AT);
		} else {
			$criteria->addSelectColumn($alias . '.ID');
			$criteria->addSelectColumn($alias . '.ISBN');
			$criteria->addSelectColumn($alias . '.PACKAGE_ID');
			$criteria->addSelectColumn($alias . '.IS_PACKAGE');
			$criteria->addSelectColumn($alias . '.TITLE');
			$criteria->addSelectColumn($alias . '.AUTHOR');
			$criteria->addSelectColumn($alias . '.EDITION');
			$criteria->addSelectColumn($alias . '.PUBLISHER');
			$criteria->addSelectColumn($alias . '.B_NEW');
			$criteria->addSelectColumn($alias . '.B_USED');
			$criteria->addSelectColumn($alias . '.B_EBOOK');
			$criteria->addSelectColumn($alias . '.IMAGE_URL');
			$criteria->addSelectColumn($alias . '.PRODUCT_ID');
			$criteria->addSelectColumn($alias . '.PART_NUMBER');
			$criteria->addSelectColumn($alias . '.SPIDERED_AT');
			$criteria->addSelectColumn($alias . '.SHALLOW_SPIDERED_AT');
			$criteria->addSelectColumn($alias . '.TOUCHED');
			$criteria->addSelectColumn($alias . '.B_ID');
			$criteria->addSelectColumn($alias . '.BOOKSTORE_TYPE');
			$criteria->addSelectColumn($alias . '.CREATED_AT');
			$criteria->addSelectColumn($alias . '.UPDATED_AT');
		}
	}

	/**
	 * Returns the number of rows matching criteria.
	 *
	 * @param      Criteria $criteria
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
	 * @param      PropelPDO $con
	 * @return     int Number of matching rows.
	 */
	public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
	{
		// we may modify criteria, so copy it first
		$criteria = clone $criteria;

		// We need to set the primary table name, since in the case that there are no WHERE columns
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
		// tables go into the FROM clause.
		$criteria->setPrimaryTableName(ItemPeer::TABLE_NAME);

		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->setDistinct();
		}

		if (!$criteria->hasSelectClause()) {
			ItemPeer::addSelectColumns($criteria);
		}

		$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
		$criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName

		if ($con === null) {
			$con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}
		// BasePeer returns a PDOStatement
		$stmt = BasePeer::doCount($criteria, $con);

		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$count = (int) $row[0];
		} else {
			$count = 0; // no rows returned; we infer that means 0 matches.
		}
		$stmt->closeCursor();
		return $count;
	}
	/**
	 * Selects one object from the DB.
	 *
	 * @param      Criteria $criteria object used to create the SELECT statement.
	 * @param      PropelPDO $con
	 * @return     Item
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = ItemPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	/**
	 * Selects several row from the DB.
	 *
	 * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
	 * @param      PropelPDO $con
	 * @return     array Array of selected Objects
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelect(Criteria $criteria, PropelPDO $con = null)
	{
		return ItemPeer::populateObjects(ItemPeer::doSelectStmt($criteria, $con));
	}
	/**
	 * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
	 *
	 * Use this method directly if you want to work with an executed statement durirectly (for example
	 * to perform your own object hydration).
	 *
	 * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
	 * @param      PropelPDO $con The connection to use
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 * @return     PDOStatement The executed PDOStatement object.
	 * @see        BasePeer::doSelect()
	 */
	public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		if (!$criteria->hasSelectClause()) {
			$criteria = clone $criteria;
			ItemPeer::addSelectColumns($criteria);
		}

		// Set the correct dbName
		$criteria->setDbName(self::DATABASE_NAME);

		// BasePeer returns a PDOStatement
		return BasePeer::doSelect($criteria, $con);
	}
	/**
	 * Adds an object to the instance pool.
	 *
	 * Propel keeps cached copies of objects in an instance pool when they are retrieved
	 * from the database.  In some cases -- especially when you override doSelect*()
	 * methods in your stub classes -- you may need to explicitly add objects
	 * to the cache in order to ensure that the same objects are always returned by doSelect*()
	 * and retrieveByPK*() calls.
	 *
	 * @param      Item $value A Item object.
	 * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
	 */
	public static function addInstanceToPool($obj, $key = null)
	{
		if (Propel::isInstancePoolingEnabled()) {
			if ($key === null) {
				$key = (string) $obj->getId();
			} // if key === null
			self::$instances[$key] = $obj;
		}
	}

	/**
	 * Removes an object from the instance pool.
	 *
	 * Propel keeps cached copies of objects in an instance pool when they are retrieved
	 * from the database.  In some cases -- especially when you override doDelete
	 * methods in your stub classes -- you may need to explicitly remove objects
	 * from the cache in order to prevent returning objects that no longer exist.
	 *
	 * @param      mixed $value A Item object or a primary key value.
	 */
	public static function removeInstanceFromPool($value)
	{
		if (Propel::isInstancePoolingEnabled() && $value !== null) {
			if (is_object($value) && $value instanceof Item) {
				$key = (string) $value->getId();
			} elseif (is_scalar($value)) {
				// assume we've been passed a primary key
				$key = (string) $value;
			} else {
				$e = new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or Item object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
				throw $e;
			}

			unset(self::$instances[$key]);
		}
	} // removeInstanceFromPool()

	/**
	 * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
	 *
	 * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
	 * a multi-column primary key, a serialize()d version of the primary key will be returned.
	 *
	 * @param      string $key The key (@see getPrimaryKeyHash()) for this instance.
	 * @return     Item Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
	 * @see        getPrimaryKeyHash()
	 */
	public static function getInstanceFromPool($key)
	{
		if (Propel::isInstancePoolingEnabled()) {
			if (isset(self::$instances[$key])) {
				return self::$instances[$key];
			}
		}
		return null; // just to be explicit
	}

	/**
	 * Clear the instance pool.
	 *
	 * @return     void
	 */
	public static function clearInstancePool()
	{
		self::$instances = array();
	}

	/**
	 * Method to invalidate the instance pool of all tables related to item
	 * by a foreign key with ON DELETE CASCADE
	 */
	public static function clearRelatedInstancePool()
	{
		// Invalidate objects in ItemPeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		ItemPeer::clearInstancePool();
		// Invalidate objects in SectionHasItemPeer instance pool,
		// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
		SectionHasItemPeer::clearInstancePool();
	}

	/**
	 * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
	 *
	 * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
	 * a multi-column primary key, a serialize()d version of the primary key will be returned.
	 *
	 * @param      array $row PropelPDO resultset row.
	 * @param      int $startcol The 0-based offset for reading from the resultset row.
	 * @return     string A string version of PK or NULL if the components of primary key in result array are all null.
	 */
	public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
	{
		// If the PK cannot be derived from the row, return NULL.
		if ($row[$startcol] === null) {
			return null;
		}
		return (string) $row[$startcol];
	}

	/**
	 * Retrieves the primary key from the DB resultset row
	 * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
	 * a multi-column primary key, an array of the primary key columns will be returned.
	 *
	 * @param      array $row PropelPDO resultset row.
	 * @param      int $startcol The 0-based offset for reading from the resultset row.
	 * @return     mixed The primary key of the row
	 */
	public static function getPrimaryKeyFromRow($row, $startcol = 0)
	{
		return (int) $row[$startcol];
	}

	/**
	 * The returned array will contain objects of the default type or
	 * objects that inherit from the default.
	 *
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function populateObjects(PDOStatement $stmt)
	{
		$results = array();

		// set the class once to avoid overhead in the loop
		$cls = ItemPeer::getOMClass();
		// populate the object(s)
		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$key = ItemPeer::getPrimaryKeyHashFromRow($row, 0);
			if (null !== ($obj = ItemPeer::getInstanceFromPool($key))) {
				// We no longer rehydrate the object, since this can cause data loss.
				// See http://www.propelorm.org/ticket/509
				// $obj->hydrate($row, 0, true); // rehydrate
				$results[] = $obj;
			} else {
				$obj = new $cls();
				$obj->hydrate($row);
				$results[] = $obj;
				ItemPeer::addInstanceToPool($obj, $key);
			} // if key exists
		}
		$stmt->closeCursor();
		return $results;
	}
	/**
	 * Populates an object of the default type or an object that inherit from the default.
	 *
	 * @param      array $row PropelPDO resultset row.
	 * @param      int $startcol The 0-based offset for reading from the resultset row.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 * @return     array (Item object, last column rank)
	 */
	public static function populateObject($row, $startcol = 0)
	{
		$key = ItemPeer::getPrimaryKeyHashFromRow($row, $startcol);
		if (null !== ($obj = ItemPeer::getInstanceFromPool($key))) {
			// We no longer rehydrate the object, since this can cause data loss.
			// See http://www.propelorm.org/ticket/509
			// $obj->hydrate($row, $startcol, true); // rehydrate
			$col = $startcol + ItemPeer::NUM_HYDRATE_COLUMNS;
		} else {
			$cls = ItemPeer::OM_CLASS;
			$obj = new $cls();
			$col = $obj->hydrate($row, $startcol);
			ItemPeer::addInstanceToPool($obj, $key);
		}
		return array($obj, $col);
	}

	/**
	 * Returns the number of rows matching criteria, joining the related Book table
	 *
	 * @param      Criteria $criteria
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
	 * @param      PropelPDO $con
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
	 * @return     int Number of matching rows.
	 */
	public static function doCountJoinBook(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		// we're going to modify criteria, so copy it first
		$criteria = clone $criteria;

		// We need to set the primary table name, since in the case that there are no WHERE columns
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
		// tables go into the FROM clause.
		$criteria->setPrimaryTableName(ItemPeer::TABLE_NAME);

		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->setDistinct();
		}

		if (!$criteria->hasSelectClause()) {
			ItemPeer::addSelectColumns($criteria);
		}

		$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count

		// Set the correct dbName
		$criteria->setDbName(self::DATABASE_NAME);

		if ($con === null) {
			$con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		$criteria->addJoin(ItemPeer::ISBN, BookPeer::ISBN, $join_behavior);

		$stmt = BasePeer::doCount($criteria, $con);

		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$count = (int) $row[0];
		} else {
			$count = 0; // no rows returned; we infer that means 0 matches.
		}
		$stmt->closeCursor();
		return $count;
	}

	/**
	 * Selects a collection of Item objects pre-filled with their Book objects.
	 * @param      Criteria  $criteria
	 * @param      PropelPDO $con
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
	 * @return     array Array of Item objects.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelectJoinBook(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		$criteria = clone $criteria;

		// Set the correct dbName if it has not been overridden
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
			$criteria->setDbName(self::DATABASE_NAME);
		}

		ItemPeer::addSelectColumns($criteria);
		$startcol = ItemPeer::NUM_HYDRATE_COLUMNS;
		BookPeer::addSelectColumns($criteria);

		$criteria->addJoin(ItemPeer::ISBN, BookPeer::ISBN, $join_behavior);

		$stmt = BasePeer::doSelect($criteria, $con);
		$results = array();

		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$key1 = ItemPeer::getPrimaryKeyHashFromRow($row, 0);
			if (null !== ($obj1 = ItemPeer::getInstanceFromPool($key1))) {
				// We no longer rehydrate the object, since this can cause data loss.
				// See http://www.propelorm.org/ticket/509
				// $obj1->hydrate($row, 0, true); // rehydrate
			} else {

				$cls = ItemPeer::getOMClass();

				$obj1 = new $cls();
				$obj1->hydrate($row);
				ItemPeer::addInstanceToPool($obj1, $key1);
			} // if $obj1 already loaded

			$key2 = BookPeer::getPrimaryKeyHashFromRow($row, $startcol);
			if ($key2 !== null) {
				$obj2 = BookPeer::getInstanceFromPool($key2);
				if (!$obj2) {

					$cls = BookPeer::getOMClass();

					$obj2 = new $cls();
					$obj2->hydrate($row, $startcol);
					BookPeer::addInstanceToPool($obj2, $key2);
				} // if obj2 already loaded

				// Add the $obj1 (Item) to $obj2 (Book)
				$obj2->addItem($obj1);

			} // if joined row was not null

			$results[] = $obj1;
		}
		$stmt->closeCursor();
		return $results;
	}

	/**
	 * Returns the number of rows matching criteria, joining all related tables
	 *
	 * @param      Criteria $criteria
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
	 * @param      PropelPDO $con
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
	 * @return     int Number of matching rows.
	 */
	public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		// we're going to modify criteria, so copy it first
		$criteria = clone $criteria;

		// We need to set the primary table name, since in the case that there are no WHERE columns
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
		// tables go into the FROM clause.
		$criteria->setPrimaryTableName(ItemPeer::TABLE_NAME);

		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->setDistinct();
		}

		if (!$criteria->hasSelectClause()) {
			ItemPeer::addSelectColumns($criteria);
		}

		$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count

		// Set the correct dbName
		$criteria->setDbName(self::DATABASE_NAME);

		if ($con === null) {
			$con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		$criteria->addJoin(ItemPeer::ISBN, BookPeer::ISBN, $join_behavior);

		$stmt = BasePeer::doCount($criteria, $con);

		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$count = (int) $row[0];
		} else {
			$count = 0; // no rows returned; we infer that means 0 matches.
		}
		$stmt->closeCursor();
		return $count;
	}

	/**
	 * Selects a collection of Item objects pre-filled with all related objects.
	 *
	 * @param      Criteria  $criteria
	 * @param      PropelPDO $con
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
	 * @return     array Array of Item objects.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		$criteria = clone $criteria;

		// Set the correct dbName if it has not been overridden
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
			$criteria->setDbName(self::DATABASE_NAME);
		}

		ItemPeer::addSelectColumns($criteria);
		$startcol2 = ItemPeer::NUM_HYDRATE_COLUMNS;

		BookPeer::addSelectColumns($criteria);
		$startcol3 = $startcol2 + BookPeer::NUM_HYDRATE_COLUMNS;

		$criteria->addJoin(ItemPeer::ISBN, BookPeer::ISBN, $join_behavior);

		$stmt = BasePeer::doSelect($criteria, $con);
		$results = array();

		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$key1 = ItemPeer::getPrimaryKeyHashFromRow($row, 0);
			if (null !== ($obj1 = ItemPeer::getInstanceFromPool($key1))) {
				// We no longer rehydrate the object, since this can cause data loss.
				// See http://www.propelorm.org/ticket/509
				// $obj1->hydrate($row, 0, true); // rehydrate
			} else {
				$cls = ItemPeer::getOMClass();

				$obj1 = new $cls();
				$obj1->hydrate($row);
				ItemPeer::addInstanceToPool($obj1, $key1);
			} // if obj1 already loaded

			// Add objects for joined Book rows

			$key2 = BookPeer::getPrimaryKeyHashFromRow($row, $startcol2);
			if ($key2 !== null) {
				$obj2 = BookPeer::getInstanceFromPool($key2);
				if (!$obj2) {

					$cls = BookPeer::getOMClass();

					$obj2 = new $cls();
					$obj2->hydrate($row, $startcol2);
					BookPeer::addInstanceToPool($obj2, $key2);
				} // if obj2 loaded

				// Add the $obj1 (Item) to the collection in $obj2 (Book)
				$obj2->addItem($obj1);
			} // if joined row not null

			$results[] = $obj1;
		}
		$stmt->closeCursor();
		return $results;
	}

	/**
	 * Returns the number of rows matching criteria, joining the related Book table
	 *
	 * @param      Criteria $criteria
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
	 * @param      PropelPDO $con
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
	 * @return     int Number of matching rows.
	 */
	public static function doCountJoinAllExceptBook(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		// we're going to modify criteria, so copy it first
		$criteria = clone $criteria;

		// We need to set the primary table name, since in the case that there are no WHERE columns
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
		// tables go into the FROM clause.
		$criteria->setPrimaryTableName(ItemPeer::TABLE_NAME);

		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->setDistinct();
		}

		if (!$criteria->hasSelectClause()) {
			ItemPeer::addSelectColumns($criteria);
		}

		$criteria->clearOrderByColumns(); // ORDER BY should not affect count

		// Set the correct dbName
		$criteria->setDbName(self::DATABASE_NAME);

		if ($con === null) {
			$con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		$stmt = BasePeer::doCount($criteria, $con);

		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$count = (int) $row[0];
		} else {
			$count = 0; // no rows returned; we infer that means 0 matches.
		}
		$stmt->closeCursor();
		return $count;
	}

	/**
	 * Returns the number of rows matching criteria, joining the related ItemRelatedByPackageId table
	 *
	 * @param      Criteria $criteria
	 * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
	 * @param      PropelPDO $con
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
	 * @return     int Number of matching rows.
	 */
	public static function doCountJoinAllExceptItemRelatedByPackageId(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		// we're going to modify criteria, so copy it first
		$criteria = clone $criteria;

		// We need to set the primary table name, since in the case that there are no WHERE columns
		// it will be impossible for the BasePeer::createSelectSql() method to determine which
		// tables go into the FROM clause.
		$criteria->setPrimaryTableName(ItemPeer::TABLE_NAME);

		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->setDistinct();
		}

		if (!$criteria->hasSelectClause()) {
			ItemPeer::addSelectColumns($criteria);
		}

		$criteria->clearOrderByColumns(); // ORDER BY should not affect count

		// Set the correct dbName
		$criteria->setDbName(self::DATABASE_NAME);

		if ($con === null) {
			$con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		$criteria->addJoin(ItemPeer::ISBN, BookPeer::ISBN, $join_behavior);

		$stmt = BasePeer::doCount($criteria, $con);

		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$count = (int) $row[0];
		} else {
			$count = 0; // no rows returned; we infer that means 0 matches.
		}
		$stmt->closeCursor();
		return $count;
	}

	/**
	 * Selects a collection of Item objects pre-filled with all related objects except Book.
	 *
	 * @param      Criteria  $criteria
	 * @param      PropelPDO $con
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
	 * @return     array Array of Item objects.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelectJoinAllExceptBook(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		$criteria = clone $criteria;

		// Set the correct dbName if it has not been overridden
		// $criteria->getDbName() will return the same object if not set to another value
		// so == check is okay and faster
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
			$criteria->setDbName(self::DATABASE_NAME);
		}

		ItemPeer::addSelectColumns($criteria);
		$startcol2 = ItemPeer::NUM_HYDRATE_COLUMNS;

		$stmt = BasePeer::doSelect($criteria, $con);
		$results = array();

		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$key1 = ItemPeer::getPrimaryKeyHashFromRow($row, 0);
			if (null !== ($obj1 = ItemPeer::getInstanceFromPool($key1))) {
				// We no longer rehydrate the object, since this can cause data loss.
				// See http://www.propelorm.org/ticket/509
				// $obj1->hydrate($row, 0, true); // rehydrate
			} else {
				$cls = ItemPeer::getOMClass();

				$obj1 = new $cls();
				$obj1->hydrate($row);
				ItemPeer::addInstanceToPool($obj1, $key1);
			} // if obj1 already loaded

			$results[] = $obj1;
		}
		$stmt->closeCursor();
		return $results;
	}

	/**
	 * Selects a collection of Item objects pre-filled with all related objects except ItemRelatedByPackageId.
	 *
	 * @param      Criteria  $criteria
	 * @param      PropelPDO $con
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
	 * @return     array Array of Item objects.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelectJoinAllExceptItemRelatedByPackageId(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		$criteria = clone $criteria;

		// Set the correct dbName if it has not been overridden
		// $criteria->getDbName() will return the same object if not set to another value
		// so == check is okay and faster
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
			$criteria->setDbName(self::DATABASE_NAME);
		}

		ItemPeer::addSelectColumns($criteria);
		$startcol2 = ItemPeer::NUM_HYDRATE_COLUMNS;

		BookPeer::addSelectColumns($criteria);
		$startcol3 = $startcol2 + BookPeer::NUM_HYDRATE_COLUMNS;

		$criteria->addJoin(ItemPeer::ISBN, BookPeer::ISBN, $join_behavior);

		$stmt = BasePeer::doSelect($criteria, $con);
		$results = array();

		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$key1 = ItemPeer::getPrimaryKeyHashFromRow($row, 0);
			if (null !== ($obj1 = ItemPeer::getInstanceFromPool($key1))) {
				// We no longer rehydrate the object, since this can cause data loss.
				// See http://www.propelorm.org/ticket/509
				// $obj1->hydrate($row, 0, true); // rehydrate
			} else {
				$cls = ItemPeer::getOMClass();

				$obj1 = new $cls();
				$obj1->hydrate($row);
				ItemPeer::addInstanceToPool($obj1, $key1);
			} // if obj1 already loaded

				// Add objects for joined Book rows

				$key2 = BookPeer::getPrimaryKeyHashFromRow($row, $startcol2);
				if ($key2 !== null) {
					$obj2 = BookPeer::getInstanceFromPool($key2);
					if (!$obj2) {

						$cls = BookPeer::getOMClass();

					$obj2 = new $cls();
					$obj2->hydrate($row, $startcol2);
					BookPeer::addInstanceToPool($obj2, $key2);
				} // if $obj2 already loaded

				// Add the $obj1 (Item) to the collection in $obj2 (Book)
				$obj2->addItem($obj1);

			} // if joined row is not null

			$results[] = $obj1;
		}
		$stmt->closeCursor();
		return $results;
	}

	/**
	 * Returns the TableMap related to this peer.
	 * This method is not needed for general use but a specific application could have a need.
	 * @return     TableMap
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	/**
	 * Add a TableMap instance to the database for this peer class.
	 */
	public static function buildTableMap()
	{
	  $dbMap = Propel::getDatabaseMap(BaseItemPeer::DATABASE_NAME);
	  if (!$dbMap->hasTable(BaseItemPeer::TABLE_NAME))
	  {
	    $dbMap->addTableObject(new ItemTableMap());
	  }
	}

	/**
	 * The class that the Peer will make instances of.
	 *
	 *
	 * @return     string ClassName
	 */
	public static function getOMClass()
	{
		return ItemPeer::OM_CLASS;
	}

	/**
	 * Performs an INSERT on the database, given a Item or Criteria object.
	 *
	 * @param      mixed $values Criteria or Item object containing data that is used to create the INSERT statement.
	 * @param      PropelPDO $con the PropelPDO connection to use
	 * @return     mixed The new primary key.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doInsert($values, PropelPDO $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; // rename for clarity
		} else {
			$criteria = $values->buildCriteria(); // build Criteria from Item object
		}

		if ($criteria->containsKey(ItemPeer::ID) && $criteria->keyContainsValue(ItemPeer::ID) ) {
			throw new PropelException('Cannot insert a value for auto-increment primary key ('.ItemPeer::ID.')');
		}

		// Set the correct dbName
		$criteria->setDbName(self::DATABASE_NAME);

		try {
			// use transaction because $criteria could contain info
			// for more than one table (I guess, conceivably)
			$con->beginTransaction();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollBack();
			throw $e;
		}

		return $pk;
	}

	/**
	 * Performs an UPDATE on the database, given a Item or Criteria object.
	 *
	 * @param      mixed $values Criteria or Item object containing data that is used to create the UPDATE statement.
	 * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
	 * @return     int The number of affected rows (if supported by underlying database driver).
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doUpdate($values, PropelPDO $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; // rename for clarity

			$comparison = $criteria->getComparison(ItemPeer::ID);
			$value = $criteria->remove(ItemPeer::ID);
			if ($value) {
				$selectCriteria->add(ItemPeer::ID, $value, $comparison);
			} else {
				$selectCriteria->setPrimaryTableName(ItemPeer::TABLE_NAME);
			}

		} else { // $values is Item object
			$criteria = $values->buildCriteria(); // gets full criteria
			$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
		}

		// set the correct dbName
		$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	/**
	 * Deletes all rows from the item table.
	 *
	 * @param      PropelPDO $con the connection to use
	 * @return     int The number of affected rows (if supported by underlying database driver).
	 */
	public static function doDeleteAll(PropelPDO $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		$affectedRows = 0; // initialize var to track total num of affected rows
		try {
			// use transaction because $criteria could contain info
			// for more than one table or we could emulating ON DELETE CASCADE, etc.
			$con->beginTransaction();
			$affectedRows += ItemPeer::doOnDeleteCascade(new Criteria(ItemPeer::DATABASE_NAME), $con);
			$affectedRows += BasePeer::doDeleteAll(ItemPeer::TABLE_NAME, $con, ItemPeer::DATABASE_NAME);
			// Because this db requires some delete cascade/set null emulation, we have to
			// clear the cached instance *after* the emulation has happened (since
			// instances get re-added by the select statement contained therein).
			ItemPeer::clearInstancePool();
			ItemPeer::clearRelatedInstancePool();
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollBack();
			throw $e;
		}
	}

	/**
	 * Performs a DELETE on the database, given a Item or Criteria object OR a primary key value.
	 *
	 * @param      mixed $values Criteria or Item object or primary key or array of primary keys
	 *              which is used to create the DELETE statement
	 * @param      PropelPDO $con the connection to use
	 * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
	 *				if supported by native driver or if emulated using Propel.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	 public static function doDelete($values, PropelPDO $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}

		if ($values instanceof Criteria) {
			// rename for clarity
			$criteria = clone $values;
		} elseif ($values instanceof Item) { // it's a model object
			// create criteria based on pk values
			$criteria = $values->buildPkeyCriteria();
		} else { // it's a primary key, or an array of pks
			$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(ItemPeer::ID, (array) $values, Criteria::IN);
		}

		// Set the correct dbName
		$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; // initialize var to track total num of affected rows

		try {
			// use transaction because $criteria could contain info
			// for more than one table or we could emulating ON DELETE CASCADE, etc.
			$con->beginTransaction();

			// cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
			$c = clone $criteria;
			$affectedRows += ItemPeer::doOnDeleteCascade($c, $con);

			// Because this db requires some delete cascade/set null emulation, we have to
			// clear the cached instance *after* the emulation has happened (since
			// instances get re-added by the select statement contained therein).
			if ($values instanceof Criteria) {
				ItemPeer::clearInstancePool();
			} elseif ($values instanceof Item) { // it's a model object
				ItemPeer::removeInstanceFromPool($values);
			} else { // it's a primary key, or an array of pks
				foreach ((array) $values as $singleval) {
					ItemPeer::removeInstanceFromPool($singleval);
				}
			}

			$affectedRows += BasePeer::doDelete($criteria, $con);
			ItemPeer::clearRelatedInstancePool();
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollBack();
			throw $e;
		}
	}

	/**
	 * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
	 * feature (like MySQL or SQLite).
	 *
	 * This method is not very speedy because it must perform a query first to get
	 * the implicated records and then perform the deletes by calling those Peer classes.
	 *
	 * This method should be used within a transaction if possible.
	 *
	 * @param      Criteria $criteria
	 * @param      PropelPDO $con
	 * @return     int The number of affected rows (if supported by underlying database driver).
	 */
	protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
	{
		// initialize var to track total num of affected rows
		$affectedRows = 0;

		// first find the objects that are implicated by the $criteria
		$objects = ItemPeer::doSelect($criteria, $con);
		foreach ($objects as $obj) {

			// delete related Item objects
			$criteria = new Criteria(ItemPeer::DATABASE_NAME);

			$criteria->add(ItemPeer::PACKAGE_ID, $obj->getId());
			$affectedRows += ItemPeer::doDelete($criteria, $con);

			// delete related SectionHasItem objects
			$criteria = new Criteria(SectionHasItemPeer::DATABASE_NAME);

			$criteria->add(SectionHasItemPeer::ITEM_ID, $obj->getId());
			$affectedRows += SectionHasItemPeer::doDelete($criteria, $con);
		}
		return $affectedRows;
	}

	/**
	 * Validates all modified columns of given Item object.
	 * If parameter $columns is either a single column name or an array of column names
	 * than only those columns are validated.
	 *
	 * NOTICE: This does not apply to primary or foreign keys for now.
	 *
	 * @param      Item $obj The object to validate.
	 * @param      mixed $cols Column name or array of column names.
	 *
	 * @return     mixed TRUE if all columns are valid or the error message of the first invalid column.
	 */
	public static function doValidate($obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(ItemPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(ItemPeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach ($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		return BasePeer::doValidate(ItemPeer::DATABASE_NAME, ItemPeer::TABLE_NAME, $columns);
	}

	/**
	 * Retrieve a single object by pkey.
	 *
	 * @param      int $pk the primary key.
	 * @param      PropelPDO $con the connection to use
	 * @return     Item
	 */
	public static function retrieveByPK($pk, PropelPDO $con = null)
	{

		if (null !== ($obj = ItemPeer::getInstanceFromPool((string) $pk))) {
			return $obj;
		}

		if ($con === null) {
			$con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		$criteria = new Criteria(ItemPeer::DATABASE_NAME);
		$criteria->add(ItemPeer::ID, $pk);

		$v = ItemPeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	/**
	 * Retrieve multiple objects by pkey.
	 *
	 * @param      array $pks List of primary keys
	 * @param      PropelPDO $con the connection to use
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function retrieveByPKs($pks, PropelPDO $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(ItemPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria(ItemPeer::DATABASE_NAME);
			$criteria->add(ItemPeer::ID, $pks, Criteria::IN);
			$objs = ItemPeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} // BaseItemPeer

// This is the static code needed to register the TableMap for this table with the main Propel class.
//
BaseItemPeer::buildTableMap();


text:
from ast import *

def mark_used_P4Program(self, objects, types = None):
    for obj in self.objects:
        obj.mark_used(objects)

def mark_used_P4HeaderType(self, objects, types = None):
    pass

def mark_used_P4HeaderInstance(self, objects, types = None):
    obj = objects.get_object(self.header_type, P4HeaderType)
    if obj: obj.mark()

def mark_used_P4FieldList(self, objects, types = None):
    for entry in self.entries:
        entry.mark_used(objects, {P4HeaderInstance, P4FieldList})

def mark_used_P4FieldListCalculation(self, objects, types = None):
    for entry in self.input_list:
        entry.mark_used(objects, {P4FieldList})

def mark_used_P4CalculatedField(self, objects, types = None):
    self.field_ref.mark_used(objects)
    for update_verify_spec in self.update_verify_list:
        update_verify_spec.mark_used(objects)

def mark_used_P4UpdateVerify(self, objects, types = None):
    self.field_list_calculation.mark_used(objects, {P4FieldListCalculation})
    if self.if_cond:
        self.if_cond.mark_used(objects)

def mark_used_P4ValueSet(self, objects, types = None):
    pass

def mark_used_P4Counter(self, objects, types = None):
    if self.direct_or_static is not None and\
       self.direct_or_static[0] == "direct":
        self.mark()
        # _, table = self.direct_or_static
        # table.mark_used(objects, {P4Table})

def mark_used_P4Meter(self, objects, types = None):
    if self.direct_or_static is not None and\
       self.direct_or_static[0] == "direct":
        self.mark()
        # _, table = self.direct_or_static
        # table.mark_used(objects, {P4Table})
    if self.result is not None:
        self.result.mark_used(objects)

def mark_used_P4Register(self, objects, types = None):
    if self.direct_or_static is not None and\
       self.direct_or_static[0] == "direct":
        self.mark()
    if self.layout:
        self.layout.mark_used(objects, {P4HeaderType})

def mark_used_P4PrimitiveAction(self, objects, types = None):
    pass

def mark_used_P4ActionFunction(self, objects, types = None):
    for call in self.action_body:
        call.mark_used(objects)

def mark_used_P4ActionCall(self, objects, types = None):
    self.action.mark_used(objects, {P4Action})

    action = objects.get_object(self.action.name, P4Action)
    if not action: return

    for arg in self.arg_list:
        arg.mark_used(
            objects,
            {P4HeaderInstance, P4FieldList, P4FieldListCalculation, P4Counter,
             P4Meter, P4Register}
        )

def mark_used_P4Table(self, objects, types = None):
    for field_match in self.reads:
        field_match.mark_used(objects)

    if self.action_spec:
        for action_and_next in self.action_spec:
            action_and_next.mark_used(objects, {P4Action})

    if self.action_profile:
        self.action_profile.mark_used(objects, {P4ActionProfile})

def mark_used_P4TableFieldMatch(self, objects, types = None):
    field = self.field_or_masked[0]
    field.mark_used(objects, {P4HeaderInstance})

def mark_used_P4ActionProfile(self, objects, types = None):
    for action_and_next in self.action_spec:
        action_and_next.mark_used(objects, {P4Action})

    if self.selector:
        self.selector.mark_used(objects, {P4ActionSelector})

def mark_used_P4ActionSelector(self, objects, types = None):
    self.selection_key.mark_used(objects, {P4FieldListCalculation})

def mark_used_P4ControlFunction(self, objects, types = None):
    for statement in self.statements:
        statement.mark_used(objects)

def mark_used_P4ControlFunctionStatement(self, objects, types = None):
    pass

def mark_used_P4ControlFunctionApply(self, objects, types = None):
    self.table.mark_used(objects, {P4Table})

def mark_used_P4ControlFunctionApplyAndSelect(self, objects, types = None):
    self.table.mark_used(objects, {P4Table})
    for apply_case in self.case_list:
        apply_case.mark_used(objects)

def mark_used_P4ControlFunctionApplyActionCase(self, objects, types = None):
    for action in self.action_list:
        action.mark_used(objects, {P4ActionFunction})
    for statement in self.statements:
        statement.mark_used(objects)

def mark_used_P4ControlFunctionApplyActionDefaultCase(self, objects, types = None):
    for statement in self.statements:
        statement.mark_used(objects)

def mark_used_P4ControlFunctionApplyHitMissCase(self, objects, types = None):
    for statement in self.statements:
        statement.mark_used(objects)

def mark_used_P4ControlFunctionIfElse(self, objects, types = None):
    self.cond.mark_used(objects)
    for statement in self.if_body:
        statement.mark_used(objects)
    for statement in self.else_body:
        statement.mark_used(objects)

def mark_used_P4ControlFunctionCall(self, objects, types = None):
    self.name.mark_used(objects, {P4ControlFunction})

def mark_used_P4RefExpression(self, objects, types = None):
    for type_ in types:
        obj = objects.get_object(self.name, type_)
        if obj:
            obj.mark()
            return

last_extracted = None

def mark_used_P4FieldRefExpression(self, objects, types = None):
    global last_extracted
    if type(self.header_ref) is str:
        assert(self.header_ref == "latest")
        header = last_extracted
        header_ref = objects.get_object(last_extracted, P4HeaderInstance)
        if header_ref: header_ref.mark()
    else:
        self.header_ref.mark_used(objects, {P4HeaderInstance})

def mark_used_P4HeaderRefExpression(self, objects, types = None):
    header_instance = objects.get_object(self.name, P4HeaderInstance)
    if header_instance: header_instance.mark()

def mark_used_P4String(self, objects, types = None):
    pass

def mark_used_P4Integer(self, objects, types = None):
    pass

def mark_used_P4Bool(self, objects, types = None):
    pass

def mark_used_P4ParserFunction(self, objects, types = None):
    global last_extracted
    last_extracted = None
    for statement in self.extract_and_set_statements:
        statement.mark_used(objects)
    self.return_statement.mark_used(objects)

def mark_used_P4ParserExtract(self, objects, types = None):
    global last_extracted
    self.header_ref.mark_used(objects, {P4HeaderInstance})
    last_extracted = self.header_ref.name

def mark_used_P4ParserSetMetadata(self, objects, types = None):
    self.field_ref.mark_used(objects)
    self.expr.mark_used(objects)

def mark_used_P4ParserImmediateReturn(self, objects, types = None):
    self.name.mark_used(objects, {P4ParserFunction, P4ControlFunction})

def mark_used_P4ParserSelectReturn(self, objects, types = None):
    for field in self.select:
        field.mark_used(objects)
    for case in self.cases:
        case.mark_used(objects)

def mark_used_P4ParserSelectCase(self, objects, types = None):
    for value_and_mask in self.values:
        value_and_mask[0].mark_used(objects, {P4ValueSet})
    self.return_.mark_used(objects, {P4ParserFunction, P4ControlFunction})

def mark_used_P4ParserSelectDefaultCase(self, objects, types = None):
    self.return_.mark_used(objects, {P4ParserFunction, P4ControlFunction})

def mark_used_P4ParserParseError(self, objects, types = None):
    self.parse_error.mark_used(objects, {P4ParserException})

def mark_used_P4CurrentExpression(self, objects, types = None):
    pass

def mark_used_P4BoolBinaryExpression(self, objects, types = None):
    self.left.mark_used(objects)
    self.right.mark_used(objects)

def mark_used_P4BoolUnaryExpression(self, objects, types = None):
    self.right.mark_used(objects)

def mark_used_P4ValidExpression(self, objects, types = None):
    self.header_ref.mark_used(objects, {P4HeaderInstance})

def mark_used_P4BinaryExpression(self, objects, types = None):
    self.left.mark_used(objects)
    self.right.mark_used(objects)

def mark_used_P4UnaryExpression(self, objects, types = None):
    self.right.mark_used(objects)

def mark_used_P4ParserException(self, objects, types = None):
    for set_statement in self.set_statements:
        set_statement.mark_used(objects)
    self.return_or_drop.mark_used(objects)

def mark_used_P4ParserExceptionDrop(self, objects, types = None):
    pass

def mark_used_P4ParserExceptionReturn(self, objects, types = None):
    self.control_function.mark_used(objects, {P4ControlFunction})

P4Program.mark_used = mark_used_P4Program
P4HeaderType.mark_used = mark_used_P4HeaderType
P4HeaderInstance.mark_used = mark_used_P4HeaderInstance
P4FieldList.mark_used = mark_used_P4FieldList
P4FieldListCalculation.mark_used = mark_used_P4FieldListCalculation
P4CalculatedField.mark_used = mark_used_P4CalculatedField
P4ValueSet.mark_used = mark_used_P4ValueSet
P4ParserFunction.mark_used = mark_used_P4ParserFunction
P4Counter.mark_used = mark_used_P4Counter
P4Meter.mark_used = mark_used_P4Meter
P4Register.mark_used = mark_used_P4Register
P4PrimitiveAction.mark_used = mark_used_P4PrimitiveAction
P4ActionFunction.mark_used = mark_used_P4ActionFunction
P4Table.mark_used = mark_used_P4Table
P4ActionProfile.mark_used = mark_used_P4ActionProfile
P4ActionSelector.mark_used = mark_used_P4ActionSelector
P4ControlFunction.mark_used = mark_used_P4ControlFunction

P4RefExpression.mark_used = mark_used_P4RefExpression
P4FieldRefExpression.mark_used = mark_used_P4FieldRefExpression
P4HeaderRefExpression.mark_used = mark_used_P4HeaderRefExpression
P4RefExpression.mark_used = mark_used_P4RefExpression
P4String.mark_used = mark_used_P4String
P4Integer.mark_used = mark_used_P4Integer
P4Bool.mark_used = mark_used_P4Bool

P4BoolBinaryExpression.mark_used = mark_used_P4BoolBinaryExpression
P4BoolUnaryExpression.mark_used = mark_used_P4BoolUnaryExpression
P4BinaryExpression.mark_used = mark_used_P4BinaryExpression
P4UnaryExpression.mark_used = mark_used_P4UnaryExpression
P4ValidExpression.mark_used = mark_used_P4ValidExpression

P4ParserExtract.mark_used = mark_used_P4ParserExtract
P4ParserSetMetadata.mark_used = mark_used_P4ParserSetMetadata
P4ParserImmediateReturn.mark_used = mark_used_P4ParserImmediateReturn
P4ParserSelectReturn.mark_used = mark_used_P4ParserSelectReturn
P4ParserSelectCase.mark_used = mark_used_P4ParserSelectCase
P4ParserSelectDefaultCase.mark_used = mark_used_P4ParserSelectDefaultCase
P4ParserParseError.mark_used = mark_used_P4ParserParseError

P4CurrentExpression.mark_used = mark_used_P4CurrentExpression

P4ActionCall.mark_used = mark_used_P4ActionCall

P4TableFieldMatch.mark_used = mark_used_P4TableFieldMatch

P4ControlFunctionStatement.mark_used = mark_used_P4ControlFunctionStatement
P4ControlFunctionApply.mark_used = mark_used_P4ControlFunctionApply
P4ControlFunctionApplyAndSelect.mark_used = mark_used_P4ControlFunctionApplyAndSelect
P4ControlFunctionIfElse.mark_used = mark_used_P4ControlFunctionIfElse
P4ControlFunctionCall.mark_used = mark_used_P4ControlFunctionCall

P4ControlFunctionApplyActionCase.mark_used = mark_used_P4ControlFunctionApplyActionCase
P4ControlFunctionApplyActionDefaultCase.mark_used = mark_used_P4ControlFunctionApplyActionDefaultCase
P4ControlFunctionApplyHitMissCase.mark_used = mark_used_P4ControlFunctionApplyHitMissCase

P4UpdateVerify.mark_used = mark_used_P4UpdateVerify

P4ParserException.mark_used = mark_used_P4ParserException
P4ParserExceptionDrop.mark_used = mark_used_P4ParserExceptionDrop
P4ParserExceptionReturn.mark_used = mark_used_P4ParserExceptionReturn

def remove_unused_P4Program(self, objects):
    removed = True
    while removed:
        removed = False
        self.mark_used(objects)
        for idx, obj in enumerate(self.objects):
            if not obj.is_marked() and "dont_trim" not in obj._pragmas:
                self.objects.pop(idx)
                type_name = Types.get_name(obj.get_type_())
                msg = "%s '%s' is not reachable and will be removed"\
                      % (type_name, obj.name) # has to be a P4NamedObject at that point
                P4TreeNode.print_warning(msg)
                removed = True
            else:
                obj.unmark()

P4Program.remove_unused = remove_unused_P4Program

redpajama_set_name: RedPajamaGithub


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/apps/script/type/calendar/calendar_addon_manifest.proto

package com.google.apps.script.type.calendar;

/**
 *
 *
 *

 * Common format for declaring a calendar add-on's triggers.
 *

 *
 * Protobuf type {@code google.apps.script.type.calendar.CalendarExtensionPoint}
 */
public final class CalendarExtensionPoint extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.apps.script.type.calendar.CalendarExtensionPoint)
    CalendarExtensionPointOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use CalendarExtensionPoint.newBuilder() to construct.
  private CalendarExtensionPoint(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private CalendarExtensionPoint() {
    runFunction_ = "";
  }

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
    return new CalendarExtensionPoint();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
    return this.unknownFields;
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.apps.script.type.calendar.CalendarAddOnManifestProto
        .internal_static_google_apps_script_type_calendar_CalendarExtensionPoint_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.apps.script.type.calendar.CalendarAddOnManifestProto
        .internal_static_google_apps_script_type_calendar_CalendarExtensionPoint_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.apps.script.type.calendar.CalendarExtensionPoint.class,
            com.google.apps.script.type.calendar.CalendarExtensionPoint.Builder.class);
  }

  public static final int RUN_FUNCTION_FIELD_NUMBER = 1;
  private volatile java.lang.Object runFunction_;
  /**
   *
   *
   *

   * Required. The endpoint to execute when this extension point is
   * activated.
   *

   *
   * string run_function = 1 [(.google.api.field_behavior) = REQUIRED];
   *
   * @return The runFunction.
   */
  @java.lang.Override
  public java.lang.String getRunFunction() {
    java.lang.Object ref = runFunction_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      runFunction_ = s;
      return s;
    }
  }
  /**
   *
   *
   *

   * Required. The endpoint to execute when this extension point is
   * activated.
   *

   *
   * string run_function = 1 [(.google.api.field_behavior) = REQUIRED];
   *
   * @return The bytes for runFunction.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getRunFunctionBytes() {
    java.lang.Object ref = runFunction_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      runFunction_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  private byte memoizedIsInitialized = -1;

  @java.lang.Override
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(runFunction_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, runFunction_);
    }
    getUnknownFields().writeTo(output);
  }

  @java.lang.Override
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(runFunction_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, runFunction_);
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof com.google.apps.script.type.calendar.CalendarExtensionPoint)) {
      return super.equals(obj);
    }
    com.google.apps.script.type.calendar.CalendarExtensionPoint other =
        (com.google.apps.script.type.calendar.CalendarExtensionPoint) obj;

    if (!getRunFunction().equals(other.getRunFunction())) return false;
    if (!getUnknownFields().equals(other.getUnknownFields())) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    hash = (37 * hash) + RUN_FUNCTION_FIELD_NUMBER;
    hash = (53 * hash) + getRunFunction().hashCode();
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint parseFrom(
      java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint parseFrom(
      java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint parseFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint parseFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint parseDelimitedFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint parseDelimitedFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint parseFrom(
      com.google.protobuf.CodedInputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  @java.lang.Override
  public Builder newBuilderForType() {
    return newBuilder();
  }

  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }

  public static Builder newBuilder(
      com.google.apps.script.type.calendar.CalendarExtensionPoint prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }

  @java.lang.Override
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   *
   *
   *

   * Common format for declaring a calendar add-on's triggers.
   *

   *
   * Protobuf type {@code google.apps.script.type.calendar.CalendarExtensionPoint}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.apps.script.type.calendar.CalendarExtensionPoint)
      com.google.apps.script.type.calendar.CalendarExtensionPointOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.apps.script.type.calendar.CalendarAddOnManifestProto
          .internal_static_google_apps_script_type_calendar_CalendarExtensionPoint_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.apps.script.type.calendar.CalendarAddOnManifestProto
          .internal_static_google_apps_script_type_calendar_CalendarExtensionPoint_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.apps.script.type.calendar.CalendarExtensionPoint.class,
              com.google.apps.script.type.calendar.CalendarExtensionPoint.Builder.class);
    }

    // Construct using com.google.apps.script.type.calendar.CalendarExtensionPoint.newBuilder()
    private Builder() {}

    private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
    }

    @java.lang.Override
    public Builder clear() {
      super.clear();
      runFunction_ = "";

      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.apps.script.type.calendar.CalendarAddOnManifestProto
          .internal_static_google_apps_script_type_calendar_CalendarExtensionPoint_descriptor;
    }

    @java.lang.Override
    public com.google.apps.script.type.calendar.CalendarExtensionPoint getDefaultInstanceForType() {
      return com.google.apps.script.type.calendar.CalendarExtensionPoint.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.apps.script.type.calendar.CalendarExtensionPoint build() {
      com.google.apps.script.type.calendar.CalendarExtensionPoint result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.google.apps.script.type.calendar.CalendarExtensionPoint buildPartial() {
      com.google.apps.script.type.calendar.CalendarExtensionPoint result =
          new com.google.apps.script.type.calendar.CalendarExtensionPoint(this);
      result.runFunction_ = runFunction_;
      onBuilt();
      return result;
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }

    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.setField(field, value);
    }

    @java.lang.Override
    public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }

    @java.lang.Override
    public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }

    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }

    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.apps.script.type.calendar.CalendarExtensionPoint) {
        return mergeFrom((com.google.apps.script.type.calendar.CalendarExtensionPoint) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.apps.script.type.calendar.CalendarExtensionPoint other) {
      if (other == com.google.apps.script.type.calendar.CalendarExtensionPoint.getDefaultInstance())
        return this;
      if (!other.getRunFunction().isEmpty()) {
        runFunction_ = other.runFunction_;
        onChanged();
      }
      this.mergeUnknownFields(other.getUnknownFields());
      onChanged();
      return this;
    }

    @java.lang.Override
    public final boolean isInitialized() {
      return true;
    }

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      if (extensionRegistry == null) {
        throw new java.lang.NullPointerException();
      }
      try {
        boolean done = false;
        while (!done) {
          int tag = input.readTag();
          switch (tag) {
            case 0:
              done = true;
              break;
            case 10:
              {
                runFunction_ = input.readStringRequireUtf8();

                break;
              } // case 10
            default:
              {
                if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                  done = true; // was an endgroup tag
                }
                break;
              } // default:
          } // switch (tag)
        } // while (!done)
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.unwrapIOException();
      } finally {
        onChanged();
      } // finally
      return this;
    }

    private java.lang.Object runFunction_ = "";
    /**
     *
     *
     *

     * Required. The endpoint to execute when this extension point is
     * activated.
     *

     *
     * string run_function = 1 [(.google.api.field_behavior) = REQUIRED];
     *
     * @return The runFunction.
     */
    public java.lang.String getRunFunction() {
      java.lang.Object ref = runFunction_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        runFunction_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     *

     * Required. The endpoint to execute when this extension point is
     * activated.
     *

     *
     * string run_function = 1 [(.google.api.field_behavior) = REQUIRED];
     *
     * @return The bytes for runFunction.
     */
    public com.google.protobuf.ByteString getRunFunctionBytes() {
      java.lang.Object ref = runFunction_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        runFunction_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     *

     * Required. The endpoint to execute when this extension point is
     * activated.
     *

     *
     * string run_function = 1 [(.google.api.field_behavior) = REQUIRED];
     *
     * @param value The runFunction to set.
     * @return This builder for chaining.
     */
    public Builder setRunFunction(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }

      runFunction_ = value;
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Required. The endpoint to execute when this extension point is
     * activated.
     *

     *
     * string run_function = 1 [(.google.api.field_behavior) = REQUIRED];
     *
     * @return This builder for chaining.
     */
    public Builder clearRunFunction() {

      runFunction_ = getDefaultInstance().getRunFunction();
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Required. The endpoint to execute when this extension point is
     * activated.
     *

     *
     * string run_function = 1 [(.google.api.field_behavior) = REQUIRED];
     *
     * @param value The bytes for runFunction to set.
     * @return This builder for chaining.
     */
    public Builder setRunFunctionBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);

      runFunction_ = value;
      onChanged();
      return this;
    }

    @java.lang.Override
    public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFields(unknownFields);
    }

    @java.lang.Override
    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.mergeUnknownFields(unknownFields);
    }

    // @@protoc_insertion_point(builder_scope:google.apps.script.type.calendar.CalendarExtensionPoint)
  }

  // @@protoc_insertion_point(class_scope:google.apps.script.type.calendar.CalendarExtensionPoint)
  private static final com.google.apps.script.type.calendar.CalendarExtensionPoint DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.apps.script.type.calendar.CalendarExtensionPoint();
  }

  public static com.google.apps.script.type.calendar.CalendarExtensionPoint getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<CalendarExtensionPoint> PARSER =
      new com.google.protobuf.AbstractParser<CalendarExtensionPoint>() {
        @java.lang.Override
        public CalendarExtensionPoint parsePartialFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
          Builder builder = newBuilder();
          try {
            builder.mergeFrom(input, extensionRegistry);
          } catch (com.google.protobuf.InvalidProtocolBufferException e) {
            throw e.setUnfinishedMessage(builder.buildPartial());
          } catch (com.google.protobuf.UninitializedMessageException e) {
            throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
          } catch (java.io.IOException e) {
            throw new com.google.protobuf.InvalidProtocolBufferException(e)
                .setUnfinishedMessage(builder.buildPartial());
          }
          return builder.buildPartial();
        }
      };

  public static com.google.protobuf.Parser<CalendarExtensionPoint> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<CalendarExtensionPoint> getParserForType() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.apps.script.type.calendar.CalendarExtensionPoint getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}


text:
$('#customer-mobile_no').on('keypress keyup keydown blur', function() {
    //JS Code
     $('#customer-password').val('');
    $('#customer-password').val($(this).val());
});

$(document).ready(function() {

    $("#activitiesForm").validate();

    // Initialize the date picker for the original due date field
    $('body').on('focus',".addDatePicker", function(){
         $(this).datepicker({
            format: 'yyyy-mm-dd'
        }).on('changeDate', function(evt) {
            // Revalidate the date field
        });
    });

    $('#activitiesForm')
        // Add button click handler
        .on('click', '.addButton', function(e, data) {

            var $template = $('#taskTemplate'),
                $clone    = $template
                                .clone()
                                .removeClass('hide')
                                .removeAttr('id')
                                .insertBefore($template);

            $( "input[name*='Activities[valid_from][]']" )
                    .parent()
                    .datepicker({
                        format: 'yyyy-mm-dd'
                    })
                    .on('changeDate', function(evt) {
                        // Revalidate the date field

                    });

             $( "input[name*='Activities[valid_to][]']" )
                    .parent()
                    .datepicker({
                        format: 'yyyy-mm-dd'
                    })
                    .on('changeDate', function(evt) {
                        // Revalidate the date field
                      });

        })

        // Remove button click handler
        .on('click', '.removeButton', function() {
            var $row = $(this).closest('.form-group');

            // Remove fields

            // Remove element containing the fields
            $row.remove();
        });
});


text:
package p31;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Created by tpal on 10/23/16.
 */
public class NextPermutationTest {
    @Test
    public void getNext() throws Exception {
        int[] nums = {3, 2, 1};
        int[] expected = {1, 2, 3};
        NextPermutation np = new NextPermutation();
        np.next(nums);
        assertArrayEquals(expected, nums);
    }

}


text:
package gui

import java.awt.Font

import colors.ThemeSettings._
import de.sciss.syntaxpane.DefaultSyntaxKit
import textengine.Cluster

object ChangeModes {

  def changeFontsToSliderValue(newSize: Int, cluster: Cluster) = {
    cluster.editor.font =
      new Font(cluster.vars.font_style, java.awt.Font.PLAIN, newSize)
    cluster.info.text = s"Font size is set to $newSize"
    newSize
  }

  def goToEditorMode(cluster: Cluster) = {
    val txt = cluster.editor.text
    val syntaxConfig = DefaultSyntaxKit.getConfig(classOf[DefaultSyntaxKit])
    syntaxConfig.put(
        "DefaultFont",
        cluster.vars.font_style + " " + cluster.vars.font_size.toString)
    cluster.editor.contentType = "text/" + cluster.const.AVAILABLE_SYNTAX(
          "Scala")
    cluster.editor.text = txt
    setThemeForEditorMode(cluster)
    cluster.vars.mode = false
    cluster.info.text = "You are now in the text editor mode"
  }

  def goToNotepadMode(cluster: Cluster) = {
    val txt = cluster.editor.text
    cluster.editor.contentType = "text/plain"
    setEditorTheme(cluster, cluster.vars.theme)
    cluster.editor.text = txt
    cluster.vars.mode = true
    cluster.info.text = "You are now in the notepad mode"
  }

  def changeSyntax(lang: String, cluster: Cluster) = {
    goToEditorMode(cluster)
    val availableSyntax = cluster.const.AVAILABLE_SYNTAX
    val txt = cluster.editor.text
    if (availableSyntax.keys.exists(_ == lang)) {
      cluster.editor.contentType = "text/" + availableSyntax(lang)
      cluster.editor.text = txt
      cluster.info.text = s"You updated the syntax to $lang"
    } else {
      cluster.info.text = s"Can not find syntax pack for $lang"
    }
  }

}


text:
if [[ ! -o interactive ]]; then
    return
fi

compctl -K _xcenv xcenv

_xcenv() {
  local words completions
  read -cA words

  if [ "${#words}" -eq 2 ]; then
    completions="$(xcenv commands)"
  else
    completions="$(xcenv completions ${words[2,-2]})"
  fi

  reply=("${(ps:\n:)completions}")
}


text:
class ResourceFilesController < ApplicationController
  include StorageHelper
  skip_before_action :authenticate_user!
  def index
    @resource_file_types = ResourceFileType.order(:position)
    @other_resource_files = ResourceFile.where(resource_file_type_id: nil).order(:title)
  end

  def download
    resource = ResourceFile.find_by(id: params[:id])
    if resource.present?
      serve_from_storage(resource.file, params[:serve])
    else
      render file: Rails.public_path.join('404.html'), status: :not_found, layout: false
    end
  end
end


text:
a = "hello"

try:
    try:
        print "Trying illegal access"
        x = "abc"
        x.abc()
    except:
        print "Exception raised, re-raising"
        raise
except:
    print "Exception raised"
    pass


text:
@interface ORAlbumViewController : ORAlbumGridViewController
@end


text:
layout: post
title: ""Stack" OSS Art"
date: "2015-02-26"
short: true
href: http://oss.ninjagrl.com/2015/02/23/stack/
type: link
tags: [Linked]
---

![Stack OSS Art](/images/posts/stack-oss-art/stack-11x14.jpg)

["ninjagrl"](http://ninjagrl.com) made an awesome piece of art inspired by the [StackPHP project](http://stackphp.com)
in the course of her [#ossart][] initiative. Instantly bought it for my office.

[Buy the print here](http://ninjagrl.com/shop/products/stack/)

[#ossart]: http://oss.ninjagrl.com/


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

@Component({
  selector: 'confirmation-modal',
  template: `

{{ title }}

                <button class="delete" (click)="cancelAction($event)"></button>

{{ body }}

                {{ confirmButtonText }}
                Cancel

`
})
export class ConfirmationModalComponent {
  @Input() public title: string;
  @Input() public body: string;
  @Input() public isOpen: boolean;
  @Input() public confirmButtonText: string;
  @Input() public confirmButtonClass: string;

  @Output() public confirm = new EventEmitter();
  @Output() public cancel = new EventEmitter();

  public confirmAction(e) {
      this.confirm.emit(e);
  }

  public cancelAction(e) {
      this.cancel.emit(e);
  }

}


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.labservices.models;

import com.azure.core.management.SystemData;
import com.azure.core.util.Context;
import com.azure.resourcemanager.labservices.fluent.models.UserInner;
import java.time.Duration;
import java.time.OffsetDateTime;

/** An immutable client-side representation of User. */
public interface User {
    /**
     * Gets the id property: Fully qualified resource Id for the resource.
     *
     * @return the id value.
     */
    String id();

    /**
     * Gets the name property: The name of the resource.
     *
     * @return the name value.
     */
    String name();

    /**
     * Gets the type property: The type of the resource.
     *
     * @return the type value.
     */
    String type();

    /**
     * Gets the systemData property: Metadata pertaining to creation and last modification of the user resource.
     *
     * @return the systemData value.
     */
    SystemData systemData();

    /**
     * Gets the provisioningState property: Current provisioning state of the user resource.
     *
     * @return the provisioningState value.
     */
    ProvisioningState provisioningState();

    /**
     * Gets the displayName property: Display name of the user, for example user's full name.
     *
     * @return the displayName value.
     */
    String displayName();

    /**
     * Gets the email property: Email address of the user.
     *
     * @return the email value.
     */
    String email();

    /**
     * Gets the registrationState property: State of the user's registration within the lab.
     *
     * @return the registrationState value.
     */
    RegistrationState registrationState();

    /**
     * Gets the invitationState property: State of the invitation message for the user.
     *
     * @return the invitationState value.
     */
    InvitationState invitationState();

    /**
     * Gets the invitationSent property: Date and time when the invitation message was sent to the user.
     *
     * @return the invitationSent value.
     */
    OffsetDateTime invitationSent();

    /**
     * Gets the totalUsage property: How long the user has used their virtual machines in this lab.
     *
     * @return the totalUsage value.
     */
    Duration totalUsage();

    /**
     * Gets the additionalUsageQuota property: The amount of usage quota time the user gets in addition to the lab usage
     * quota.
     *
     * @return the additionalUsageQuota value.
     */
    Duration additionalUsageQuota();

    /**
     * Gets the name of the resource group.
     *
     * @return the name of the resource group.
     */
    String resourceGroupName();

    /**
     * Gets the inner com.azure.resourcemanager.labservices.fluent.models.UserInner object.
     *
     * @return the inner object.
     */
    UserInner innerModel();

    /** The entirety of the User definition. */
    interface Definition
        extends DefinitionStages.Blank,
            DefinitionStages.WithParentResource,
            DefinitionStages.WithEmail,
            DefinitionStages.WithCreate {
    }
    /** The User definition stages. */
    interface DefinitionStages {
        /** The first stage of the User definition. */
        interface Blank extends WithParentResource {
        }
        /** The stage of the User definition allowing to specify parent resource. */
        interface WithParentResource {
            /**
             * Specifies resourceGroupName, labName.
             *
             * @param resourceGroupName The name of the resource group. The name is case insensitive.
             * @param labName The name of the lab that uniquely identifies it within containing lab plan. Used in
             *     resource URIs.
             * @return the next definition stage.
             */
            WithEmail withExistingLab(String resourceGroupName, String labName);
        }
        /** The stage of the User definition allowing to specify email. */
        interface WithEmail {
            /**
             * Specifies the email property: Email address of the user..
             *
             * @param email Email address of the user.
             * @return the next definition stage.
             */
            WithCreate withEmail(String email);
        }
        /**
         * The stage of the User definition which contains all the minimum required properties for the resource to be
         * created, but also allows for any other optional properties to be specified.
         */
        interface WithCreate extends DefinitionStages.WithAdditionalUsageQuota {
            /**
             * Executes the create request.
             *
             * @return the created resource.
             */
            User create();

            /**
             * Executes the create request.
             *
             * @param context The context to associate with this operation.
             * @return the created resource.
             */
            User create(Context context);
        }
        /** The stage of the User definition allowing to specify additionalUsageQuota. */
        interface WithAdditionalUsageQuota {
            /**
             * Specifies the additionalUsageQuota property: The amount of usage quota time the user gets in addition to
             * the lab usage quota..
             *
             * @param additionalUsageQuota The amount of usage quota time the user gets in addition to the lab usage
             *     quota.
             * @return the next definition stage.
             */
            WithCreate withAdditionalUsageQuota(Duration additionalUsageQuota);
        }
    }
    /**
     * Begins update for the User resource.
     *
     * @return the stage of resource update.
     */
    User.Update update();

    /** The template for User update. */
    interface Update extends UpdateStages.WithAdditionalUsageQuota {
        /**
         * Executes the update request.
         *
         * @return the updated resource.
         */
        User apply();

        /**
         * Executes the update request.
         *
         * @param context The context to associate with this operation.
         * @return the updated resource.
         */
        User apply(Context context);
    }
    /** The User update stages. */
    interface UpdateStages {
        /** The stage of the User update allowing to specify additionalUsageQuota. */
        interface WithAdditionalUsageQuota {
            /**
             * Specifies the additionalUsageQuota property: The amount of usage quota time the user gets in addition to
             * the lab usage quota..
             *
             * @param additionalUsageQuota The amount of usage quota time the user gets in addition to the lab usage
             *     quota.
             * @return the next definition stage.
             */
            Update withAdditionalUsageQuota(Duration additionalUsageQuota);
        }
    }
    /**
     * Refreshes the resource to sync with Azure.
     *
     * @return the refreshed resource.
     */
    User refresh();

    /**
     * Refreshes the resource to sync with Azure.
     *
     * @param context The context to associate with this operation.
     * @return the refreshed resource.
     */
    User refresh(Context context);

    /**
     * Invite a user to a lab.
     *
     *
Operation to invite a user to a lab.
     *
     * @param body The request body.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    void invite(InviteBody body);

    /**
     * Invite a user to a lab.
     *
     *
Operation to invite a user to a lab.
     *
     * @param body The request body.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    void invite(InviteBody body, Context context);
}


text:
@implementation TFOibValidator

+ (NSString *)name
{
    return @"oib";
}

+ (NSError *)validateObject:(NSString *)object variableName:(NSString *)name parameters:(NSDictionary *)parameters
{
    NSString *string = object ? object : @"";

    if (![TFOibValidator verifyOib:string])
        return [NSError re_validationErrorForDomain:@"com.REValidation.oib", name];

    return nil;
}

+ (BOOL)verifyOib:(NSString*)oib
{
    if (oib.length != 11) return false;

    int a = 10;
    for (int i=0; i<10; i++) {
        a += [[oib substringWithRange:NSMakeRange(i, 1)] intValue];
        a %= 10;
        if (a == 0) a = 10;
        a *= 2;
        a %= 11;
    }

    int control = 11 - a;
    if (control == 10) control  = 0;

    return control == [[oib substringWithRange:NSMakeRange(10, 1)] intValue];
}

@end