ItemModel.java
Go to the documentation of this file.
00001 /*******************************************************************************
00002  * Copyright (c) 2012 Stefan Profanter.
00003  * All rights reserved. This program and the accompanying materials
00004  * are made available under the terms of the GNU Public License v3.0
00005  * which accompanies this distribution, and is available at
00006  * http://www.gnu.org/licenses/gpl.html
00007  * 
00008  * Contributors:
00009  *     Stefan Profanter - initial API and implementation, Year: 2012
00010  ******************************************************************************/
00011 package edu.tum.cs.vis.model;
00012 
00013 import edu.tum.cs.vis.model.parser.ModelParser;
00014 
00021 public class ItemModel {
00022 
00026         private String          path;
00027 
00031         private ModelParser     parser;
00032 
00039         public ItemModel(String path) {
00040                 this.path = path;
00041                 if (!parseModel())
00042                         parser = null;
00043         }
00044 
00050         public ModelParser getParser() {
00051                 return parser;
00052         }
00053 
00059         public String getPath() {
00060                 return path;
00061         }
00062 
00069         public boolean parseModel() {
00070                 if (path == null)
00071                         return false;
00072                 Class<? extends ModelParser> cl = ModelParser.findParser(path);
00073                 if (cl == null) {
00074                         System.out.println("No parser found for: " + path);
00075                         return false;
00076                 }
00077                 try {
00078                         parser = cl.newInstance();
00079                 } catch (InstantiationException e) {
00080                         System.out.println("Couldn't instantiate parser for: " + path);
00081                         e.printStackTrace();
00082                 } catch (IllegalAccessException e) {
00083                         System.out.println("Couldn't instantiate parser for: " + path);
00084                         e.printStackTrace();
00085                 }
00086                 return parser.parseModel(path);
00087         }
00088 
00095         public void setParser(ModelParser parser) {
00096                 this.parser = parser;
00097         }
00098 
00105         public void setPath(String path) {
00106                 this.path = path;
00107         }
00108 
00109 }


knowrob_cad_parser
Author(s): Stefan Profanter
autogenerated on Mon Oct 6 2014 01:29:56