text:
<?php

/**
 * Doctrine_Expression_Driver
 *
 * @package     Doctrine
 * @subpackage  Expression
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
 * @link        www.doctrine-project.org
 * @since       1.0
 * @version     $Revision$
 * @author      Konsta Vesterinen <kvesteri@cc.hut.fi>
 */
class Doctrine_Expression_Driver extends Doctrine_Connection_Module
{
    public function getIdentifier($column)
    {
        return $column;
    }

    public function getIdentifiers($columns)
    {
        return $columns;
    }

    /**
     * regexp
     * returns the regular expression operator
     *
     * @return string
     */
    public function regexp()
    {
        throw new Doctrine_Expression_Exception('Regular expression operator is not supported by this database driver.');
    }

    /**
     * Returns the average value of a column
     *
     * @param string $column    the column to use
     * @return string           generated sql including an AVG aggregate function
     */
    public function avg($column)
    {
        $column = $this->getIdentifier($column);
        return 'AVG(' .  $column . ')';
    }

    /**
     * Returns the number of rows (without a NULL value) of a column
     *
     * If a '*' is used instead of a column the number of selected rows
     * is returned.
     *
     * @param string|integer $column    the column to use
     * @return string                   generated sql including a COUNT aggregate function
     */
    public function count($column)
    {
        $column = $this->getIdentifier($column);
        return 'COUNT(' . $column . ')';
    }

    /**
     * Returns the highest value of a column
     *
     * @param string $column    the column to use
     * @return string           generated sql including a MAX aggregate function
     */
    public function max($column)
    {
        $column = $this->getIdentifier($column);
        return 'MAX(' . $column . ')';
    }

    /**
     * Returns the lowest value of a column
     *
     * @param string $column the column to use
     * @return string
     */
    public function min($column)
    {
        $column = $this->getIdentifier($column);
        return 'MIN(' . $column . ')';
    }

    /**
     * Returns the total sum of a column
     *
     * @param string $column the column to use
     * @return string
     */
    public function sum($column)
    {
        $column = $this->getIdentifier($column);
        return 'SUM(' . $column . ')';
    }

    // scalar functions

    /**
     * Returns the md5 sum of a field.
     *
     * Note: Not SQL92, but common functionality
     *
     * @return string
     */
    public function md5($column)
    {
        $column = $this->getIdentifier($column);
        return 'MD5(' . $column . ')';
    }

    /**
     * Returns the length of a text field.
     *
     * @param string $expression1
     * @param string $expression2
     * @return string
     */
    public function length($column)
    {
        $column = $this->getIdentifier($column);
        return 'LENGTH(' . $column . ')';
    }

    /**
     * Rounds a numeric field to the number of decimals specified.
     *
     * @param string $expression1
     * @param string $expression2
     * @return string
     */
    public function round($column, $decimals = 0)
    {
        $column = $this->getIdentifier($column);

        return 'ROUND(' . $column . ', ' . $decimals . ')';
    }

    /**
     * Returns the remainder of the division operation
     * $expression1 / $expression2.
     *
     * @param string $expression1
     * @param string $expression2
     * @return string
     */
    public function mod($expression1, $expression2)
    {
        $expression1 = $this->getIdentifier($expression1);
        $expression2 = $this->getIdentifier($expression2);
        return 'MOD(' . $expression1 . ', ' . $expression2 . ')';
    }

    /**
     * trim
     * returns the string $str with leading and proceeding space characters removed
     *
     * @param string $str       literal string or column name
     * @return string
     */
    public function trim($str)
    {
        return 'TRIM(' . $str . ')';
    }

    /**
     * rtrim
     * returns the string $str with proceeding space characters removed
     *
     * @param string $str       literal string or column name
     * @return string
     */
    public function rtrim($str)
    {
        return 'RTRIM(' . $str . ')';
    }

    /**
     * ltrim
     * returns the string $str with leading space characters removed
     *
     * @param string $str       literal string or column name
     * @return string
     */
    public function ltrim($str)
    {
        return 'LTRIM(' . $str . ')';
    }

    /**
     * upper
     * Returns the string $str with all characters changed to
     * uppercase according to the current character set mapping.
     *
     * @param string $str       literal string or column name
     * @return string
     */
    public function upper($str)
    {
        return 'UPPER(' . $str . ')';
    }

    /**
     * lower
     * Returns the string $str with all characters changed to
     * lowercase according to the current character set mapping.
     *
     * @param string $str       literal string or column name
     * @return string
     */
    public function lower($str)
    {
        return 'LOWER(' . $str . ')';
    }

    /**
     * locate
     * returns the position of the first occurrence of substring $substr in string $str
     *
     * @param string $substr    literal string to find
     * @param string $str       literal string
     * @return integer
     */
    public function locate($str, $substr)
    {
        return 'LOCATE(' . $str . ', ' . $substr . ')';
    }

    /**
     * Returns the current system date.
     *
     * @return string
     */
    public function now()
    {
        return 'NOW()';
    }

    /**
     * soundex
     * Returns a string to call a function to compute the
     * soundex encoding of a string
     *
     * The string "?000" is returned if the argument is NULL.
     *
     * @param string $value
     * @return string   SQL soundex function with given parameter
     */
    public function soundex($value)
    {
        throw new Doctrine_Expression_Exception('SQL soundex function not supported by this driver.');
    }

    /**
     * return string to call a function to get a substring inside an SQL statement
     *
     * Note: Not SQL92, but common functionality.
     *
     * SQLite only supports the 2 parameter variant of this function
     *
     * @param string $value         an sql string literal or column name/alias
     * @param integer $position     where to start the substring portion
     * @param integer $length       the substring portion length
     * @return string               SQL substring function with given parameters
     */
    public function substring($value, $from, $len = null)
    {
        $value = $this->getIdentifier($value);
        if ($len === null)
            return 'SUBSTRING(' . $value . ' FROM ' . $from . ')';
        else {
            $len = $this->getIdentifier($len);
            return 'SUBSTRING(' . $value . ' FROM ' . $from . ' FOR ' . $len . ')';
        }
    }

    /**
     * Returns a series of strings concatinated
     *
     * concat() accepts an arbitrary number of parameters. Each parameter
     * must contain an expression or an array with expressions.
     *
     * @param string|array(string) strings that will be concatinated.
     */
    public function concat()
    {
        $args = func_get_args();

        return 'CONCAT(' . join(', ', (array) $args) . ')';
    }

    /**
     * Returns the SQL for a logical not.
     *
     * @return string a logical expression
     */
    public function not($expression)
    {
        $expression = $this->getIdentifier($expression);
        return 'NOT(' . $expression . ')';
    }

    /**
     * Returns the SQL to perform the same mathematical operation over an array
     * of values or expressions.
     *
     * basicMath() accepts an arbitrary number of parameters. Each parameter
     * must contain a value or an expression or an array with values or
     * expressions.
     *
     * @param string $type the type of operation, can be '+', '-', '*' or '/'.
     * @param string|array(string)
     * @return string an expression
     */
    private function basicMath($type, array $args)
    {
        $elements = $this->getIdentifiers($args);
        if (count($elements) < 1) {
            return '';
        }
        if (count($elements) == 1) {
            return $elements[0];
        } else {
            return '(' . implode(' ' . $type . ' ', $elements) . ')';
        }
    }

    /**
     * Returns the SQL to add values or expressions together.
     *
     * add() accepts an arbitrary number of parameters. Each parameter
     * must contain a value or an expression or an array with values or
     * expressions.
     *
     * @param string|array(string)
     * @return string an expression
     */
    public function add(array $args)
    {
        return $this->basicMath('+', $args);
    }

    /**
     * Returns the SQL to subtract values or expressions from eachother.
     *
     * subtract() accepts an arbitrary number of parameters. Each parameter
     * must contain a value or an expression or an array with values or
     * expressions.
     *
     * @param string|array(string)
     * @return string an expression
     */
    public function sub(array $args)
    {
        return $this->basicMath('-', $args );
    }

    /**
     * Returns the SQL to multiply values or expressions by eachother.
     *
     * multiply() accepts an arbitrary number of parameters. Each parameter
     * must contain a value or an expression or an array with values or
     * expressions.
     *
     * @param string|array(string)
     * @return string an expression
     */
    public function mul(array $args)
    {
        return $this->basicMath('*', $args);
    }

    /**
     * Returns the SQL to divide values or expressions by eachother.
     *
     * divide() accepts an arbitrary number of parameters. Each parameter
     * must contain a value or an expression or an array with values or
     * expressions.
     *
     * @param string|array(string)
     * @return string an expression
     */
    public function div(array $args)
    {
        return $this->basicMath('/', $args);
    }

    /**
     * Returns the SQL to check if two values are equal.
     *
     * @param string $value1 logical expression to compare
     * @param string $value2 logical expression to compare with
     * @return string logical expression
     */
    public function eq($value1, $value2)
    {
        $value1 = $this->getIdentifier($value1);
        $value2 = $this->getIdentifier($value2);
        return $value1 . ' = ' . $value2;
    }

    /**
     * Returns the SQL to check if two values are unequal.
     *
     * @param string $value1 logical expression to compare
     * @param string $value2 logical expression to compare with
     * @return string logical expression
     */
    public function neq($value1, $value2)
    {
        $value1 = $this->getIdentifier($value1);
        $value2 = $this->getIdentifier($value2);
        return $value1 . ' <> ' . $value2;
    }

    /**
     * Returns the SQL to check if one value is greater than another value.
     *
     * @param string $value1 logical expression to compare
     * @param string $value2 logical expression to compare with
     * @return string logical expression
     */
    public function gt($value1, $value2)
    {
        $value1 = $this->getIdentifier($value1);
        $value2 = $this->getIdentifier($value2);
        return $value1 . ' > ' . $value2;
    }

    /**
     * Returns the SQL to check if one value is greater than or equal to
     * another value.
     *
     * @param string $value1 logical expression to compare
     * @param string $value2 logical expression to compare with
     * @return string logical expression
     */
    public function gte($value1, $value2)
    {
        $value1 = $this->getIdentifier($value1);
        $value2 = $this->getIdentifier($value2);
        return $value1 . ' >= ' . $value2;
    }

    /**
     * Returns the SQL to check if one value is less than another value.
     *
     * @param string $value1        logical expression to compare
     * @param string $value2        logical expression to compare with
     * @return string logical expression
     */
    public function lt($value1, $value2)
    {
        $value1 = $this->getIdentifier($value1);
        $value2 = $this->getIdentifier($value2);
        return $value1 . ' < ' . $value2;
    }

    /**
     * Returns the SQL to check if one value is less than or equal to
     * another value.
     *
     * @param string $value1        logical expression to compare
     * @param string $value2        logical expression to compare with
     * @return string logical expression
     */
    public function lte($value1, $value2)
    {
        $value1 = $this->getIdentifier($value1);
        $value2 = $this->getIdentifier($value2);
        return $value1 . ' <= ' . $value2;
    }

    /**
     * Returns the SQL to check if a value is one in a set of
     * given values..
     *
     * in() accepts an arbitrary number of parameters. The first parameter
     * must always specify the value that should be matched against. Successive
     * must contain a logical expression or an array with logical expressions.
     * These expressions will be matched against the first parameter.
     *
     * @param string $column        the value that should be matched against
     * @param string|array(string)  values that will be matched against $column
     * @return string logical expression
     */
    public function in($column, $values)
    {
        if ( ! is_array($values)) {
            $values = array($values);
        }
        $values = $this->getIdentifiers($values);
        $column = $this->getIdentifier($column);

        if (count($values) == 0) {
            throw new Doctrine_Expression_Exception('Values array for IN operator should not be empty.');
        }
        return $column . ' IN (' . implode(', ', $values) . ')';
    }

    /**
     * Returns SQL that checks if a expression is null.
     *
     * @param string $expression the expression that should be compared to null
     * @return string logical expression
     */
    public function isNull($expression)
    {
        $expression = $this->getIdentifier($expression);
        return $expression . ' IS NULL';
    }

    /**
     * Returns SQL that checks if a expression is not null.
     *
     * @param string $expression the expression that should be compared to null
     * @return string logical expression
     */
    public function isNotNull($expression)
    {
        $expression = $this->getIdentifier($expression);
        return $expression . ' IS NOT NULL';
    }

    /**
     * Returns SQL that checks if an expression evaluates to a value between
     * two values.
     *
     * The parameter $expression is checked if it is between $value1 and $value2.
     *
     * Note: There is a slight difference in the way BETWEEN works on some databases.
     * http://www.w3schools.com/sql/sql_between.asp. If you want complete database
     * independence you should avoid using between().
     *
     * @param string $expression the value to compare to
     * @param string $value1 the lower value to compare with
     * @param string $value2 the higher value to compare with
     * @return string logical expression
     */
    public function between($expression, $value1, $value2)
    {
        $expression = $this->getIdentifier($expression);
        $value1 = $this->getIdentifier($value1);
        $value2 = $this->getIdentifier($value2);
        return $expression . ' BETWEEN ' .$value1 . ' AND ' . $value2;
    }

    /**
     * Returns global unique identifier
     *
     * @return string to get global unique identifier
     */
    public function guid()
    {
        throw new Doctrine_Expression_Exception('method not implemented');
    }

    /**
     * returns arcus cosine SQL string
     *
     * @return string
     */
    public function acos($value)
    {
        return 'ACOS(' . $value . ')';
    }

    /**
     * sin
     *
     * @param string $value
     * @return void
     */
    public function sin($value)
    {
        return 'SIN(' . $value . ')';
    }

    /**
     * pi
     *
     * @return void
     */
    public function pi()
    {
        return 'PI()';
    }

    /**
     * cos
     *
     * @param string $value
     * @return void
     */
    public function cos($value)
    {
        return 'COS(' . $value . ')';
    }

    /**
     * coalesce
     *
     * @return string
     */
    public function coalesce()
    {
        $args = func_get_args();

	    return 'COALESCE(' . join(', ', (array) $args) . ')';
    }

    /**
     * __call
     *
     * for all native RDBMS functions the function name itself is returned
     */
    public function __call($m, $a)
    {
        if ($this->conn->getAttribute(Doctrine_Core::ATTR_PORTABILITY) & Doctrine_Core::PORTABILITY_EXPR) {
            throw new Doctrine_Expression_Exception('Unknown expression: ' . $m);
        }

        return $m . '(' . implode(', ', $a) . ')';
    }
}


text:
namespace chrono {
namespace sensor {

// forward declaration
class ChSensor;

/// @addtogroup sensor_filters
/// @{

/// A filter that, when applied to a sensor, generates point cloud data from depth values
class CH_SENSOR_API ChFilterPCfromDepth : public ChFilter {
  public:
    /// Class constructor
    /// @param name String name of the filter
    ChFilterPCfromDepth(std::string name = {});

    /// Apply function. Converts data from depth/intensity to point cloud data
    /// @param pSensor A pointer to the sensor on which the filter is attached.
    /// @param bufferInOut A buffer that is passed into the filter.
    virtual void Apply(std::shared_ptr<ChSensor> pSensor, std::shared_ptr<SensorBuffer>& bufferInOut);

    /// Initializes all data needed by the filter access apply function.
    /// @param pSensor A pointer to the sensor.
    virtual void Initialize(std::shared_ptr<ChSensor> pSensor) {}

  private:
    std::shared_ptr<SensorDeviceXYZIBuffer> m_buffer;  ///< holder of the output buffer
};

/// @}

}  // namespace sensor
}  // namespace chrono

#endif

redpajama_set_name: RedPajamaGithub


text:
from ...athreads.fifo import await_fifo, await_ts_fifo

class http2_producer_fifo (await_fifo):
	# asyncore await_fifo replacement
	# for resorting, removeing by http2 priority, cacnel and reset features
	# also can handle producers has 'ready' method
	# this class can be used only at single thread environment

	def remove (self, stream_id):
		if self.l:
			for i in range (len (self.l)):
				try:
					producer_stream_id = self.l [0].stream_id
				except AttributeError:
					pass
				else:
					if producer_stream_id	== stream_id:
						self.l.popleft ()
				self.l.rotate (1)

	def _insert_into (self, index, item):
		if index == 0:
			self.l.appendleft (item)
		elif index == -1:
			self.l.append (item)
		else:
			r = len (self.l) - index
			self.l.rotate (r)
			self.l.append (item)
			self.l.rotate (index + 1)

	def insert (self, index, item):
		if item is None:
			self.has_None = True
			return

		if self.has_None and index != 0:
			return # deny adding
		if not self.l:
			return self.l.append (item)

		if index == 0:
			try:
				readyfunc = getattr (item, "ready")
			except AttributeError:
				pass
			else:
				if not readyfunc ():
					return self.l.append (item)

			return self.l.appendleft (item)

		# insert by priority
		try:
			d1 = item.depends_on
			w1 = item.weight
		except AttributeError:
			return self.l.append (item)

		if d1 == 0:
			return self.l.append (item)

		i = 0
		found_parent = 0
		for each in self.l:
			try:
				s2 = each.stream_id
			except AttributeError:
				pass
			else:
				if found_parent:
					d2 = each.depends_on
					w2 = each.weight
					if d1 == d2 and w2 < w1:
						return self._insert_into (i, item)
				elif d1 == s2:
					found_parent = 1
			i += 1

		self.l.append (item)

class http2_producer_ts_fifo (http2_producer_fifo, await_ts_fifo):
	# multin threads safe version

	def remove (self, stream_id):
		with self._lock:
			http2_producer_fifo.remove (self, stream_id)

	def insert (self, index, item):
		with self._lock:
			http2_producer_fifo.insert (self, index, item)


text:
package kuberuntime

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"k8s.io/kubernetes/pkg/apis/componentconfig"
	apitest "k8s.io/kubernetes/pkg/kubelet/api/testing"
	containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
	"k8s.io/kubernetes/pkg/kubelet/network"
	nettest "k8s.io/kubernetes/pkg/kubelet/network/testing"
)

func createTestFakeRuntimeManager() (*apitest.FakeRuntimeService, *apitest.FakeImageService, *kubeGenericRuntimeManager, error) {
	fakeRuntimeService := apitest.NewFakeRuntimeService()
	fakeImageService := apitest.NewFakeImageService()
	networkPlugin, _ := network.InitNetworkPlugin(
		[]network.NetworkPlugin{},
		"",
		nettest.NewFakeHost(nil),
		componentconfig.HairpinNone,
		"10.0.0.0/8",
	)
	osInterface := &containertest.FakeOS{}
	manager, err := NewFakeKubeRuntimeManager(fakeRuntimeService, fakeImageService, networkPlugin, osInterface)
	return fakeRuntimeService, fakeImageService, manager, err
}

func TestNewKubeRuntimeManager(t *testing.T) {
	_, _, _, err := createTestFakeRuntimeManager()
	assert.NoError(t, err)
}

func TestVersion(t *testing.T) {
	_, _, m, err := createTestFakeRuntimeManager()
	assert.NoError(t, err)

	version, err := m.Version()
	assert.NoError(t, err)
	assert.Equal(t, kubeRuntimeAPIVersion, version.String())
}

func TestContainerRuntimeType(t *testing.T) {
	_, _, m, err := createTestFakeRuntimeManager()
	assert.NoError(t, err)

	runtimeType := m.Type()
	assert.Equal(t, "fakeRuntime", runtimeType)
}


text:
package linprog.messages;

import java.util.SortedMap;
import java.util.TreeMap;

import akka.basicMessages.AnswerContent;

public class OptimizationResult implements AnswerContent {

	public SortedMap<String, double[]> basicsMap = new TreeMap<String, double[]>();

	public SortedMap<String, double[]> resultMap = new TreeMap<String, double[]>();

	public SortedMap<String, double[]> marketMap = new TreeMap<String, double[]>();

}


text:
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.ImageObserver;
import java.util.ArrayList;

public abstract class MapComponent {

   public final int start_size = 5000;

   protected ArrayList coords = new ArrayList(start_size);
   protected ArrayList poiCoords = new ArrayList(start_size);
   protected ArrayList pois = new ArrayList(start_size);
   protected ArrayList poiComments = new ArrayList(start_size);
   protected ArrayList boxes = new ArrayList(start_size);
   protected int delayTime = 1000; // Simulation update time
   protected String mapServer = "";
   protected boolean showTraffic = true;
   protected boolean showPois = false;
   protected Point carPosition = new Point(0, 0);
   protected Point carDirection = new Point(0, 0);
   protected Point cPoint = new Point(0, 0); // What is this?
   protected Point markedPoint = new Point(0, 0);
   protected int screenHeight;
   protected int screenWidth;
   protected int screenDistance;
   protected Point nwPoint = new Point(0, 0);
   protected Point sePoint = new Point(0, 0);
   protected double xyRatio;
   protected SPDesc spDesc;
   protected Component toRepaint;

   private Point start = null;
   private Point dest = null;

   private class Poi {
      public int x;
      public int y;
      public String name;

      public Poi(int mc2_x, int mc2_y, String name) {
         this.x = mc2_x;
         this.y = mc2_y;
         this.name = name;
      }
   }

   // Maximum route acceleration and speed. In m/s & m/(s^2).
   protected int maxAcceleration = 2;
   protected int defaultMaxSpeed = 56;
   protected int maxSpeed = 20;

   protected final double wgs84Tomc2 = 11930464.7111;
   protected final double mc2ToM = (double) (40075016.69 / 4294967296.0);

   //Interface

   public abstract void zoomIn(int mc2_x, int mc2_y);

   public abstract void zoomOut(int mc2_x, int mc2_y);

   public abstract void moveCenter(int mc2_x, int mc2_y);

   public abstract void zoomToSquare(int x1, int y1, int x2, int y2); //x2 and y2 is width and height of zoomSquare!

   public abstract void loadMap() throws Exception;

   public abstract int mc2LatToY(int mc2Lat);

   public abstract int mc2LonToX(int mc2Lon);

   public abstract int xToMc2Lon(int x);

   public abstract int yToMc2Lat(int y);

   public abstract boolean drawMap(Graphics g, int width, int height,
         ImageObserver obs);

   public abstract void zoomToRoute();

   protected void setSPDesc(SPDesc spDesc) {
      this.spDesc = spDesc;
   }

   protected void setMarkedPoint(Point p) {
      markedPoint = p;
   }

   protected Point getMarkedPoint() {
      return markedPoint;
   }

   protected void setShowPoi(boolean en) {
      showPois = en;
   }

   protected boolean showPoi() {
      return showPois;
   }

   protected void setStartPoint(int mc2_x, int mc2_y) {
      start = new Point(mc2_x, mc2_y);
   }

   protected void setDestPoint(int mc2_x, int mc2_y) {
      dest = new Point(mc2_x, mc2_y);
   }

   protected Point getStartPoint() {
      return start;
   }

   protected Point getDestPoint() {
      return dest;
   }

   protected void clearStartEndPoints() {
      start = null;
      dest = null;
   }

   protected int getDelayTime() {
      return delayTime;
   }

   protected void setScreenHeight(int height) {
      screenHeight = height;
   }

   protected void setScreenWidth(int width) {
      screenWidth = width;
   }

   protected Point getCPoint() {
      return cPoint;
   }

   protected Point getCarDir() {
      return carDirection;
   }

   protected Point getCarPos() {
      return carPosition;
   }

   protected Rectangle getBox(int i) {
      return (Rectangle) boxes.get(i);
   }

   protected Point getCoordPoiPoint(int i) {
      return (Point) poiCoords.get(i);
   }

   protected String getCoordPoiComment(int i) {
      return (String) poiComments.get(i);
   }

   protected int getPoiX(int i) {
      return ((Poi) pois.get(i)).x;
   }

   protected int getPoiY(int i) {
      return ((Poi) pois.get(i)).y;
   }

   protected String getPoiName(int i) {
      return ((Poi) pois.get(i)).name;
   }

   protected Point getRoutePoint(int i) {
      return (Point) coords.get(i);
   }

   protected void addCoordPoiComment(String comment) {
      poiComments.add(comment);
   }

   protected void addCoordPoiPoint(int mc2_x, int mc2_y) {
      poiCoords.add(new Point(mc2_x, mc2_y));
   }

   protected void addPoiPoint(int mc2_x, int mc2_y, String name) {
      Poi poi = new Poi(mc2_x, mc2_y, name);
      pois.add(poi);
   }

   protected void removeCoordPoiPoint(int i) {
      poiCoords.remove(i);
   }

   protected void removeCoordPoiComment(int i) {
      poiComments.remove(i);
   }

   protected void removeRoutePoint(int i) {
      for (int j = i; j < coords.size(); j++)
         coords.remove(j);
   }

   protected ArrayList getRoute() {
      return coords;
   }

   protected void setRoute(ArrayList route) {
      coords = route;
   }

   protected int getNbrBoxes() {
      return boxes.size();
   }

   protected int getNbrRoutePoints() {
      return coords.size();
   }

   protected int getNbrCoordPoiPoints() {
      return poiCoords.size();
   }

   protected int getNbrPoiPoints() {
      return pois.size();
   }

   protected int getDefaultMaxSpeed() {
      return defaultMaxSpeed;
   }

   protected void setMaxSpeed(int speed) {
      maxSpeed = speed;
   }

   protected int getMaxSpeed() {
      return maxSpeed;
   }

   protected void setShowTraffic(boolean en) {
      showTraffic = en;
   }

   protected boolean showTraffic() {
      return showTraffic;
   }

   protected void setDelayTime(int time) {
      delayTime = time;
   }

   protected void resetForLoad(int size) {
      coords = new ArrayList(size);
      //mapWin.setLoadButton(false);
      //mapWin.repaint();
   }

   protected void setRoutePoints(NMEAMessage[] messages) {
      //nbrCoords = 0;
      for (int i = 0, n = messages.length; i < n; ++i) {
         if (messages[i].isRMC()) {
            if (messages[i].getLon() != Double.MAX_VALUE) {
               coords.add(new Point((int) Math.round(wgs84ToMc2(messages[i]
                     .getLon())), (int) Math.round(wgs84ToMc2(messages[i]
                     .getLat()))));
               //nbrCoords++;
            }
         }
      }
   }

   /**
    * Call resetForLoad() first
    */
   protected boolean loadRoutePoint(double x, double y) {
      int newX = (int) Math.round(wgs84ToMc2(x));
      int newY = (int) Math.round(wgs84ToMc2(y));

      addRoutePoint(newX, newY);

      // Why use repaint! or something
      //      Graphics g = getGraphics();
      //      drawRoutePoint();
      //      repaint();
      return true;
   }

   protected void addRoutePoint(int mc2_x, int mc2_y) {
      if (coords.size() == 0) {
         coords.add(new Point(mc2_x, mc2_y));
      } else {
         // Max dist & acc
         int max_dd = (int) (((float) delayTime / 1000.0) * maxAcceleration / mc2ToM);
         int max_d = (int) (((float) delayTime / 1000.0) * maxSpeed / mc2ToM);
         float coslat = (float) getCosLat(mc2_y);
         do {
            int lastSpeed = 0;
            float dx;
            float dy;
            if (coords.size() > 1) {
               dx = ((Point) coords.get(coords.size() - 1)).x
                     - ((Point) coords.get(coords.size() - 2)).x;
               dy = ((Point) coords.get(coords.size() - 1)).y
                     - ((Point) coords.get(coords.size() - 2)).y;
               lastSpeed = (int) Math.sqrt(Math.pow(dy, 2)
                     + Math.pow(dx * coslat, 2));
            }
            dx = mc2_x - ((Point) coords.get(coords.size() - 1)).x;
            dy = mc2_y - ((Point) coords.get(coords.size() - 1)).y;

            int thisSpeed = (int) Math.sqrt(Math.pow(dy, 2)
                  + Math.pow(dx * coslat, 2));
            if ((lastSpeed + max_dd > thisSpeed) && (max_d > thisSpeed)) {
               //coords[nbrCoords++] = new Point(mc2_x, mc2_y);
               coords.add(new Point(mc2_x, mc2_y));
               //nbrCoords++;

            } else {
               // Calculate how many between points we need.
               int nbrPoints = 0;
               int totDist = 0;
               int incSpeed = lastSpeed + max_dd;
               while (totDist < thisSpeed) {
                  nbrPoints++;
                  totDist += incSpeed;
                  incSpeed = Math.min(incSpeed + max_dd, max_d);
               }

               // Create new speed
               int newSpeed = Math.min((int) (thisSpeed / nbrPoints) + 1,
                     lastSpeed + max_dd);
               newSpeed = Math.min(newSpeed, max_d);
               float speedFactor = (float) newSpeed / (float) thisSpeed;
               int new_dx = (int) (dx * speedFactor);
               int new_dy = (int) (dy * speedFactor);
               int new_X = ((Point) coords.get(coords.size() - 1)).x + new_dx;
               int new_Y = ((Point) coords.get(coords.size() - 1)).y + new_dy;
               //System.out.println("newSpeed"+newSpeed+", dy = "+new_dy
               //                 +", dx = "+new_dx);
               coords.add(new Point(new_X, new_Y));
               //nbrCoords++;

            }
         } while (/**(nbrCoords < maxNbrPoints) && */
         (((Point) coords.get(coords.size() - 1)).x != mc2_x)
               || (((Point) coords.get(coords.size() - 1)).y != mc2_y));
      }
   }

   protected int findRoutePoint(int mc2_x, int mc2_y) {
      int retVal = -1;
      int index = coords.size() - 1;
      int sc_y = mc2LatToY(mc2_y);
      int sc_x = mc2LonToX(mc2_x);
      //System.out.println("sc_y,sc_x"+sc_y+","+sc_x);

      while (((index + 1) > 0) && (retVal == -1)) {
         int x = mc2LonToX(((Point) coords.get(index)).x);
         int y = mc2LatToY(((Point) coords.get(index)).y);
         //System.out.println("      y,x"+y+","+x);
         if ((sc_x < (x + 5)) && (sc_x > (x - 5)) && (sc_y < (y + 5))
               && (sc_y > (y - 5))) {
            retVal = index;
         }
         index--;
      }
      return retVal;
   }

   protected String getRouteDataString(int i) {
      String data = "";
      if (i < coords.size()) {
         // Lat & lon
         double y = (double) ((double) ((Point) coords.get(i)).y / wgs84Tomc2);
         double x = (double) ((double) ((Point) coords.get(i)).x / wgs84Tomc2);
         double speed_x = 0;
         double speed_y = 0;
         if (i < coords.size() - 1) {
            int d_x = ((Point) coords.get(i + 1)).x - ((Point) coords.get(i)).x;
            int d_y = ((Point) coords.get(i + 1)).y - ((Point) coords.get(i)).y;
            //System.out.println("dy = "+d_y+", dx = "+d_x);
            double coslat = (double) getCosLat(((Point) coords.get(i)).y);
            speed_x = (double) d_x * coslat * mc2ToM * (double) 1000
                  / (double) delayTime;
            speed_y = (double) d_y * mc2ToM * (double) 1000
                  / (double) delayTime;
            if ((speed_x < 0000.1) && (speed_x > -0000.1))
               speed_x = 0;
            if ((speed_y < 0000.1) && (speed_y > -0000.1))
               speed_y = 0;
         }

         data = y + " " + x + " " + speed_x + " " + speed_y;
         //System.out.println(i+")"+data);
      }
      return data;
   }

   protected int findCoordPoiPoint(int sc_x, int sc_y) {
      int retVal = -1;
      int index = poiCoords.size() - 1;
      //System.out.println("(sc_y,sc_x) = "+ "(" + sc_y + "," + sc_x + ")");

      while (((index + 1) > 0) && (retVal == -1)) {
         int x = mc2LonToX(((Point) poiCoords.get(index)).x);
         int y = mc2LatToY(((Point) poiCoords.get(index)).y);
         //System.out.println("      y,x"+y+","+x);
         if ((sc_x < (x + 5)) && (sc_x > (x - 5)) && (sc_y < (y + 5))
               && (sc_y > (y - 5))) {
            retVal = index;
         }
         index--;
      }
      return retVal;
   }

   protected void updateVehicle(double lat, double lon, double speed,
         double bearing, boolean gpsOn) {
      //System.out.println("updateVehicle");

      carPosition.x = (int) Math.round(wgs84ToMc2(lon));
      carPosition.y = (int) Math.round(wgs84ToMc2(lat));
      //System.out.println(carPos.x+" "+carPos.y);
      // Update speed & bearing
      speed = speed / 1.9438445; // knots =>m/s.
      bearing = bearing * Math.PI / 180.0;
      double y_speed = (double) speed * (double) Math.cos(bearing);
      double x_speed = (double) speed * (double) Math.sin(bearing);

      double meterTocoord = 3.0 / mc2ToM;
      double coslat = (double) getCosLat(carPosition.y);

      carDirection.y = carPosition.y + (int) (meterTocoord * y_speed);
      carDirection.x = carPosition.x + (int) (meterTocoord * x_speed / coslat);

      if (false //close to edge)
      ) {
      }
   }

   protected void setServer(String server) {
      this.mapServer = server;
   }

   protected String getServer() {
      return mapServer;
   }

   protected void resetCoordPoiForLoad() {
      poiCoords = new ArrayList(start_size);
      //mapWin.repaint();
   }

   protected void resetPoiForLoad() {
      pois = new ArrayList(start_size);
   }

   protected void addBox(Rectangle r) {
      boxes.add(r);
   }

   protected void removeBox(int i) {
      boxes.remove(i);
   }

   protected double mc2ToWgs84(double mc2) {
      return mc2 / wgs84Tomc2;
   }

   protected double wgs84ToMc2(double wgs84) {
      return wgs84 * wgs84Tomc2;
   }

   protected double getCosLat(int mc2Lat) {
      double latInRads = ((double) mc2Lat * Math.PI) / (wgs84Tomc2 * 180);
      return Math.cos(latInRads);
   }

   protected void setXYRatio(double ratio) {
      xyRatio = ratio;
   }

   protected Point getNWPoint() {
      return nwPoint;
   }

   protected Point getSEPoint() {
      return sePoint;
   }

   protected int getScreenDistance() {
      return screenDistance;
   }

   protected void setScreenDistance(int dist) {
      screenDistance = dist;
   }

}


text:
package info.u250.c2d.box2deditor.io;

import java.io.File;
import java.io.InputStream;

public interface IO {
	void reset();
	void save(File file);
	void read(File file);
	void read(InputStream input);

	void exportXML(File file);

	public IO INSTANCE = new SerializableIO();
}


text:
package com.ontraport.app.tests;

import java.util.Calendar;
import java.util.concurrent.TimeUnit;

import org.junit.Assert;
import org.junit.Test;
import org.testng.AssertJUnit;

import com.ontraport.app.pages.Contact_ListAll;
import com.ontraport.app.pages.SmartForm_Create;
import com.ontraport.app.pages.SmartForm_Edit;
import com.ontraport.app.pages.SmartForm_ListAll;
import com.ontraport.app.parts.SiteMenu;
import com.ontraport.app.tools.AbstractTest;

public class SmartForm_FormStyle_BackgroundPos_TC0415 extends AbstractTest {
	String smartFormName = "SForm" + Calendar.getInstance().getTimeInMillis();
	String sectionName = "label style";
	String fieldName = "Background Position";
	String fieldvalue = "Right Top";

	@Test
	public void SmartForm_FormStyle_BackgroundPos_TC0415 () throws Exception{
		SmartForm_Create smartFormCreate = createSmartForm (smartFormName);
		SmartForm_Edit smartFormEdit = navigateToContactsAndClickSmartForms (smartFormName);
		smartFormEdit = smartFormEdit.clickSubmitButton();
		//Fill text box field
		smartFormEdit = smartFormEdit.clickFormStyle();
		smartFormEdit.setSelectInFormStyleBasedOnLabel(sectionName,fieldName, fieldvalue);
		smartFormEdit.clickSaveButton();
		smartFormEdit = navigateToContactsAndClickSmartForms (smartFormName);
		smartFormEdit = smartFormEdit.clickSubmitButton();
		//Verification on select field
		smartFormEdit = smartFormEdit.clickFormStyle();
		boolean b = smartFormEdit.verifySelectedOptionInFormStyleBasedOnLabel(sectionName,fieldName, fieldvalue);
		System.out.println(b);
		Assert.assertTrue("Field Value", b);

	}

