⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dataschema.as

📁 用于flash/flex的 as3的 2D图形图像图表的动态生成
💻 AS
字号:
package flare.data
{
	import flare.util.Arrays;
	
	/**
	 * A data schema represents a set of data variables and their associated 
	 * types. A schema maintains a collection of <code>DataField</code>
	 * objects.
	 * @see flare.data.DataField
	 */
	public class DataSchema
	{
		public var dataRoot:String = null;
		public var hasHeader:Boolean = false;
		
		private var _fields:/*DataField*/Array = [];
		private var _nameLookup:/*String->DataField*/Object = {};
		private var _idLookup:/*String->DataField*/Object = {};
		
		/** An array containing the data fields in this schema. */
		public function get fields():Array { return Arrays.copy(_fields); }
		/** The number of data fields in this schema. */
		public function get numFields():int { return _fields.length; }
		
		/**
		 * Creates a new DataSchema.
		 * @param fields an ordered list of data fields to include in the
		 * schema
		 */
		public function DataSchema(...fields)
		{
			for each (var f:DataField in fields) {
				addField(f);
			}
		}
		
		/**
		 * Adds a field to this schema.
		 * @param field the data field to add
		 */
		public function addField(field:DataField):void
		{
			_fields.push(field);
			_nameLookup[field.name] = field;
			_idLookup[field.id] = field;
		}
		
		/**
		 * Retrieves a data field by name.
		 * @param name the data field name
		 * @return the corresponding data field, or null if no data field is
		 *  found matching the name
		 */
		public function getFieldByName(name:String):DataField
		{
			return _nameLookup[name];
		}
		
		/**
		 * Retrieves a data field by id.
		 * @param name the data field id
		 * @return the corresponding data field, or null if no data field is
		 *  found matching the id
		 */
		public function getFieldById(id:String):DataField
		{
			return _idLookup[id];
		}
		
		/**
		 * Retrieves a data field by its index in this schema.
		 * @param idx the index of the data field in this schema
		 * @return the corresponding data field
		 */
		public function getFieldAt(idx:int):DataField
		{
			return _fields[idx];
		}
		
	} // end of class DataSchema
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -