/** * Constructs a handle for a model workspace item of the specified type, with the given parent * item and name. * * @param type - one of the constants defined in ModelWorkspaceItem * @exception IllegalArgumentException if the type is not one of the valid model workspace item * type constants */ protected ModelWorkspaceItemImpl( final int type, final ModelWorkspaceItem parent, final String name) throws IllegalArgumentException { if (type < MINIMUM_VALID_TYPE || type > MAXIMUM_VALID_TYPE) { throw new IllegalArgumentException( ModelerCore.Util.getString("element.invalidType")); // $NON-NLS-1$ } // ArgCheck.isNotNull(name); // Should be done in subclasses, not here // ArgCheck.isNotZeroLength(name); // Should be done in subclasses, not here fType = type; fParent = (ModelWorkspaceItemImpl) parent; fName = name; if (fParent != null) { try { ModelWorkspaceItemInfo info = (ModelWorkspaceItemInfo) fParent.getItemInfo(); info.addChild(this); } catch (ModelWorkspaceException e) { ModelerCore.Util.log( IStatus.ERROR, e, ModelerCore.Util.getString( "ModelWorkspaceItemImpl.Error_trying_to_create_a_modelWorksapceItem_{0}_under_the_parent_{1}_1", name, fParent.getItemName())); // $NON-NLS-1$ } } }
/** @see ModelWorkspaceItem */ @Override public boolean exists() { try { getItemInfo(); // throws exception if cannot obtain info return true; } catch (ModelWorkspaceException e) { } return false; }