001: /*
002: * $RCSfile: LoaderBase.java,v $
003: *
004: * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * - Redistribution of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * - Redistribution in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in
015: * the documentation and/or other materials provided with the
016: * distribution.
017: *
018: * Neither the name of Sun Microsystems, Inc. or the names of
019: * contributors may be used to endorse or promote products derived
020: * from this software without specific prior written permission.
021: *
022: * This software is provided "AS IS," without a warranty of any
023: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
024: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
025: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
026: * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
027: * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
028: * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
029: * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
030: * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
031: * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
032: * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
033: * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
034: * POSSIBILITY OF SUCH DAMAGES.
035: *
036: * You acknowledge that this software is not designed, licensed or
037: * intended for use in the design, construction, operation or
038: * maintenance of any nuclear facility.
039: *
040: * $Revision: 1.4 $
041: * $Date: 2007/02/09 17:20:06 $
042: * $State: Exp $
043: */
044:
045: package com.sun.j3d.loaders;
046:
047: import java.net.URL;
048: import java.io.Reader;
049:
050: /**
051: * This class implements the Loader interface. To use
052: * a file loader would extend this class.
053: */
054: public abstract class LoaderBase implements Loader {
055:
056: /** Stores the types of objects that the user wishes to load.*/
057: protected int loadFlags = 0;
058:
059: /** Stores the baseUrl for data files associated with the URL
060: * passed into load(URL).*/
061: protected URL baseUrl = null;
062:
063: /** Stores the basePath for data files associated with the file
064: * passed into load(String).*/
065: protected String basePath = null;
066:
067: // Constructors
068:
069: /**
070: * Constructs a Loader with default values for all variables.
071: */
072: public LoaderBase() {
073: }
074:
075: /**
076: * Constructs a Loader with the specified flags word.
077: */
078: public LoaderBase(int flags) {
079: loadFlags = flags;
080: }
081:
082: // Variable get/set methods
083:
084: /**
085: * This method sets the base URL name for data files associated with
086: * the file. The baseUrl should be null by default, which is an indicator
087: * to the loader that it should look for any associated files starting
088: * from the same place as the URL passed into the load(URL) method.
089: * Note: Users of setBaseUrl() would then use load(URL)
090: * as opposed to load(String).
091: */
092: public void setBaseUrl(URL url) {
093: baseUrl = url;
094: }
095:
096: /**
097: * This method sets the base path name for data files associated with
098: * the file. The basePath should be null by default, which is an indicator
099: * to the loader that it should look for any associated files starting
100: * from the same directory as the file passed into the load(String)
101: * method.
102: * Note: Users of setBasePath() would then use load(String)
103: * as opposed to load(URL).
104: */
105: public void setBasePath(String pathName) {
106: basePath = pathName;
107: }
108:
109: /**
110: * Returns the current base URL setting.
111: */
112: public URL getBaseUrl() {
113: return baseUrl;
114: }
115:
116: /**
117: * Returns the current base path setting.
118: */
119: public String getBasePath() {
120: return basePath;
121: }
122:
123: /**
124: * This method sets the load flags for the file. The flags should
125: * equal 0 by default (which tells the loader to only load geometry).
126: */
127: public void setFlags(int flags) {
128: loadFlags = flags;
129: }
130:
131: /**
132: * Returns the current loading flags setting.
133: */
134: public int getFlags() {
135: return loadFlags;
136: }
137:
138: }
|