📄 restriction.java
字号:
/* OMM - Ontology Middleware Module * Copyright (C) 2002 OntoText Lab, Sirma AI OOD * * Contact: * Sirma AI OOD, OntoText Lab. * 38A, Christo Botev Blvd. * 1000 Sofia, Bulgaria * tel. +359(2)981 00 18 * fax. +359(2)981 90 58 * info@ontotext.com * * http://www.ontotext.com/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package org.openrdf.sesame.sailimpl.omm.security;import java.util.ArrayList;import java.util.HashSet;import java.util.Map;import java.util.Set;/**Restriction.java * <p>Title: Knowledge Control System</p> * <p> </p> * <p> </p> * <p>Company: OntoText Lab. Sirma AI. </p> * @author damyan ognyanoff, borislav popov * @version 1.0 * This is the base class for all kinds of restrictions supported in the * repository */public abstract class Restriction { /** set of all the restrictions */ private static Set restrictions = new HashSet(); /**REPOSITORY Restriction Type*/ public static final int REPOSITORY = 1; /**SCHEMA Restriction Type*/ public static final int SCHEMA = 2; /**CLASSES Restriction Type*/ public static final int CLASSES = 3; /**INSTANCES Restriction Type*/ public static final int INSTANCES = 4; /**PROPERTIES Restriction Type*/ public static final int PROPERTIES = 5; /**PATTERN Restriction Type*/ public static final int PATTERN = 6; /**QUERY Restriction Type*/ public static final int QUERY = 7; /**CLASSES Over Schema Restriction Type*/ public static final int CLASSES_OVER_SCHEMA = 8; /**REPOSITORY Restriction name*/ public static final String REPOSITORY_RESTRICTION = "RepositoryRestriction"; /**SCHEMA Restriction name*/ public static final String SCHEMA_RESTRICTION = "SchemaRestriction"; /**CLASSES Restriction name*/ public static final String CLASSES_RESTRICTION = "ClassesRestriction"; /**INSTANCES Restriction name*/ public static final String INSTANCES_RESTRICTION = "InstancesRestriction"; /**PROPERTIES Restriction name*/ public static final String PROPERTIES_RESTRICTION = "PropertiesRestriction"; /**PATTERN Restriction name*/ public static final String PATTERN_RESTRICTION = "PatternRestriction"; /**QUERY Restriction name*/ public static final String QUERY_RESTRICTION = "QueryRestriction"; /**CLASSES Over Schema Restriction name*/ public static final String CLASSES_OVER_SCHEMA_RESTRICTION = "ClassesOverSchemaRestriction"; /** the lastId of all types of restrictions */ private static int lastId = 0; /** the type of the restriction */ int type; /** the id of the restriction */ int id; /** the name of the restriction */ String name = null; /** the descritpion of the restriction */ String description = null; /** the URI */ private String uri = null; /** construction of a restriction * @param id id of the restriction * @param kind restriction type * @param name description * @param desc description */ protected Restriction(int id, int kind,String name, String desc) { this.id = id; type = kind; this.name = name; description = desc; restrictions.add(this); }//CONsTRUCTion /** * Constructs a restriction given its type. * @param type the type of the restriction */ protected Restriction(int type) { this.type = type; this.id = ++lastId; } /** * Creates a restriction given only its type. Other members should be set explicitly. * @param type the type of the restriction * @return the created restriction if a valid type was specified, otherwise - null. */ public static Restriction createRestriction(int type) { Restriction restr = null; switch ( type ) { case (1) : restr = new RepositoryRestriction(++lastId,"",""); break; case (2) : restr = new SchemaRestriction(++lastId,"","");break; case (3) : restr = new ClassesRestriction(++lastId,"","");break; case (4) : restr = new InstancesRestriction(++lastId,"","");break; case (5) : restr = new PropertiesRestriction(++lastId,"","");break; case (6) : restr = new PatternRestriction(++lastId,"","");break; case (7) : restr = new QueryRestriction(++lastId,"","");break; case (8) : restr = new ClassesOverSchemaRestriction(++lastId,"","");break; } return restr; } /** * Creates a restriction given its type and id. Other members should be set explicitly. * @param type the type of the restriction * @param id the id of the restriction * @return the created restriction if a valid type was specified, otherwise - null. */ public static Restriction createRestriction(int type, int id) { Restriction restr = null; switch ( type ) { case (1) : restr = new RepositoryRestriction(id,"",""); break; case (2) : restr = new SchemaRestriction(id,"","");break; case (3) : restr = new ClassesRestriction(id,"","");break; case (4) : restr = new InstancesRestriction(id,"","");break; case (5) : restr = new PropertiesRestriction(id,"","");break; case (6) : restr = new PatternRestriction(id,"","");break; case (7) : restr = new QueryRestriction(id,"","");break; case (8) : restr = new ClassesOverSchemaRestriction(id,"","");break; } if ( id > lastId) lastId = id; return restr; } /** * Create a Repository 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 createRepositoryRestriction(int id, String name, String descr) { if ( id > lastId ) lastId = id; return new RepositoryRestriction(id,name,descr); } /** * Create a Repository Restriction. * @param name name of the restriction. * @param descr description of the restriction. * @return the created restriction */ static public Restriction createRepositoryRestriction( String name, String descr) { return new RepositoryRestriction(++lastId,name,descr); } /** * Create a Schema 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 createSchemaRestriction(int id, String name, String descr) { if ( id > lastId ) lastId = id; return new SchemaRestriction(id,name,descr); } /** * Create a Schema Restriction. * @param name name of the restriction. * @param descr description of the restriction. * @return the created restriction */ static public Restriction createSchemaRestriction( String name, String descr) { return new SchemaRestriction(++lastId,name,descr); } /** * Create a Classes 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 createClassesRestriction(int id, String name, String descr) { if ( id > lastId ) lastId = id; return new ClassesRestriction(id,name,descr); } /** * Create a Classes Restriction. * @param name name of the restriction. * @param descr description of the restriction. * @return the created restriction */ static public Restriction createClassesRestriction(String name, String descr) { return new ClassesRestriction(++lastId,name,descr); } /** * Create a Classes Over Schema 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 createClassesOverSchemaRestriction( int id, String name, String descr) { if ( id > lastId) lastId = id; return new ClassesOverSchemaRestriction(id,name,descr); } /** * Create a Classes Over Schema Restriction. * @param name name of the restriction. * @param descr description of the restriction. * @return the created restriction */ static public Restriction createClassesOverSchemaRestriction(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -