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

📄 restriction.java

📁 这是外国一个开源推理机
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    String name, String descr)    {      return new ClassesOverSchemaRestriction(        ++lastId,name,descr);    }  /**   * Create an Instances Restriction.   * @param id id of the restriction.   * @param name name of the restriction.   * @param descr description of the restriction.   * @return the created restriction   */  static public Restriction createInstancesRestriction(int id, String name, String descr)    {      if ( id > lastId)        lastId = id;      return new InstancesRestriction(id,name,descr);    }  /**   * Create an Instances Restriction.   * @param name name of the restriction.   * @param descr description of the restriction.   * @return the created restriction   */  static public Restriction createInstancesRestriction(String name, String descr)    {      return new InstancesRestriction(++lastId,name,descr);    }  /**   * Create a Properties Restriction.   * @param id id of the restriction.   * @param name name of the restriction.   * @param descr description of the restriction.   * @return the created restriction   */  static public Restriction createPropertiesRestriction(int id, String name, String descr)    {      if ( id > lastId )        lastId = id;      return new PropertiesRestriction(id,name,descr);}  /**   * Create a Properties Restriction.   * @param name name of the restriction.   * @param descr description of the restriction.   * @return the created restriction   */  static public Restriction createPropertiesRestriction(String name, String descr)    {      return new PropertiesRestriction(++lastId,name,descr);    }  /**   * Create a Pattern Restriction.   * @param id id of the restriction.   * @param name name of the restriction.   * @param descr description of the restriction.   * @return the created restriction   */  static public Restriction createPatternRestriction(int id, String name, String descr)    {      if ( id > lastId )        lastId = id;      return new PatternRestriction(id,name,descr);    }  /**   * Create a Pattern Restriction.   * @param name name of the restriction.   * @param descr description of the restriction.   * @return the created restriction   */  static public Restriction createPatternRestriction( String name, String descr)    {      return new PatternRestriction(++lastId,name,descr);    } /**   * Create a Query Restriction.   * @param id id of the restriction.   * @param name name of the restriction.   * @param descr description of the restriction.   * @return the created restriction   */  static public Restriction createQueryRestriction(int id, String name, String descr){    if ( id > lastId )      lastId = id;    return new QueryRestriction(id,name,descr);  } /**   * Create a Query Restriction.   * @param name name of the restriction.   * @param descr description of the restriction.   * @return the created restriction   */  static public Restriction createQueryRestriction(String name, String descr){    return new QueryRestriction(++lastId,name,descr);  }  /**   * Retrieve the set of all restrictions.   * @return the set of all restrictions.   */  public static Set getRestrictions(){    return restrictions;  }  /**   * Gets the string representation of the type of the restriction. e.g. 1 is Repository.   * @param type the type to be converted   * @return the string representing the converted restriction type   */  public static String type2String(int type) {    String result = ""+type;    switch ( type ) {      case (1) : result = "Repository"; break;      case (2) : result = "Schema"; break;      case (3) : result = "Classes"; break;      case (4) : result = "Instances"; break;      case (5) : result = "Properties"; break;      case (6) : result = "Pattern"; break;      case (7) : result = "Query"; break;      case (8) : result = "ClassesOverSchema"; break;    }    return result+"Restriction";  }  /**   * Converts the type to its integer value.   * @param type the String representation of the Restriction type   * @return 0 is returned if unknown type,   * otherwise the int associated with the string type is returned.   */  public static int type2Int(String type){    int result = 0;    if (type.equals("RepositoryRestriction")) result =1 ;    if (type.equals("SchemaRestriction")) result =2 ;    if (type.equals("ClassesRestriction")) result =3 ;    if (type.equals("InstancesRestriction")) result =4 ;    if (type.equals("PropertiesRestriction")) result =5 ;    if (type.equals("PatternRestriction")) result =6 ;    if (type.equals("QueryRestriction")) result =7 ;    if (type.equals("ClassesOverSchemaRestriction")) result =8 ;    return result;  }  /**   * Gets the restriction id.   * @return the id of the restriction   */  public int getId() {    return id;  }  /**   * Sets restriction's id.   * @param id the id to be set.   */  public void setId(int id) {    this.id = id;  }  /**   * Gets the restriction's description.   * @return the restriction's description   */  public String getDescription() {    return description;  }  /**   * Sets the restriction's description.   * @param descr the restriction's description   */  public void setDescription(String descr) {    description = descr;  }  /**   * Gets the restriciton's name.   * @return the restriciton's name   */  public String getName() {    return name;  }  /**   * Sets the restriciton's name.   * @param name the name to be set   */  public void setName(String name) {    this.name = name;  }  /**   * Gets restriction type.   * @return type of the restriction   */  public int getType() {    return type;  }  /**   * Sets the type of the restriction.   * @param type restriction type   */  public void setType(int type) {    this.type = type;  }  /** Creates update queries over the restrictions, res_prop_restrs, query_restrs,   *  pattern_restrs tables.   * @return A list of update SQL queries, to be used to mirror the objects'   *  properties from memory to an SQL repository.   */  public ArrayList toSql(Map idByLiteral, Map idByRes) throws NullParameterException,SecurityException  {    if (idByRes == null )      throw new NullParameterException("[ids by resources] map should not be [null].");    if (idByLiteral == null )      throw new NullParameterException("[ids by literals] map should not be [null].");    ArrayList list = new ArrayList(3);    StringBuffer query = new StringBuffer();    query.append(SecuritySail.INSERT);    query.append(SecuritySail.RESTRICTIONS_TABLE);    query.append(SecuritySail.VALUES);    query.append("(").append(id);    query.append(",");    query.append(type);    query.append(",'");    query.append(name);    query.append("','");    query.append(description).append("');");    list.add(query.toString());    return list;  }// toSql()	public void setUri(String uri) {		this.uri = uri;	}	public String getUri() {		return uri;	}} // RestrictionType class

⌨️ 快捷键说明

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