A command that returns a list of results

Introduced properties

type ITEM: Object

nitc :: CmdList :: ITEM

Type of result
private var _count: nullable Int

nitc :: CmdList :: _count

Total number of ret
private var _limit: nullable Int

nitc :: CmdList :: _limit

Limit the items in the list
private var _max: nullable Int

nitc :: CmdList :: _max

Total number of pages
private var _page: nullable Int

nitc :: CmdList :: _page

Page to display
private var _results: nullable Array[ITEM]

nitc :: CmdList :: _results

Items in the list
private var _sorter: nullable Comparator

nitc :: CmdList :: _sorter

Comparator used to sort the list
fun count: nullable Int

nitc :: CmdList :: count

Total number of ret
fun count=(count: nullable Int)

nitc :: CmdList :: count=

Total number of ret
init defaultinit(model: Model, filter: nullable ModelFilter, limit: nullable Int, page: nullable Int, count: nullable Int, max: nullable Int)

nitc :: CmdList :: defaultinit

fun init_results: CmdMessage

nitc :: CmdList :: init_results

Initialize the results list
fun limit: nullable Int

nitc :: CmdList :: limit

Limit the items in the list
fun limit=(limit: nullable Int)

nitc :: CmdList :: limit=

Limit the items in the list
fun max: nullable Int

nitc :: CmdList :: max

Total number of pages
fun max=(max: nullable Int)

nitc :: CmdList :: max=

Total number of pages
fun page: nullable Int

nitc :: CmdList :: page

Page to display
fun page=(page: nullable Int)

nitc :: CmdList :: page=

Page to display
fun paginate

nitc :: CmdList :: paginate

Paginate the results
fun print_list(list_title: nullable String, list_items: nullable Array[MEntity], no_color: nullable Bool)

nitc :: CmdList :: print_list

fun results: nullable Array[ITEM]

nitc :: CmdList :: results

Items in the list
fun results=(results: nullable Array[ITEM])

nitc :: CmdList :: results=

Items in the list
fun sort

nitc :: CmdList :: sort

Sort mentities with sorter
fun sorter: nullable Comparator

nitc :: CmdList :: sorter

Comparator used to sort the list
fun sorter=(sorter: nullable Comparator)

nitc :: CmdList :: sorter=

Comparator used to sort the list

Redefined properties

redef type SELF: CmdList

nitc $ CmdList :: SELF

Type of this instance, automatically specialized in every class
redef fun http_init(req: HttpRequest): CmdMessage

nitc :: commands_http $ CmdList :: http_init

Init the command from an HTTPRequest
redef fun init_command: CmdMessage

nitc $ CmdList :: init_command

init_command is used to factorize the sorting and pagination of results
redef fun parser_init(mentity_name: String, options: CmdOptions): CmdMessage

nitc :: commands_parser $ CmdList :: parser_init

Initialize the command from the CommandParser data
redef fun to_json: nullable Serializable

nitc :: json_commands $ CmdList :: to_json

Return a JSON Serializable representation of self results

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type ITEM: Object

nitc :: CmdList :: ITEM

Type of result
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _count: nullable Int

nitc :: CmdList :: _count

Total number of ret
private var _filter: nullable ModelFilter

nitc :: DocCommand :: _filter

ModelFilter to apply if any
private var _limit: nullable Int

nitc :: CmdList :: _limit

Limit the items in the list
private var _max: nullable Int

nitc :: CmdList :: _max

Total number of pages
private var _model: Model

nitc :: DocCommand :: _model

Model to retrieve data for
private var _page: nullable Int

nitc :: CmdList :: _page

Page to display
private var _results: nullable Array[ITEM]

nitc :: CmdList :: _results

Items in the list
private var _sorter: nullable Comparator

nitc :: CmdList :: _sorter

Comparator used to sort the list
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun cmd_filter: ModelFilter

nitc :: DocCommand :: cmd_filter

Return a new filter for that command execution.
fun count: nullable Int

nitc :: CmdList :: count

Total number of ret
fun count=(count: nullable Int)

nitc :: CmdList :: count=

Total number of ret
init defaultinit(model: Model, filter: nullable ModelFilter)

nitc :: DocCommand :: defaultinit

init defaultinit(model: Model, filter: nullable ModelFilter, limit: nullable Int, page: nullable Int, count: nullable Int, max: nullable Int)

nitc :: CmdList :: defaultinit

abstract fun execute(no_color: nullable Bool)

nitc :: DocCommand :: execute

fun filter: nullable ModelFilter

nitc :: DocCommand :: filter

ModelFilter to apply if any
protected fun filter=(filter: nullable ModelFilter)

nitc :: DocCommand :: filter=

ModelFilter to apply if any
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun http_init(req: HttpRequest): CmdMessage

