Revision 17134 trunk/libraries/libTopology/src/org/gvsig/topology/TopologyRuleFactory.java

View differences:

TopologyRuleFactory.java
81 81
			return null;
82 82
		}
83 83
		Class clazz = null;
84
		ITopologyRule obj = null;
84
		IOneLyrRule obj = null;
85 85
		String s = className;
86 86
		try {
87 87
			clazz = Class.forName(className);
88 88
			if (xml.contains("desc")) {
89 89
				s += " \"" + xml.getStringProperty("desc") + "\"";
90 90
			}
91
			obj = (ITopologyRule) clazz.newInstance();
91
			obj = (IOneLyrRule) clazz.newInstance();
92 92
			logger.info(Messages.getString("creating") + "....... " + s);
93 93
			try {
94 94
				obj.setTopology(ownerOfRule);
95 95
				obj.setXMLEntity(xml);
96
				
97
				if(obj.getOriginLyr() == null)
98
					throw new TopologyRuleDefinitionException("Regla topologica sin capa de origen");
99
				
100
				if(obj instanceof ITwoLyrRule){
101
					if(((ITwoLyrRule)obj).getDestinationLyr() == null){
102
						throw new TopologyRuleDefinitionException("Regla que aplica a dos capas no ha especificado la segunda capa");
103
					}
104
				}
105
				
96 106
			} catch (NotExistInXMLEntity neiXML) {
97 107
				logger.error(Messages.getString("failed_creating_object")
98 108
						+ ": " + s);
......
111 121
		try{	
112 122
			ITopologyRule rule = (ITopologyRule) ruleClass.newInstance();
113 123
			FLyrVect originLyr = (FLyrVect) params.get("originLyr");
124
			if(originLyr == null)
125
				throw new TopologyRuleDefinitionException("Regla topologica sin capa de origen");
114 126
			((IOneLyrRule)rule).setOriginLyr(originLyr);
115
			
116 127
			if (ruleClass.isAssignableFrom(ITwoLyrRule.class)){
117 128
				FLyrVect destinationLyr = (FLyrVect) params.get("destinationLyr");
118 129
				if(destinationLyr == null)

Also available in: Unified diff