	public SmartForm_Create createSmartForm (String smartFormName) throws Exception{
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
		SiteMenu sitemenu = (SiteMenu) new SiteMenu().init();
		Contact_ListAll contactListAll = sitemenu.contacts();
		SmartForm_ListAll smartListAll = contactListAll.navSmartForms();
		Thread.sleep(4000);
		SmartForm_Create smartFormCreate = smartListAll.clickNewSmartForm();
		return smartFormCreate.createNewSmartForm(smartFormName);
	}

	public SmartForm_Edit navigateToContactsAndClickSmartForms (String smartFormName) throws Exception{
		SiteMenu sitemenu = (SiteMenu) new SiteMenu().init();
		Contact_ListAll contactListAll = sitemenu.contacts();
		SmartForm_ListAll smartListAll = contactListAll.navSmartForms();
		smartListAll.setHundredRecordsPerPage();
		boolean condition = smartListAll.isElementPresent(smartFormName);
		AssertJUnit.assertTrue(condition);
		return smartListAll.editSmartForm(smartFormName);
	}

}


text:
<?php

/**
 * Output the vendor metabox
 *
 *
 *
 * @link       http://www.wcvendors.com
 * @since      1.0.0
 *
 * @package    WCVendors_Pro
 * @subpackage WCVendors_Pro/public/partials
 */

$output = "<select style='width:200px;' name='$id' id='$id' class='$class' data-placeholder='$placeholder'>\n";
$output .= "\t<option value=''></option>\n";

foreach ( $roles as $role ) {

	$new_args           = $user_args;
	$new_args[ 'role' ] = $role;
	$users              = get_users( $new_args );

	if ( empty( $users ) ) continue;
	foreach ( (array) $users as $user ) {
		$select = selected( $user->ID, $selected, false );
		$output .= "\t<option value='$user->ID' $select>$user->user_login</option>\n";
	}

}
$output .= "</select>";

// Convert this selectbox with select2
$output .= '
<script type="text/javascript">jQuery(function() { jQuery("#' . $id . '").select2().focus(); } );</script>';

?>


text:
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;
using System.IO;

namespace Amazon.SimpleWorkflow.Model
{
    ///
    /// <para> Provides details of the <c>CompleteWorkflowExecutionFailed</c> event. </para>
    ///
    public class CompleteWorkflowExecutionFailedEventAttributes
    {

        private string cause;
        private long? decisionTaskCompletedEventId;

        ///
        /// The cause of the failure. This information is generated by the system and can be useful for diagnostic purposes. <note>If cause is
        /// set to OPERATION_NOT_PERMITTED, the decision failed because it lacked sufficient permissions. For details and example IAM policies, see Using IAM to Manage Access to Amazon SWF
        /// Workflows.</note>
        ///
        /// <para>
        /// Constraints:
        /// <list type="definition">
        ///     <item>
        ///         <term>Allowed Values</term>
        ///         <description>UNHANDLED_DECISION, OPERATION_NOT_PERMITTED</description>
        ///     </item>
        /// </list>
        /// </para>
        ///
        public string Cause
        {
            get { return this.cause; }
            set { this.cause = value; }
        }

        ///
        /// Sets the Cause property
        ///
        /// <param name="cause">The value to set for the Cause property </param>
        /// <returns>this instance</returns>
        [Obsolete("The With methods are obsolete and will be removed in version 2 of the AWS SDK for .NET. See http://aws.amazon.com/sdkfornet/#version2 for more information.")]
        public CompleteWorkflowExecutionFailedEventAttributes WithCause(string cause)
        {
            this.cause = cause;
            return this;
        }

        // Check to see if Cause property is set
        internal bool IsSetCause()
        {
            return this.cause != null;
        }

        ///
        /// The id of the <c>DecisionTaskCompleted</c> event corresponding to the decision task that resulted in the <c>CompleteWorkflowExecution</c>
        /// decision to complete this execution. This information can be useful for diagnosing problems by tracing back the cause of events.
        ///
        ///
        public long DecisionTaskCompletedEventId
        {
            get { return this.decisionTaskCompletedEventId ?? default(long); }
            set { this.decisionTaskCompletedEventId = value; }
        }

        ///
        /// Sets the DecisionTaskCompletedEventId property
        ///
        /// <param name="decisionTaskCompletedEventId">The value to set for the DecisionTaskCompletedEventId property </param>
        /// <returns>this instance</returns>
        [Obsolete("The With methods are obsolete and will be removed in version 2 of the AWS SDK for .NET. See http://aws.amazon.com/sdkfornet/#version2 for more information.")]
        public CompleteWorkflowExecutionFailedEventAttributes WithDecisionTaskCompletedEventId(long decisionTaskCompletedEventId)
        {
            this.decisionTaskCompletedEventId = decisionTaskCompletedEventId;
            return this;
        }

        // Check to see if DecisionTaskCompletedEventId property is set
        internal bool IsSetDecisionTaskCompletedEventId()
        {
            return this.decisionTaskCompletedEventId.HasValue;
        }
    }
}


text:
import {AttributeMetadata} from "../../AttributeMetadata";

export class AttributeMetadataAndAttributeName {
    public readonly attributeMetadata: AttributeMetadata<any>;
    public readonly attributeName: string;

    constructor(attributeMetadata: AttributeMetadata<any>, attributeName: string) {
        this.attributeMetadata = attributeMetadata;
        this.attributeName = attributeName;
    }
}


text:
/**
 * @file
 *   This file includes definitions for IPv6 addresses.
 */

#ifndef IP6_ADDRESS_HPP_
#define IP6_ADDRESS_HPP_

#include "openthread-core-config.h"

#include <stdint.h>

#include <openthread/ip6.h>

#include "common/as_core_type.hpp"
#include "common/clearable.hpp"
#include "common/encoding.hpp"
#include "common/equatable.hpp"
#include "common/string.hpp"
#include "mac/mac_types.hpp"

using ot::Encoding::BigEndian::HostSwap16;

namespace ot {

namespace Ip4 {
// Forward declaration for SynthesizeFromIp4Address
class Address;
} // namespace Ip4

namespace Ip6 {

/**
 * @addtogroup core-ip6-ip6
 *
 * @{
 *
 */

/**
 * This class represents the Network Prefix of an IPv6 address (most significant 64 bits of the address).
 *
 */
OT_TOOL_PACKED_BEGIN
class NetworkPrefix : public otIp6NetworkPrefix, public Equatable<NetworkPrefix>, public Clearable<NetworkPrefix>
{
public:
    static constexpr uint8_t kSize   = OT_IP6_PREFIX_SIZE;            ///< Size in bytes.
    static constexpr uint8_t kLength = OT_IP6_PREFIX_SIZE * CHAR_BIT; ///< Length of Network Prefix in bits.

    /**
     * This method generates and sets the Network Prefix to a crypto-secure random Unique Local Address (ULA) based
     * on the pattern `fdxx:xxxx:xxxx:` (RFC 4193).
     *
     * @retval kErrorNone     Successfully generated a random ULA Network Prefix
     * @retval kErrorFailed   Failed to generate random ULA Network Prefix.
     *
     */
    Error GenerateRandomUla(void);

} OT_TOOL_PACKED_END;

/**
 * This class represents an IPv6 Prefix.
 *
 */
OT_TOOL_PACKED_BEGIN
class Prefix : public otIp6Prefix, public Clearable<Prefix>, public Unequatable<Prefix>
{
public:
    static constexpr uint8_t kMaxLength = OT_IP6_ADDRESS_SIZE * CHAR_BIT; ///< Max length of a prefix in bits.
    static constexpr uint8_t kMaxSize   = OT_IP6_ADDRESS_SIZE;            ///< Max (byte) size of a prefix.

    static constexpr uint16_t kInfoStringSize = OT_IP6_PREFIX_STRING_SIZE; ///< Info string size (`ToString()`).

    /**
     * This type defines the fixed-length `String` object returned from `ToString()`.
     *
     */
    typedef String<kInfoStringSize> InfoString;

    /**
     * This method gets the prefix as a pointer to a byte array.
     *
     * @returns A pointer to a byte array containing the Prefix.
     *
     */
    const uint8_t *GetBytes(void) const { return mPrefix.mFields.m8; }

    /**
     * This method gets the subnet ID of the prefix.
     *
     * @returns The 16-bit subnet ID.
     *
     */
    uint16_t GetSubnetId(void) const { return HostSwap16(mPrefix.mFields.m16[3]); }

    /**
     * This method gets the prefix length (in bits).
     *
     * @returns The prefix length (in bits).
     *
     */
    uint8_t GetLength(void) const { return mLength; }

    /**
     * This method returns the size (in bytes) of the prefix.
     *
     * @returns The size (in bytes) of the prefix array.
     *
     */
    uint8_t GetBytesSize(void) const { return SizeForLength(mLength); }

    /**
     * This method sets the prefix.
     *
     * @param[in] aPrefix  A pointer to buffer containing the prefix bytes.
     * @param[in] aLength  The length or prefix in bits.
     *
     */
    void Set(const uint8_t *aPrefix, uint8_t aLength);

    /**
     * This method sets the prefix from a given Network Prefix.
     *
     * @param[in] aNetworkPrefix    A Network Prefix.
     *
     */
    void Set(const NetworkPrefix &aNetworkPrefix) { Set(aNetworkPrefix.m8, NetworkPrefix::kLength); }

    /**
     * This method sets the subnet ID of the prefix.
     *
     * @param[in] aSubnetId  A 16-bit subnet ID.
     *
     */
    void SetSubnetId(uint16_t aSubnetId) { mPrefix.mFields.m16[3] = HostSwap16(aSubnetId); }

    /**
     * This method set the prefix length.
     *
     * @param[in] aLength  The new prefix length (in bits).
     *
     */
    void SetLength(uint8_t aLength) { mLength = aLength; }

    /**
     * This method indicates whether prefix length is valid (smaller or equal to max length).
     *
     * @retval TRUE   The prefix length is valid.
     * @retval FALSE  The prefix length is not valid.
     *
     */
    bool IsValid(void) const { return (mLength <= kMaxLength); }

    /**
     * This method indicates whether the prefix is a Link-Local prefix.
     *
     * @retval TRUE   The prefix is a Link-Local prefix.
     * @retval FALSE  The prefix is not a Link-Local prefix.
     *
     */
    bool IsLinkLocal(void) const;

    /**
     * This method indicates whether the prefix is a Multicast prefix.
     *
     * @retval TRUE   The prefix is a Multicast prefix.
     * @retval FALSE  The prefix is not a Multicast prefix.
     *
     */
    bool IsMulticast(void) const;

    /**
     * This method indicates whether the prefix is a Unique-Local prefix.
     *
     * @retval TRUE   The prefix is a Unique-Local prefix.
     * @retval FALSE  The prefix is not a Unique-Local prefix.
     *
     */
    bool IsUniqueLocal(void) const;

    /**
     * This method indicates whether the prefix is equal to a given prefix.
     *
     * @param[in] aPrefixBytes   A pointer to buffer containing the prefix bytes to compare with.
     * @param[in] aPrefixLength  The length of prefix (in bits) specified by @p aPrefixBytes.
     *
     * @retval TRUE   If the prefix is equal to the specified prefix by @p aPrefixBytes and @p aPrefixLength.
     * @retval FALSE  If the prefix is not equal to the specified prefix by @p aPrefixBytes and @p aPrefixLength.
     *
     */
    bool IsEqual(const uint8_t *aPrefixBytes, uint8_t aPrefixLength) const;

    /**
     * This method indicates whether the prefix contains a sub-prefix.
     *
     * @param[in] aSubPrefix  A sub-prefix.
     *
     * @retval TRUE   The prefix contains the @p aSubPrefix
     * @retval FALSE  The prefix does not contains the @p aSubPrefix.
     *
     */
    bool ContainsPrefix(const Prefix &aSubPrefix) const;

    /**
     * This method indicates whether the prefix contains a sub-prefix (given as a `NetworkPrefix`).
     *
     * @param[in] aSubPrefix  A sub-prefix (as a `NetworkPrefix`).
     *
     * @retval TRUE   The prefix contains the @p aSubPrefix
     * @retval FALSE  The prefix does not contains the @p aSubPrefix.
     *
     */
    bool ContainsPrefix(const NetworkPrefix &aSubPrefix) const;

    /**
     * This method overloads operator `==` to evaluate whether or not two prefixes are equal.
     *
     * @param[in]  aOther  The other prefix to compare with.
     *
     * @retval TRUE   If the two prefixes are equal.
     * @retval FALSE  If the two prefixes are not equal.
     *
     */
    bool operator==(const Prefix &aOther) const;

    /**
     * This method overloads operator `<` to compare two prefixes.
     *
     * If the two prefixes have the same length N, then the bytes are compared directly (as two big-endian N-bit
     * numbers). If the two prefix have different lengths, the shorter prefix is padded by `0` bit up to the longer
     * prefix length N before the bytes are compared (as big-endian N-bit numbers). If all bytes are equal, the prefix
     * with shorter length is considered smaller.
     *
     * @param[in] aOther  The other prefix to compare against.
     *
     * @retval TRUE   If the prefix is smaller than @p aOther.
     * @retval FALSE  If the prefix is not smaller than @p aOther.
     *
     */
    bool operator<(const Prefix &aOther) const;

    /**
     * This static method converts a prefix length (in bits) to size (number of bytes).
     *
     * @param[in] aLength   A prefix length (in bits).
     *
     * @returns The size (in bytes) of the prefix.
     *
     */
    static uint8_t SizeForLength(uint8_t aLength) { return BitVectorBytes(aLength); }

    /**
     * This static method returns the number of IPv6 prefix bits that match.
     *
     * @param[in]  aPrefixA     A pointer to a byte array containing a first prefix.
     * @param[in]  aPrefixB     A pointer to a byte array containing a second prefix.
     * @param[in]  aMaxSize     Number of bytes of the two prefixes.
     *
     * @returns The number of prefix bits that match.
     *
     */
    static uint8_t MatchLength(const uint8_t *aPrefixA, const uint8_t *aPrefixB, uint8_t aMaxSize);

    /**
     * This method indicates whether or not a given prefix length is valid for use as a NAT64 prefix.
     *
     * A NAT64 prefix must have one of the following lengths: 32, 40, 48, 56, 64, or 96 (per RFC 6502).
     *
     * @param[in] aLength The length of the prefix.
     *
     * @retval TRUE   If the prefix has a valid length for use as a NAT64 prefix.
     * @retval FALSE  If the prefix does not have a valid length for use as a NAT64 prefix.
     *
     */
    static bool IsValidNat64PrefixLength(uint8_t aLength);

    /**
     * This method indicates whether or not the prefix has a valid length for use as a NAT64 prefix.
     *
     * A NAT64 prefix must have one of the following lengths: 32, 40, 48, 56, 64, or 96 (per RFC 6502).
     *
     * @retval TRUE   If the prefix has a valid length for use as a NAT64 prefix.
     * @retval FALSE  If the prefix does not have a valid length for use as a NAT64 prefix.
     *
     */
    bool IsValidNat64(void) const { return IsValidNat64PrefixLength(mLength); }

    /**
     * This method converts the prefix to a string.
     *
     * The IPv6 prefix string is formatted as "%x:%x:%x:...[::]/plen".
     *
     * @returns An `InfoString` containing the string representation of the Prefix.
     *
     */
    InfoString ToString(void) const;

    /**
     * This method converts the prefix to a string.
     *
     * The IPv6 prefix string is formatted as "%x:%x:%x:...[::]/plen".
     *
     * If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be
     * truncated but the outputted string is always null-terminated.
     *
     * @param[out] aBuffer   A pointer to a char array to output the string (MUST NOT be `nullptr`).
     * @param[in]  aSize     The size of @p aBuffer (in bytes).
     *
     */
    void ToString(char *aBuffer, uint16_t aSize) const;

private:
    void ToString(StringWriter &aWriter) const;
} OT_TOOL_PACKED_END;

/**
 * This class represents the Interface Identifier of an IPv6 address.
 *
 */
OT_TOOL_PACKED_BEGIN
class InterfaceIdentifier : public otIp6InterfaceIdentifier,
                            public Equatable<InterfaceIdentifier>,
                            public Clearable<InterfaceIdentifier>
{
    friend class Address;

public:
    static constexpr uint8_t kSize = OT_IP6_IID_SIZE; ///< Size of an IPv6 Interface Identifier (in bytes).

    static constexpr uint16_t kInfoStringSize = 17; ///< Max chars for the info string (`ToString()`).

    /**
     * This type defines the fixed-length `String` object returned from `ToString()`.
     *
     */
    typedef String<kInfoStringSize> InfoString;

    /**
     * This method indicates whether or not the Interface Identifier is unspecified.
     *
     * @retval true  If the Interface Identifier is unspecified.
     * @retval false If the Interface Identifier is not unspecified.
     *
     */
    bool IsUnspecified(void) const;

    /**
     * This method indicates whether or not the Interface Identifier is reserved (RFC 5453).
     *
     * @retval true  If the Interface Identifier is reserved.
     * @retval false If the Interface Identifier is not reserved.
     *
     */
    bool IsReserved(void) const;

    /**
     * This method indicates whether or not the Interface Identifier is Subnet-Router Anycast (RFC 4291).
     *
     * @retval TRUE   If the Interface Identifier is a Subnet-Router Anycast address.
     * @retval FALSE  If the Interface Identifier is not a Subnet-Router Anycast address.
     *
     */
    bool IsSubnetRouterAnycast(void) const;

    /**
     * This method indicates whether or not the Interface Identifier is Reserved Subnet Anycast (RFC 2526).
     *
     * @retval TRUE   If the Interface Identifier is a Reserved Subnet Anycast address.
     * @retval FALSE  If the Interface Identifier is not a Reserved Subnet Anycast address.
     *
     */
    bool IsReservedSubnetAnycast(void) const;

    /**
     * This method generates and sets the Interface Identifier to a crypto-secure random byte sequence.
     *
     */
    void GenerateRandom(void);

    /**
     * This method gets the Interface Identifier as a pointer to a byte array.
     *
     * @returns A pointer to a byte array (of size `kSize`) containing the Interface Identifier.
     *
     */
    const uint8_t *GetBytes(void) const { return mFields.m8; }

    /**
     * This method sets the Interface Identifier from a given byte array.
     *
     * @param[in] aBuffer    Pointer to an array containing the Interface Identifier. `kSize` bytes from the buffer
     *                       are copied to form the Interface Identifier.
     *
     */
    void SetBytes(const uint8_t *aBuffer);

    /**
     * This method sets the Interface Identifier from a given IEEE 802.15.4 Extended Address.
     *
     * @param[in] aExtAddress  An Extended Address.
     *
     */
    void SetFromExtAddress(const Mac::ExtAddress &aExtAddress);

    /**
     * This method converts the Interface Identifier to an IEEE 802.15.4 Extended Address.
     *
     * @param[out]  aExtAddress  A reference to an Extended Address where the converted address is placed.
     *
     */
    void ConvertToExtAddress(Mac::ExtAddress &aExtAddress) const;

    /**
     * This method converts the Interface Identifier to an IEEE 802.15.4 MAC Address.
     *
     * @param[out]  aMacAddress  A reference to a MAC Address where the converted address is placed.
     *
     */
    void ConvertToMacAddress(Mac::Address &aMacAddress) const;

    /**
     * This method sets the Interface Identifier to Routing/Anycast Locator pattern `0000:00ff:fe00:xxxx` with a given
     * locator (RLOC16 or ALOC16) value.
     *
     * @param[in]  aLocator    RLOC16 or ALOC16.
     *
     */
    void SetToLocator(uint16_t aLocator);

    /**
     * This method indicates whether or not the Interface Identifier matches the locator pattern `0000:00ff:fe00:xxxx`.
     *
     * @retval TRUE   If the IID matches the locator pattern.
     * @retval FALSE  If the IID does not match the locator pattern.
     *
     */
    bool IsLocator(void) const;

    /**
     * This method indicates whether or not the Interface Identifier (IID) matches a Routing Locator (RLOC).
     *
     * In addition to checking that the IID matches the locator pattern (`0000:00ff:fe00:xxxx`), this method also
     * checks that the locator value is a valid RLOC16.
     *
     * @retval TRUE   If the IID matches a RLOC address.
     * @retval FALSE  If the IID does not match a RLOC address.
     *
     */
    bool IsRoutingLocator(void) const;

    /**
     * This method indicates whether or not the Interface Identifier (IID) matches an Anycast Locator (ALOC).
     *
     * In addition to checking that the IID matches the locator pattern (`0000:00ff:fe00:xxxx`), this method also
     * checks that the locator value is any valid ALOC16 (0xfc00 - 0xfcff).
     *
     * @retval TRUE   If the IID matches a ALOC address.
     * @retval FALSE  If the IID does not match a ALOC address.
     *
     */
    bool IsAnycastLocator(void) const;

    /**
     * This method indicates whether or not the Interface Identifier (IID) matches a Service Anycast Locator (ALOC).
     *
     * In addition to checking that the IID matches the locator pattern (`0000:00ff:fe00:xxxx`), this method also
     * checks that the locator value is a valid Service ALOC16 (0xfc10 – 0xfc2f).
     *
     * @retval TRUE   If the IID matches a ALOC address.
     * @retval FALSE  If the IID does not match a ALOC address.
     *
     */
    bool IsAnycastServiceLocator(void) const;

    /**
     * This method gets the Interface Identifier (IID) address locator fields.
     *
     * This method assumes the IID to match the locator pattern `0000:00ff:fe00:xxxx` (does not explicitly check this)
     * and returns the last `uint16` portion of the IID.
     *
     * @returns The RLOC16 or ALOC16.
     *
     */
    uint16_t GetLocator(void) const { return HostSwap16(mFields.m16[3]); }

    /**
     * This method sets the Interface Identifier (IID) address locator field.
     *
     * Unlike `SetToLocator()`, this method only changes the last 2 bytes of the IID and keeps the rest of the address
     * as before.
     *
     * @param[in]  aLocator   RLOC16 or ALOC16.
     *
     */
    void SetLocator(uint16_t aLocator) { mFields.m16[3] = HostSwap16(aLocator); }

    /**
     * This method applies a prefix to IID.
     *
     * If the prefix length is longer than 64 bits, the prefix bits after 64 are written into the IID. This method only
     * changes the bits in IID up the prefix length and keeps the rest of the bits in IID as before.
     *
     * @param[in] aPrefix   An IPv6 prefix.
     *
     */
    void ApplyPrefix(const Prefix &aPrefix);

    /**
     * This method converts an Interface Identifier to a string.
     *
     * @returns An `InfoString` containing the string representation of the Interface Identifier.
     *
     */
    InfoString ToString(void) const;

private:
    static constexpr uint8_t kAloc16Mask            = 0xfc; // The mask for ALOC16.
    static constexpr uint8_t kRloc16ReservedBitMask = 0x02; // The mask for the reserved bit of RLOC16.

} OT_TOOL_PACKED_END;

/**
 * This class implements an IPv6 address object.
 *
 */
OT_TOOL_PACKED_BEGIN
class Address : public otIp6Address, public Equatable<Address>, public Clearable<Address>
{
    friend class Prefix;
    friend class InterfaceIdentifier;

public:
    static constexpr uint8_t kAloc16Mask = InterfaceIdentifier::kAloc16Mask; ///< The mask for ALOC16.

    static constexpr uint8_t kSize = OT_IP6_ADDRESS_SIZE; ///< Size of an IPv6 Address (in bytes).

    static constexpr uint16_t kInfoStringSize = OT_IP6_ADDRESS_STRING_SIZE; ///< String Size for IPv6 address.

    // IPv6 Address Scopes
    static constexpr uint8_t kNodeLocalScope      = 0;  ///< Node-Local scope
    static constexpr uint8_t kInterfaceLocalScope = 1;  ///< Interface-Local scope
    static constexpr uint8_t kLinkLocalScope      = 2;  ///< Link-Local scope
    static constexpr uint8_t kRealmLocalScope     = 3;  ///< Realm-Local scope
    static constexpr uint8_t kAdminLocalScope     = 4;  ///< Admin-Local scope
    static constexpr uint8_t kSiteLocalScope      = 5;  ///< Site-Local scope
    static constexpr uint8_t kOrgLocalScope       = 8;  ///< Organization-Local scope
    static constexpr uint8_t kGlobalScope         = 14; ///< Global scope

    /**
     * This enumeration defines IPv6 address type filter.
     *
     */
    enum TypeFilter : uint8_t
    {
        kTypeAny,                           ///< Accept any IPv6 address (unicast or multicast).
        kTypeUnicast,                       ///< Accept unicast IPv6 addresses only.
        kTypeMulticast,                     ///< Accept multicast IPv6 addresses only.
        kTypeMulticastLargerThanRealmLocal, ///< Accept multicast IPv6 addresses with scope larger than Realm Local.
    };

    /**
     * This type defines the fixed-length `String` object returned from `ToString()`.
     *
     */
    typedef String<kInfoStringSize> InfoString;

    /**
     * This method gets the IPv6 address as a pointer to a byte array.
     *
     * @returns A pointer to a byte array containing the IPv6 address.
     *
     */
    const uint8_t *GetBytes(void) const { return mFields.m8; }

    /**
     * This method sets the IPv6 address from a given byte array.
     *
     * @param[in] aBuffer    Pointer to an array containing the IPv6 address. `kSize` bytes from the buffer
     *                       are copied to form the IPv6 address.
     *
     */
    void SetBytes(const uint8_t *aBuffer) { memcpy(mFields.m8, aBuffer, kSize); }

    /**
     * This method indicates whether or not the IPv6 address is the Unspecified Address.
     *
     * @retval TRUE   If the IPv6 address is the Unspecified Address.
     * @retval FALSE  If the IPv6 address is not the Unspecified Address.
     *
     */
    bool IsUnspecified(void) const;

    /**
     * This method indicates whether or not the IPv6 address is the Loopback Address.
     *
     * @retval TRUE   If the IPv6 address is the Loopback Address.
     * @retval FALSE  If the IPv6 address is not the Loopback Address.
     *
     */
    bool IsLoopback(void) const;

    /**
     * This method indicates whether or not the IPv6 address scope is Link-Local.
     *
     * @retval TRUE   If the IPv6 address scope is Link-Local.
     * @retval FALSE  If the IPv6 address scope is not Link-Local.
     *
     */
    bool IsLinkLocal(void) const;

    /**
     * This methods sets the IPv6 address to a Link-Local address with Interface Identifier generated from a given
     * MAC Extended Address.
     *
     * @param[in]  aExtAddress  A MAC Extended Address (used to generate the IID).
     *
     */
    void SetToLinkLocalAddress(const Mac::ExtAddress &aExtAddress);

    /**
     * This methods sets the IPv6 address to a Link-Local address with a given Interface Identifier.
     *
     * @param[in]  aIid   An Interface Identifier.
     *
     */
    void SetToLinkLocalAddress(const InterfaceIdentifier &aIid);

    /**
     * This method indicates whether or not the IPv6 address is multicast address.
     *
     * @retval TRUE   If the IPv6 address is a multicast address.
     * @retval FALSE  If the IPv6 address scope is not a multicast address.
     *
     */
    bool IsMulticast(void) const { return mFields.m8[0] == 0xff; }

    /**
     * This method indicates whether or not the IPv6 address is a link-local multicast address.
     *
     * @retval TRUE   If the IPv6 address is a link-local multicast address.
     * @retval FALSE  If the IPv6 address scope is not a link-local multicast address.
     *
     */
    bool IsLinkLocalMulticast(void) const;

    /**
     * This method indicates whether or not the IPv6 address is a link-local all nodes multicast address (ff02::01).
     *
     * @retval TRUE   If the IPv6 address is a link-local all nodes multicast address.
     * @retval FALSE  If the IPv6 address is not a link-local all nodes multicast address.
     *
     */
    bool IsLinkLocalAllNodesMulticast(void) const;

    /**
     * This method sets the IPv6 address to the link-local all nodes multicast address (ff02::01).
     *
     */
    void SetToLinkLocalAllNodesMulticast(void);

    /**
     * This method indicates whether or not the IPv6 address is a link-local all routers multicast address (ff02::02).
     *
     * @retval TRUE   If the IPv6 address is a link-local all routers multicast address.
     * @retval FALSE  If the IPv6 address is not a link-local all routers multicast address.
     *
     */
    bool IsLinkLocalAllRoutersMulticast(void) const;

    /**
     * This method sets the IPv6 address to the link-local all routers multicast address (ff02::02).
     *
     */
    void SetToLinkLocalAllRoutersMulticast(void);

    /**
     * This method indicates whether or not the IPv6 address is a realm-local multicast address.
     *
     * @retval TRUE   If the IPv6 address is a realm-local multicast address.
     * @retval FALSE  If the IPv6 address scope is not a realm-local multicast address.
     *
     */
    bool IsRealmLocalMulticast(void) const;

    /**
     * This method indicates whether or not the IPv6 address is a realm-local all nodes multicast address (ff03::01).
     *
     * @retval TRUE   If the IPv6 address is a realm-local all nodes multicast address.
     * @retval FALSE  If the IPv6 address is not a realm-local all nodes multicast address.
     *
     */
    bool IsRealmLocalAllNodesMulticast(void) const;

    /**
     * This method sets the IPv6 address to the realm-local all nodes multicast address (ff03::01)
     *
     */
    void SetToRealmLocalAllNodesMulticast(void);

    /**
     * This method indicates whether or not the IPv6 address is a realm-local all routers multicast address (ff03::02).
     *
     * @retval TRUE   If the IPv6 address is a realm-local all routers multicast address.
     * @retval FALSE  If the IPv6 address is not a realm-local all routers multicast address.
     *
     */
    bool IsRealmLocalAllRoutersMulticast(void) const;

    /**
     * This method sets the IPv6 address to the realm-local all routers multicast address (ff03::02).
     *
     */
    void SetToRealmLocalAllRoutersMulticast(void);

    /**
     * This method indicates whether or not the IPv6 address is a realm-local all MPL forwarders address (ff03::fc).
     *
     * @retval TRUE   If the IPv6 address is a realm-local all MPL forwarders address.
     * @retval FALSE  If the IPv6 address is not a realm-local all MPL forwarders address.
     *
     */
    bool IsRealmLocalAllMplForwarders(void) const;

    /**
     * This method sets the the IPv6 address to the realm-local all MPL forwarders address (ff03::fc).
     *
     */
    void SetToRealmLocalAllMplForwarders(void);

    /**
     * This method indicates whether or not the IPv6 address is multicast larger than realm local.
     *
     * @retval TRUE   If the IPv6 address is multicast larger than realm local.
     * @retval FALSE  If the IPv6 address is not multicast or the scope is not larger than realm local.
     *
     */
    bool IsMulticastLargerThanRealmLocal(void) const;

    /**
     * This method sets the IPv6 address to a Routing Locator (RLOC) IPv6 address with a given Network Prefix and
     * RLOC16 value.
     *
     * @param[in]  aNetworkPrefix    A Network Prefix.
     * @param[in]  aRloc16           A RLOC16 value.
     *
     */
    void SetToRoutingLocator(const NetworkPrefix &aNetworkPrefix, uint16_t aRloc16)
    {
        SetToLocator(aNetworkPrefix, aRloc16);
    }

    /**
     * This method sets the IPv6 address to a Anycast Locator (ALOC) IPv6 address with a given Network Prefix and
     * ALOC16 value.
     *
     * @param[in]  aNetworkPrefix    A Network Prefix.
     * @param[in]  aAloc16           A ALOC16 value.
     *
     */
    void SetToAnycastLocator(const NetworkPrefix &aNetworkPrefix, uint16_t aAloc16)
    {
        SetToLocator(aNetworkPrefix, aAloc16);
    }

    /**
     * This method returns the Network Prefix of the IPv6 address (most significant 64 bits of the address).
     *
     * @returns A reference to the Network Prefix.
     *
     */
    const NetworkPrefix &GetPrefix(void) const
    {
        return static_cast<const NetworkPrefix &>(mFields.mComponents.mNetworkPrefix);
    }

    /**
     * This method gets a prefix of the IPv6 address with a given length.
     *
     * @param[in]  aLength  The length of prefix in bits.
     * @param[out] aPrefix  A reference to a prefix to output the fetched prefix.
     *
     */
    void GetPrefix(uint8_t aLength, Prefix &aPrefix) const { aPrefix.Set(mFields.m8, aLength); }

    /**
     * This method indicates whether the IPv6 address matches a given prefix.
     *
     * @param[in] aPrefix  An IPv6 prefix to match with.
     *
     * @retval TRUE   The IPv6 address matches the @p aPrefix.
     * @retval FALSE  The IPv6 address does not match the @p aPrefix.
     *
     */
    bool MatchesPrefix(const Prefix &aPrefix) const;

    /**
     * This method indicates whether the IPv6 address matches a given prefix.
     *
     * @param[in]  aPrefix         A buffer containing the prefix.
     * @param[in]  aPrefixLength   The prefix length (in bits).
     *
     * @retval TRUE   The IPv6 address matches the @p aPrefix.
     * @retval FALSE  The IPv6 address does not match the @p aPrefix.
     *
     */
    bool MatchesPrefix(const uint8_t *aPrefix, uint8_t aPrefixLength) const;

    /**
     * This method sets the IPv6 address prefix.
     *
     * This method only changes the first @p aPrefixLength bits of the address and keeps the rest of the bits in the
     * address as before.
     *
     * @param[in]  aPrefix         A buffer containing the prefix.
     * @param[in]  aPrefixLength   The prefix length (in bits).
     *
     */
    void SetPrefix(const uint8_t *aPrefix, uint8_t aPrefixLength) { CopyBits(mFields.m8, aPrefix, aPrefixLength); }

    /**
     * This method sets the IPv6 address prefix to the given Network Prefix.
     *
     * @param[in]  aNetworkPrefix   A Network Prefix.
     *
     */
    void SetPrefix(const NetworkPrefix &aNetworkPrefix);

    /**
     * This method sets the IPv6 address prefix.
     *
     * This method only changes the initial prefix length bits of the IPv6 address and keeps the rest of the bits in
     * the address as before.
     *
     * @param[in]  aPrefix         An IPv6 prefix.
     *
     */
    void SetPrefix(const Prefix &aPrefix);

    /**
     * This method sets the prefix content of the Prefix-Based Multicast Address.
     *
     * @param[in]  aPrefix         A buffer containing the prefix.
     * @param[in]  aPrefixLength   The prefix length (in bits).
     *
     */
    void SetMulticastNetworkPrefix(const uint8_t *aPrefix, uint8_t aPrefixLength);

    /**
     * This method sets the prefix content of Prefix-Based Multicast Address.
     *
     * @param[in]  aNetworkPrefix   A reference to a Network Prefix.
     *
     */
    void SetMulticastNetworkPrefix(const NetworkPrefix &aNetworkPrefix)
    {
        SetMulticastNetworkPrefix(aNetworkPrefix.m8, NetworkPrefix::kLength);
    }

    /**
     * This method sets the prefix content of Prefix-Based Multicast Address.
     *
     * @param[in]  aPrefix  An IPv6 Prefix.
     *
     */
    void SetMulticastNetworkPrefix(const Prefix &aPrefix)
    {
        SetMulticastNetworkPrefix(aPrefix.GetBytes(), aPrefix.GetLength());
    }

    /**
     * This method returns the Interface Identifier of the IPv6 address.
     *
     * @returns A reference to the Interface Identifier.
     *
     */
    const InterfaceIdentifier &GetIid(void) const
    {
        return static_cast<const InterfaceIdentifier &>(mFields.mComponents.mIid);
    }

    /**
     * This method returns the Interface Identifier of the IPv6 address.
     *
     * @returns A reference to the Interface Identifier.
     *
     */
    InterfaceIdentifier &GetIid(void) { return static_cast<InterfaceIdentifier &>(mFields.mComponents.mIid); }

    /**
     * This method sets the Interface Identifier.
     *
     * @param[in]  aIid  An Interface Identifier.
     *
     */
    void SetIid(const InterfaceIdentifier &aIid) { GetIid() = aIid; }

    /**
     * This method returns the IPv6 address scope.
     *
     * @returns The IPv6 address scope.
     *
     */
    uint8_t GetScope(void) const;

    /**
     * This method returns the number of IPv6 prefix bits that match.
     *
     * @param[in]  aOther  The IPv6 address to match against.
     *
     * @returns The number of IPv6 prefix bits that match.
     *
     */
    uint8_t PrefixMatch(const Address &aOther) const;

    /**
     * This method indicates whether address matches a given type filter.
     *
     * @param[in] aFilter   An address type filter.
     *
     * @retval TRUE   The address matches @p aFilter.
     * @retval FALSE  The address does not match @p aFilter.
     *
     */
    bool MatchesFilter(TypeFilter aFilter) const;

    /**
     * This method sets the IPv6 address by performing NAT64 address translation from a given IPv4 address as specified
     * in RFC 6052.
     *
     * The NAT64 @p aPrefix MUST have one of the following lengths: 32, 40, 48, 56, 64, or 96, otherwise the behavior
     * of this method is undefined.
     *
     * @param[in] aPrefix      The prefix to use for IPv4/IPv6 translation.
     * @param[in] aIp4Address  The IPv4 address to translate to IPv6.
     *
     */
    void SynthesizeFromIp4Address(const Prefix &aPrefix, const Ip4::Address &aIp4Address);

    /**
     * This method converts an IPv6 address string to binary.
     *
     * @param[in]  aString  A pointer to the null-terminated string.
     *
     * @retval kErrorNone          Successfully parsed the IPv6 address string.
     * @retval kErrorParse         Failed to parse the IPv6 address string.
     *
     */
    Error FromString(const char *aString);

    /**
     * This method converts the IPv6 address to a string.
     *
     * The IPv6 address string is formatted as 16 hex values separated by ':' (i.e., "%x:%x:%x:...:%x").
     *
     * @returns An `InfoString` representing the IPv6 address.
     *
     */
    InfoString ToString(void) const;

    /**
     * This method convert the IPv6 address to a C string.
     *
     * The IPv6 address string is formatted as 16 hex values separated by ':' (i.e., "%x:%x:%x:...:%x").
     *
     * If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be
     * truncated but the outputted string is always null-terminated.
     *
     * @param[out] aBuffer   A pointer to a char array to output the string (MUST NOT be `nullptr`).
     * @param[in]  aSize     The size of @p aBuffer (in bytes).
     *
     */
    void ToString(char *aBuffer, uint16_t aSize) const;

    /**
     * This method overloads operator `<` to compare two IPv6 addresses.
     *
     * @param[in] aOther  The other IPv6 address to compare with.
     *
     * @retval true   The IPv6 address is smaller than @p aOther.
     * @retval false  The IPv6 address is larger than or equal to @p aOther.
     *
     */
    bool operator<(const Address &aOther) const { return memcmp(mFields.m8, aOther.mFields.m8, sizeof(Address)) < 0; }

private:
    static constexpr uint8_t kMulticastNetworkPrefixLengthOffset = 3; // Prefix-Based Multicast Address (RFC3306)
    static constexpr uint8_t kMulticastNetworkPrefixOffset       = 4; // Prefix-Based Multicast Address (RFC3306)

    void SetToLocator(const NetworkPrefix &aNetworkPrefix, uint16_t aLocator);
    void ToString(StringWriter &aWriter) const;
    void AppendHexWords(StringWriter &aWriter, uint8_t aLength) const;

    static const Address &GetLinkLocalAllNodesMulticast(void);
    static const Address &GetLinkLocalAllRoutersMulticast(void);
    static const Address &GetRealmLocalAllNodesMulticast(void);
    static const Address &GetRealmLocalAllRoutersMulticast(void);
    static const Address &GetRealmLocalAllMplForwarders(void);

    static void CopyBits(uint8_t *aDst, const uint8_t *aSrc, uint8_t aNumBits);

} OT_TOOL_PACKED_END;

/**
 * @}
 *
 */

} // namespace Ip6

DefineCoreType(otIp6NetworkPrefix, Ip6::NetworkPrefix);
DefineCoreType(otIp6Prefix, Ip6::Prefix);
DefineCoreType(otIp6InterfaceIdentifier, Ip6::InterfaceIdentifier);
DefineCoreType(otIp6Address, Ip6::Address);

} // namespace ot

#endif // IP6_ADDRESS_HPP_


text:
#include <zephyr.h>
#include <drivers/flash.h>
#include <storage/flash_map.h>
#include <device.h>
#include <stdio.h>

#ifdef CONFIG_TRUSTED_EXECUTION_NONSECURE
#define FLASH_TEST_OFFSET FLASH_AREA_OFFSET(image_1_nonsecure)
#else
#define FLASH_TEST_OFFSET FLASH_AREA_OFFSET(image_1)
#endif

#define FLASH_PAGE_SIZE   4096
#define TEST_DATA_WORD_0  0x1122
#define TEST_DATA_WORD_1  0xaabb
#define TEST_DATA_WORD_2  0xabcd
#define TEST_DATA_WORD_3  0x1234

#define FLASH_TEST_OFFSET2 0x41234
#define FLASH_TEST_PAGE_IDX 37

void main(void)
{
	const struct device *flash_dev;
	uint32_t buf_array_1[4] = { TEST_DATA_WORD_0, TEST_DATA_WORD_1,
				    TEST_DATA_WORD_2, TEST_DATA_WORD_3 };
	uint32_t buf_array_2[4] = { TEST_DATA_WORD_3, TEST_DATA_WORD_1,
				    TEST_DATA_WORD_2, TEST_DATA_WORD_0 };
	uint32_t buf_array_3[8] = { TEST_DATA_WORD_0, TEST_DATA_WORD_1,
				    TEST_DATA_WORD_2, TEST_DATA_WORD_3,
				    TEST_DATA_WORD_0, TEST_DATA_WORD_1,
				    TEST_DATA_WORD_2, TEST_DATA_WORD_3 };
	uint32_t buf_word = 0U;
	uint32_t i, offset;

	printf("\nNordic nRF5 Flash Testing\n");
	printf("=========================\n");

	flash_dev =
		device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL);

	if (!flash_dev) {
		printf("Nordic nRF5 flash driver was not found!\n");
		return;
	}

	printf("\nTest 1: Flash erase page at 0x%x\n", FLASH_TEST_OFFSET);
	if (flash_erase(flash_dev, FLASH_TEST_OFFSET, FLASH_PAGE_SIZE) != 0) {
		printf("   Flash erase failed!\n");
	} else {
		printf("   Flash erase succeeded!\n");
	}

	printf("\nTest 2: Flash write (word array 1)\n");
	for (i = 0U; i < ARRAY_SIZE(buf_array_1); i++) {
		offset = FLASH_TEST_OFFSET + (i << 2);
		printf("   Attempted to write %x at 0x%x\n", buf_array_1[i],
				offset);
		if (flash_write(flash_dev, offset, &buf_array_1[i],
					sizeof(uint32_t)) != 0) {
			printf("   Flash write failed!\n");
			return;
		}
		printf("   Attempted to read 0x%x\n", offset);
		if (flash_read(flash_dev, offset, &buf_word,
					sizeof(uint32_t)) != 0) {
			printf("   Flash read failed!\n");
			return;
		}
		printf("   Data read: %x\n", buf_word);
		if (buf_array_1[i] == buf_word) {
			printf("   Data read matches data written. Good!\n");
		} else {
			printf("   Data read does not match data written!\n");
		}
	}

	offset = FLASH_TEST_OFFSET - FLASH_PAGE_SIZE * 2;
	printf("\nTest 3: Flash erase (4 pages at 0x%x)\n", offset);
	if (flash_erase(flash_dev, offset, FLASH_PAGE_SIZE * 4) != 0) {
		printf("   Flash erase failed!\n");
	} else {
		printf("   Flash erase succeeded!\n");
	}

	printf("\nTest 4: Flash write (word array 2)\n");
	for (i = 0U; i < ARRAY_SIZE(buf_array_2); i++) {
		offset = FLASH_TEST_OFFSET + (i << 2);
		printf("   Attempted to write %x at 0x%x\n", buf_array_2[i],
				offset);
		if (flash_write(flash_dev, offset, &buf_array_2[i],
					sizeof(uint32_t)) != 0) {
			printf("   Flash write failed!\n");
			return;
		}
		printf("   Attempted to read 0x%x\n", offset);
		if (flash_read(flash_dev, offset, &buf_word,
					sizeof(uint32_t)) != 0) {
			printf("   Flash read failed!\n");
			return;
		}
		printf("   Data read: %x\n", buf_word);
		if (buf_array_2[i] == buf_word) {
			printf("   Data read matches data written. Good!\n");
		} else {
			printf("   Data read does not match data written!\n");
		}
	}

	printf("\nTest 5: Flash erase page at 0x%x\n", FLASH_TEST_OFFSET);
	if (flash_erase(flash_dev, FLASH_TEST_OFFSET, FLASH_PAGE_SIZE) != 0) {
		printf("   Flash erase failed!\n");
	} else {
		printf("   Flash erase succeeded!\n");
	}

	printf("\nTest 6: Non-word aligned write (word array 3)\n");
	for (i = 0U; i < ARRAY_SIZE(buf_array_3); i++) {
		offset = FLASH_TEST_OFFSET + (i << 2) + 1;
		printf("   Attempted to write %x at 0x%x\n", buf_array_3[i],
				offset);
		if (flash_write(flash_dev, offset, &buf_array_3[i],
					sizeof(uint32_t)) != 0) {
			printf("   Flash write failed!\n");
			return;
		}
		printf("   Attempted to read 0x%x\n", offset);
		if (flash_read(flash_dev, offset, &buf_word,
					sizeof(uint32_t)) != 0) {
			printf("   Flash read failed!\n");
			return;
		}
		printf("   Data read: %x\n", buf_word);
		if (buf_array_3[i] == buf_word) {
			printf("   Data read matches data written. Good!\n");
		} else {
			printf("   Data read does not match data written!\n");
		}
	}

#if defined(CONFIG_FLASH_PAGE_LAYOUT)
	struct flash_pages_info info;
	int rc;

	rc = flash_get_page_info_by_offs(flash_dev, FLASH_TEST_OFFSET2, &info);

	printf("\nTest 7: Page layout API\n");

	if (!rc) {
		printf("   Offset  0x%08x:\n", FLASH_TEST_OFFSET2);
		printf("     belongs to the page %u of start offset 0x%08x\n",
		       info.index, info.start_offset);
		printf("     and the size of 0x%08x B.\n", info.size);
	} else {
		printf("   Error: flash_get_page_info_by_offs returns %d\n",
		       rc);
	}

	rc = flash_get_page_info_by_idx(flash_dev, FLASH_TEST_PAGE_IDX, &info);

	if (!rc) {
		printf("   Page of number %u has start offset 0x%08x\n",
		       FLASH_TEST_PAGE_IDX,
		       info.start_offset);
		printf("     and size of 0x%08x B.\n", info.size);
		if (info.index == FLASH_TEST_PAGE_IDX) {
			printf("     Page index resolved properly\n");
		} else {
			printf("     ERROR: Page index resolved to %u\n",
			       info.index);
		}

	} else {
		printf("   Error: flash_get_page_info_by_idx returns %d\n", rc);
	}

	printf("   SoC flash consists of %u pages.\n",
	       flash_get_page_count(flash_dev));

#endif

	printf("\nTest 8: Write block size API\n");
	printf("   write-block-size = %u\n",
	       flash_get_write_block_size(flash_dev));
}


text:
package com.amazonaws.services.forecast.model.transform;

import java.util.List;
import javax.annotation.Generated;

import com.amazonaws.SdkClientException;
import com.amazonaws.services.forecast.model.*;

import com.amazonaws.protocol.*;
import com.amazonaws.annotation.SdkInternalApi;

