/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Main is a simple java class to demonstrate the NullObject pattern, * aspectized. * * Copyright (C) 2003 R. Dale Asberry * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * R. Dale Asberry - initial implementation * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ package test; import java.util.ArrayList; import java.util.List; public class Main { private List cList = null; private ArrayList cArrayList = null; private String cString = null; public static void main(String[] args) { Main lMain = new Main(); // lMain.cList = lMain.nullListTest(); try { lMain.cString = lMain.nullStringTest(); System.out.println(lMain.cString.charAt(4)); } catch(NullPointerException npe) { npe.printStackTrace(); } System.out.println(""); try { lMain.cArrayList = lMain.nullArrayListTest(); lMain.cArrayList.get(0); } catch(NullPointerException npe) { npe.printStackTrace(); } System.out.println(""); try { // lMain.cList = null; lMain.cList.get(0); } catch(NullPointerException npe) { npe.printStackTrace(); } for(int i = 0; i < 100; i++) { lMain.cArrayList = lMain.nullArrayListTest(); lMain.cArrayList.get(1); } } public List nullListTest() { return null; } public ArrayList nullArrayListTest() { return null; } public String nullStringTest() { return null; } }