nitc :: DocCommand :: http_init

Init the command from an HTTPRequest
init init

core :: Object :: init

fun init_command: CmdMessage

nitc :: DocCommand :: init_command

Initialize the command
fun init_results: CmdMessage

nitc :: CmdList :: init_results

Initialize the results list
fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun limit: nullable Int

nitc :: CmdList :: limit

Limit the items in the list
fun limit=(limit: nullable Int)

nitc :: CmdList :: limit=

Limit the items in the list
fun max: nullable Int

nitc :: CmdList :: max

Total number of pages
fun max=(max: nullable Int)

nitc :: CmdList :: max=

Total number of pages
fun model: Model

nitc :: DocCommand :: model

Model to retrieve data for
protected fun model=(model: Model)

nitc :: DocCommand :: model=

Model to retrieve data for
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun page: nullable Int

nitc :: CmdList :: page

Page to display
fun page=(page: nullable Int)

nitc :: CmdList :: page=

Page to display
fun paginate

nitc :: CmdList :: paginate

Paginate the results
fun parser_init(arg: String, options: CmdOptions): CmdMessage

nitc :: DocCommand :: parser_init

Initialize the command from the CommandParser data
fun print_list(list_title: nullable String, list_items: nullable Array[MEntity], no_color: nullable Bool)

nitc :: CmdList :: print_list

fun results: nullable Array[ITEM]

nitc :: CmdList :: results

Items in the list
fun results=(results: nullable Array[ITEM])

nitc :: CmdList :: results=

Items in the list
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun sort

nitc :: CmdList :: sort

Sort mentities with sorter
fun sorter: nullable Comparator

nitc :: CmdList :: sorter

Comparator used to sort the list
fun sorter=(sorter: nullable Comparator)

nitc :: CmdList :: sorter=

Comparator used to sort the list
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun to_html: Writable

nitc :: DocCommand :: to_html

Render results as a HTML string
abstract fun to_json: nullable Serializable

nitc :: DocCommand :: to_json

Return a JSON Serializable representation of self results
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_md: Writable

nitc :: DocCommand :: to_md

Render results as a Markdown string
fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram nitc::CmdList CmdList nitc::DocCommand DocCommand nitc::CmdList->nitc::DocCommand core::Object Object nitc::DocCommand->core::Object ...core::Object ... ...core::Object->core::Object nitc::CmdEntities CmdEntities nitc::CmdEntities->nitc::CmdList nitc::CmdCatalogPackages CmdCatalogPackages nitc::CmdCatalogPackages->nitc::CmdEntities nitc::CmdSearch CmdSearch nitc::CmdSearch->nitc::CmdEntities nitc::CmdModelEntities CmdModelEntities nitc::CmdModelEntities->nitc::CmdEntities nitc::CmdEntityList CmdEntityList nitc::CmdEntityList->nitc::CmdEntities nitc::CmdCatalogPackages... ... nitc::CmdCatalogPackages...->nitc::CmdCatalogPackages nitc::CmdSearch... ... nitc::CmdSearch...->nitc::CmdSearch nitc::CmdModelEntities... ... nitc::CmdModelEntities...->nitc::CmdModelEntities nitc::CmdEntityList... ... nitc::CmdEntityList...->nitc::CmdEntityList

Ancestors

interface Object

core :: Object

The root of the class hierarchy.

Parents

abstract class DocCommand

nitc :: DocCommand

Documentation command

Children

abstract class CmdEntities

nitc :: CmdEntities

A list of mentities

Descendants

class CmdAllProps

nitc :: CmdAllProps

TODO remove once the filters/sorters are merged
class CmdAncestors

nitc :: CmdAncestors

MEntity ancestors command
class CmdCall

nitc :: CmdCall

Retrieve all the mproperties that call mentity
class CmdCatalogContributing

nitc :: CmdCatalogContributing

Retrieve the packages contributed by a person
class CmdCatalogMaintaining

nitc :: CmdCatalogMaintaining

Retrieve the packages maintained by a person
class CmdCatalogPackages

nitc :: CmdCatalogPackages

Retrieve the packages in the catalog
class CmdCatalogSearch

nitc :: CmdCatalogSearch

A CmdSearch command using a Catalog
class CmdCatalogTag

nitc :: CmdCatalogTag

Retrieve the packages for a tag
class CmdChildren

nitc :: CmdChildren

MEntity children command
class CmdDescendants

nitc :: CmdDescendants

MEntity descendants command
abstract class CmdEntityList

nitc :: CmdEntityList

A command about a MEntity that returns a list of mentities
class CmdFeatures

nitc :: CmdFeatures

MEntity feature list
abstract class CmdInheritance

nitc :: CmdInheritance

An abstract inheritance command
class CmdIntros

nitc :: CmdIntros

