最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。
In the null object schema (Null Object Pattern), an empty object replaces the check of the NULL object instance. Instead of checking for null values, the Null object reflects a relationship that does nothing. Such Null objects can also provide default behavior when data is not available.
In the empty object pattern, we create an abstract class that specifies various operations to be performed and an entity class that extends it, as well as an empty object class that has not been implemented at all. The empty object class will be used seamlessly where null values need to be checked. We will create a definition operation (in this case, the name of the customer) AbstractCustomer Abstract classes, and extend the AbstractCustomer The entity class of the. Factory class CustomerFactory Return based on the name passed by the customer RealCustomer Or NullCustomer Object. NullPatternDemo Our demo class uses the CustomerFactory To demonstrate the use of the empty object pattern. Create an abstract class. Create an entity class that extends the above class. Create CustomerFactory Class. Use CustomerFactory Based on the name passed by the customer, to get RealCustomer Or NullCustomer Object. Execute the program and output the result: 6.24.1. Realize ¶

6.24.2. Step 1 ¶
AbstractCustomer.java ¶
publicabstractclassAbstractCustomer{protectedStringname;publicabstractbooleanisNil();publicabstractStringgetName();}
6.24.3. Step 2 ¶
RealCustomer.java ¶
publicclassRealCustomerextendsAbstractCustomer{publicRealCustomer(Stringname){this.name=name;}@OverridepublicStringgetName(){returnname;}@OverridepublicbooleanisNil(){returnfalse;}}
NullCustomer.java ¶
publicclassNullCustomerextendsAbstractCustomer{@OverridepublicStringgetName(){return"Not Available in Customer Database";}@OverridepublicbooleanisNil(){returntrue;}}
6.24.4. Step 3 ¶
CustomerFactory.java ¶
publicclassCustomerFactory{publicstaticfinalString[]names={"Rob","Joe","Julie"};publicstaticAbstractCustomergetCustomer(Stringname){for(inti=0;i<names.length;i++){if(names[i].equalsIgnoreCase(name)){returnnewRealCustomer(name);}}returnnewNullCustomer();}}
6.24.5. Step 4 ¶
NullPatternDemo.java ¶
publicclassNullPatternDemo{publicstaticvoidmain(String[]args){AbstractCustomercustomer1=CustomerFactory.getCustomer("Rob");AbstractCustomercustomer2=CustomerFactory.getCustomer("Bob");AbstractCustomercustomer3=CustomerFactory.getCustomer("Julie");AbstractCustomercustomer4=CustomerFactory.getCustomer("Laura");System.out.println("Customers");System.out.println(customer1.getName());System.out.println(customer2.getName());System.out.println(customer3.getName());System.out.println(customer4.getName());}}
6.24.6. Step 5 ¶
Customers Rob Not Available in Customer Database Julie Not Available in Customer Database