/**
 * PredictorExecutionMarshaller
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
@SdkInternalApi
public class PredictorExecutionMarshaller {

    private static final MarshallingInfo<String> ALGORITHMARN_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("AlgorithmArn").build();
    private static final MarshallingInfo<List> TESTWINDOWS_BINDING = MarshallingInfo.builder(MarshallingType.LIST).marshallLocation(MarshallLocation.PAYLOAD)
            .marshallLocationName("TestWindows").build();

    private static final PredictorExecutionMarshaller instance = new PredictorExecutionMarshaller();

    public static PredictorExecutionMarshaller getInstance() {
        return instance;
    }

    /**
     * Marshall the given parameter object.
     */
    public void marshall(PredictorExecution predictorExecution, ProtocolMarshaller protocolMarshaller) {

        if (predictorExecution == null) {
            throw new SdkClientException("Invalid argument passed to marshall(...)");
        }

        try {
            protocolMarshaller.marshall(predictorExecution.getAlgorithmArn(), ALGORITHMARN_BINDING);
            protocolMarshaller.marshall(predictorExecution.getTestWindows(), TESTWINDOWS_BINDING);
        } catch (Exception e) {
            throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
        }
    }

}


text:
#if FUSION_MAX_VECTOR_SIZE <= 10
#include <boost/fusion/container/vector/detail/preprocessed/as_vector10.hpp>
#elif FUSION_MAX_VECTOR_SIZE <= 20
#include <boost/fusion/container/vector/detail/preprocessed/as_vector20.hpp>
#elif FUSION_MAX_VECTOR_SIZE <= 30
#include <boost/fusion/container/vector/detail/preprocessed/as_vector30.hpp>
#elif FUSION_MAX_VECTOR_SIZE <= 40
#include <boost/fusion/container/vector/detail/preprocessed/as_vector40.hpp>
#elif FUSION_MAX_VECTOR_SIZE <= 50
#include <boost/fusion/container/vector/detail/preprocessed/as_vector50.hpp>
#else
#error "FUSION_MAX_VECTOR_SIZE out of bounds for preprocessed headers"
#endif


text:
package com.thoughtworks.go.server.service;

import com.thoughtworks.go.config.CaseInsensitiveString;
import com.thoughtworks.go.config.CruiseConfig;
import com.thoughtworks.go.config.PipelineConfig;
import com.thoughtworks.go.domain.PipelinePauseInfo;
import com.thoughtworks.go.i18n.LocalizedMessage;
import com.thoughtworks.go.server.dao.PipelineSqlMapDao;
import com.thoughtworks.go.server.domain.Username;
import com.thoughtworks.go.server.service.result.DefaultLocalizedOperationResult;
import com.thoughtworks.go.server.service.result.LocalizedOperationResult;
import com.thoughtworks.go.server.util.UserHelper;
import com.thoughtworks.go.serverhealth.HealthStateScope;
import com.thoughtworks.go.serverhealth.HealthStateType;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PipelinePauseService {

    private PipelineSqlMapDao pipelineSqlMapDao;
    private final GoConfigService goConfigService;
    private final SecurityService securityService;

    private static final Logger LOGGER = LoggerFactory.getLogger(PipelinePauseService.class);

    @Autowired
    public PipelinePauseService(PipelineSqlMapDao pipelineSqlMapDao, GoConfigService goConfigService, SecurityService securityService) {
        this.pipelineSqlMapDao = pipelineSqlMapDao;
        this.goConfigService = goConfigService;
        this.securityService = securityService;
    }

    public void pause(String pipelineName, String pauseCause, Username userName) {
        pause(pipelineName, pauseCause, userName, new DefaultLocalizedOperationResult());
    }

    public void pause(String pipelineName, String pauseCause, Username pausedBy, LocalizedOperationResult result) {
        String pauseByUserName = pausedBy == null ? "" : pausedBy.getUsername().toString();
        if (pipelineDoesNotExist(pipelineName, result) || notAuthorized(pipelineName, pauseByUserName, result)) {
            return;
        }
        if (StringUtils.isBlank(pauseCause)) {
            pauseCause = "";
        }
        try {
            pausePipeline(pipelineName, pauseCause, pausedBy);
        } catch (Exception e) {
            LOGGER.error("[Pipeline Pause] Failed to pause pipeline", e);
            result.internalServerError(LocalizedMessage.string("INTERNAL_SERVER_ERROR"));
        }
    }

    private void pausePipeline(String pipelineName, String pauseCause, Username pauseBy) {
        String mutexPipelineName = mutexForPausePipeline(pipelineName);
        synchronized (mutexPipelineName) {
            String sanitizedPauseCause = pauseCause.substring(0, Math.min(255, pauseCause.length()));
            String pauseByDisplayName = pauseBy.getDisplayName();
            String sanitizedPauseBy = pauseByDisplayName.substring(0, Math.min(255, pauseByDisplayName.length()));
            pipelineSqlMapDao.pause(pipelineName, sanitizedPauseCause, sanitizedPauseBy);
            LOGGER.info("[Pipeline Pause] Pipeline [{}] is paused by [{}] because [{}]", pipelineName, pauseBy, pauseCause);
        }
    }

    private boolean notAuthorized(String pipelineName, String pauseBy, LocalizedOperationResult result) {
        CruiseConfig cruiseConfig = goConfigService.getCurrentConfig();
        PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
        if (securityService.hasOperatePermissionForGroup(new CaseInsensitiveString(pauseBy), cruiseConfig.findGroupOfPipeline(pipelineConfig).getGroup())) {
            return false;
        }
        result.unauthorized(LocalizedMessage.string("UNAUTHORIZED_TO_EDIT_PIPELINE", pipelineName), HealthStateType.unauthorisedForPipeline(pipelineName));
        return true;
    }

    private boolean pipelineDoesNotExist(String pipelineName, LocalizedOperationResult result) {
        CruiseConfig cruiseConfig = goConfigService.getCurrentConfig();
        if (cruiseConfig.hasPipelineNamed(new CaseInsensitiveString(pipelineName))) {
            return false;
        }
        result.notFound(LocalizedMessage.string("RESOURCE_NOT_FOUND", "pipeline", pipelineName), HealthStateType.general(HealthStateScope.forPipeline(pipelineName)));
        return true;
    }

    public void unpause(String pipelineName) {
        unpause(pipelineName, UserHelper.getUserName(), new DefaultLocalizedOperationResult());
    }

    public void unpause(String pipelineName, Username unpausedBy, LocalizedOperationResult result) {
        String unpauseByUserName = unpausedBy == null ? "" : unpausedBy.getUsername().toString();
        if (pipelineDoesNotExist(pipelineName, result) || notAuthorized(pipelineName, unpauseByUserName, result)) {
            return;
        }
        try {
            unpausePipeline(pipelineName, unpausedBy);
        } catch (Exception e) {
            LOGGER.error("[Pipeline Unpause] Failed to unpause pipeline", e);
            result.internalServerError(LocalizedMessage.string("INTERNAL_SERVER_ERROR"));
        }
    }

    private void unpausePipeline(String pipelineName, Username unpausedBy) {
        String mutextPipelineName = mutexForPausePipeline(pipelineName);
        synchronized (mutextPipelineName) {
            pipelineSqlMapDao.unpause(pipelineName);
            LOGGER.info("[Pipeline Unpause] Pipeline [{}] is unpaused by [{}]", pipelineName, unpausedBy);
        }
    }

    public PipelinePauseInfo pipelinePauseInfo(String pipelineName) {
        PipelinePauseInfo pipelinePauseInfo = pipelineSqlMapDao.pauseState(pipelineName);
        return pipelinePauseInfo == null ? PipelinePauseInfo.notPaused() : pipelinePauseInfo;
    }

    public boolean isPaused(String pipelineName) {
        return pipelinePauseInfo(pipelineName).isPaused();
    }

    /*
     * Mutex shared between PipelinePauseService and PipelineService. This is to avoid constraint violation when
     * updateCounter() and pause() are trying to insert pipeline row if one doesn't exist
     */
    public static String mutexForPausePipeline(String pipelineName) {
        return (PipelineSqlMapDao.class.getName() + "_mutexForPausePipeline_" + pipelineName).intern();
    }
}


text:
import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.math.BigInteger;

public class Set1Chapter6 {

    public static void main(String[] args) throws Exception {
        String base64input = readFile6();
        String asciiInput = new String(Base64.getDecoder().decode(base64input));

        int keySize = BasicCrypto.autoGetKeySize(asciiInput.toCharArray());
        System.out.println("GOT KEY SIZE! keysize = " + keySize);

        String guessedKey = BasicCrypto.autoGuessRepeatedKey(asciiInput.toCharArray(), keySize);
        System.out.println("GOT KEY! key = '" + guessedKey + "'");

        System.out.println("---------------------------");

        System.out.println(BasicCrypto.decryptRepeatingXor(BasicCrypto.ascii2hex(asciiInput), guessedKey));
    }

    public static void hammingTest() {
        String test1 = new String("this is a test");
        String test2 = new String("wokka wokka!!!");

        System.out.println(BasicCrypto.hamming(test1.toCharArray(), test2.toCharArray()));
    }

    public static String readFile6() throws FileNotFoundException {
        StringBuilder sb = new StringBuilder();

        Scanner scn = new Scanner(new File("./dat/6.txt"));
        while(scn.hasNextLine()) {
            sb.append(scn.nextLine());
        }
        scn.close();

        return sb.toString();
    }
}


text:
package com.intellij.ide.todo;

import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.ui.content.Content;
import org.jetbrains.annotations.NotNull;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

abstract class CurrentFileTodosPanel extends TodoPanel {
  CurrentFileTodosPanel(Project project, TodoPanelSettings settings, Content content) {
    super(project, settings, true, content);

    VirtualFile[] files = FileEditorManager.getInstance(project).getSelectedFiles();
    setFile(files.length == 0 ? null : PsiManager.getInstance(myProject).findFile(files[0]));
    // It's important to remove this listener. It prevents invocation of setFile method after the tree builder is disposed
    project.getMessageBus().connect(this).subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
      @Override
      public void selectionChanged(@NotNull FileEditorManagerEvent e) {
        VirtualFile file = e.getNewFile();
        final PsiFile psiFile = file != null && file.isValid() ? PsiManager.getInstance(myProject).findFile(file) : null;
        // This invokeLater is required. The problem is setFile does a commit to PSI, but setFile is
        // invoked inside PSI change event. It causes an Exception like "Changes to PSI are not allowed inside event processing"
        DumbService.getInstance(myProject).smartInvokeLater(() -> setFile(psiFile));
      }
    });
  }

  private void setFile(PsiFile file) {
    // setFile method is invoked in LaterInvocator so PsiManager
    // can be already disposed, so we need to check this before using it.
    if (myProject == null || PsiManager.getInstance(myProject).isDisposed()) {
      return;
    }

    if (file != null && getSelectedFile() == file) return;

    CurrentFileTodosTreeBuilder builder = (CurrentFileTodosTreeBuilder)myTodoTreeBuilder;
    builder.setFile(file);
    if (myTodoTreeBuilder.isUpdatable()) {
      Object selectableElement = builder.getTodoTreeStructure().getFirstSelectableElement();
      if (selectableElement != null) {
        builder.buildNodeForElement(selectableElement);
        DefaultMutableTreeNode node = builder.getNodeForElement(selectableElement);
        LOG.assertTrue(node != null);
        myTodoTreeBuilder.getTree().getSelectionModel().setSelectionPath(new TreePath(node.getPath()));
      }
    }
  }
}


text:
package net.mybluemix.model;

public class Dengon {
	private String teamNum;
	private String myNum;
	private String[] choiceNum;

	public String getTeamNum() {
		return teamNum;
	}

	public void setTeamNum(String teamNum) {
		this.teamNum = teamNum;
	}

	public String getMyNum() {
		return myNum;
	}

	public void setMyNum(String myNum) {
		this.myNum = myNum;
	}

	public String[] getChoiceNum() {
		return choiceNum;
	}

	public void setChoiceNum(String[] choiceNum) {
		this.choiceNum = choiceNum;
	}

}