TODO remove once the filters/sorters are merged
class CmdLinearization

nitc :: CmdLinearization

Linearization command
class CmdMains

nitc :: CmdMains

Cmd that finds the mains of an mentity
class CmdModelEntities

nitc :: CmdModelEntities

A command that returns a list of all mentities in a model
class CmdNew

nitc :: CmdNew

Retrieve all the mproperties that initialize mentity
class CmdParam

nitc :: CmdParam

Retrieve all the mproperties using mentity as a type for its parameters
class CmdParents

nitc :: CmdParents

MEntity parents command
class CmdRandomEntities

nitc :: CmdRandomEntities

A command that returns a random list of mentities from a model
class CmdRedefs

nitc :: CmdRedefs

TODO remove once the filters/sorters are merged
class CmdReturn

nitc :: CmdReturn

Retrieve all the mproperties that return somethinf of the mentity type.
class CmdSearch

nitc :: CmdSearch

A free text search command
class CmdTesting

nitc :: CmdTesting

Cmd that finds the nitunit command related to an mentity

Class definitions

nitc $ CmdList
# A command that returns a list of results
abstract class CmdList
	super DocCommand

	# Type of result
	type ITEM: Object

	# Limit the items in the list
	var limit: nullable Int = null is optional, writable

	# Page to display
	var page: nullable Int = null is optional, writable

	# Total number of ret
	var count: nullable Int = null is optional, writable

	# Total number of pages
	var max: nullable Int = null is optional, writable

	# Comparator used to sort the list
	var sorter: nullable Comparator = null is writable

	# Items in the list
	var results: nullable Array[ITEM] = null is writable

	# `init_command` is used to factorize the sorting and pagination of results
	#
	# See `init_results` for the result list initialization.
	redef fun init_command do
		var res = super
		if not res isa CmdSuccess then return res
		res = init_results
		if not res isa CmdSuccess then return res
		sort
		paginate
		return res
	end

	# Initialize the `results` list
	#
	# This method must be redefined by CmdList subclasses.
	fun init_results: CmdMessage do return new CmdSuccess

	# Sort `mentities` with `sorter`
	fun sort do
		var results = self.results
		if results == null then return
		var sorter = self.sorter
		if sorter == null then return
		sorter.sort(results)
	end

	# Paginate the results
	#
	# This methods keeps only a subset of `results` depending on the current `page` and the
	# number of elements to return set by `limit`.
	#
	# The `count` can be specified when `results` does not contain all the results.
	# For example when the results are already limited from a DB statement.
	fun paginate do
		var results = self.results
		if results == null then return

		var limit = self.limit
		if limit == null then return

		var page = self.page
		if page == null or page <= 0 then page = 1

		var count = self.count
		if count == null then count = results.length

		var max = count / limit
		if max == 0 then
			page = 1
			max = 1
		else if page > max then
			page = max
		end

		var lstart = (page - 1) * limit
		var lend = limit
		if lstart + lend > count then lend = count - lstart
		self.results = results.subarray(lstart, lend)
		self.max = max
		self.limit = limit
		self.page = page
		self.count = count
	end
end
src/doc/commands/commands_base.nit:217,1--306,3

nitc :: commands_parser $ CmdList
redef class CmdList
	redef fun parser_init(mentity_name, options) do
		var opt_page = options.opt_int("page")
		if opt_page != null then page = opt_page
		var opt_limit = options.opt_int("limit")
		if opt_limit != null then limit = opt_limit
		return super
	end
end
src/doc/commands/commands_parser.nit:291,1--299,3

nitc :: commands_http $ CmdList
redef class CmdList
	redef fun http_init(req) do
		var opt_limit = req.int_arg("l")
		if opt_limit != null then limit = opt_limit
		var opt_page = req.int_arg("p")
		if opt_page != null then page = opt_page
		return super
	end
end
src/doc/commands/commands_http.nit:68,1--76,3

nitc :: json_commands $ CmdList
redef class CmdList
	redef fun to_json do
		var obj = new JsonObject
		obj["results"] = results
		obj["page"] = page
		obj["count"] = count
		obj["limit"] = limit
		obj["max"] = max
		return obj
	end
end
src/doc/templates/json_commands.nit:48,1--58,3

nitc :: term $ CmdList
redef class CmdList
	fun print_list(list_title: nullable String, list_items: nullable Array[MEntity], no_color: nullable Bool) do
		if list_title != null then
			if no_color == null or not no_color then
				print list_title.bold
			else
				print list_title
			end
			print ""
		end
		if list_items != null and list_items.not_empty then
			for mentity in list_items do
				print mentity.cs_list_item(no_color)
				print ""
			end
		else
			print "None."
		end
	end
end
src/doc/term/term.nit:108,1--127,3