Class ModelMakerImpl

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close the factory - no more requests need be honoured, and any clean-up can be done.
      Model createDefaultModel()
      Answer this ModelSource's default model.
      Model createFreshModel()
      Answer a Model that satisfies this ModelSource's shape.
      Model createModel​(java.lang.String name)
      Create a Model with the given name if no such model exists.
      Model createModel​(java.lang.String name, boolean strict)
      Create a new Model associated with the given name.
      Model createModelOver​(java.lang.String name)  
      GraphMaker getGraphMaker()
      Answer a GraphMaker that makes graphs the same way this ModelMaker makes models.
      Model getModel​(java.lang.String URL)
      ModelGetter implementation component.
      Model getModel​(java.lang.String URL, ModelReader loadIfAbsent)
      Answer a model appropriate for URL, If none is to hand, and it's possible to create one, create it and load it using loadIfAbsent.
      boolean hasModel​(java.lang.String name)
      return true iff the factory has a Model with the given name
      ExtendedIterator<java.lang.String> listModels()
      Answer an [extended] iterator where each element is the name of a model in the maker, and the complete sequence exhausts the set of names.
      Model openModel()  
      Model openModel​(java.lang.String name)
      Answer a model.
      Model openModel​(java.lang.String name, boolean strict)
      Find an existing Model that this factory knows about under the given name.
      Model openModelIfPresent​(java.lang.String name)
      Answer the model named by string in this ModelSource, if it [still] has one, or null if there isn't one.
      void removeModel​(java.lang.String name)
      Remove the association between the name and the Model.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ModelMakerImpl

        public ModelMakerImpl​(GraphMaker maker)
    • Method Detail

      • getGraphMaker

        public GraphMaker getGraphMaker()
        Description copied from interface: ModelMaker
        Answer a GraphMaker that makes graphs the same way this ModelMaker makes models. In general this will be an underlying GraphMaker.
        Specified by:
        getGraphMaker in interface ModelMaker
      • close

        public void close()
        Description copied from interface: ModelMaker
        Close the factory - no more requests need be honoured, and any clean-up can be done.
        Specified by:
        close in interface ModelMaker
      • openModel

        public Model openModel()
      • openModelIfPresent

        public Model openModelIfPresent​(java.lang.String name)
        Description copied from interface: ModelSource
        Answer the model named by string in this ModelSource, if it [still] has one, or null if there isn't one. The ModelSource should not create a fresh model if it doesn't already have one.
        Specified by:
        openModelIfPresent in interface ModelSource
      • openModel

        public Model openModel​(java.lang.String name,
                               boolean strict)
        Description copied from interface: ModelMaker
        Find an existing Model that this factory knows about under the given name. If such a Model exists, return it. Otherwise, if strict is false, create a new Model, associate it with the name, and return it. Otherwise throw a DoesNotExistException.

        When called with strict=false, is equivalent to the ancestor openModel(String) method.

        Specified by:
        openModel in interface ModelMaker
        Parameters:
        name - the name of the Model to find and return
        strict - false to create a new one if one doesn't already exist
      • openModel

        public Model openModel​(java.lang.String name)
        Description copied from interface: ModelSource
        Answer a model. Different ModelSources may implement this in very different ways - ModelSource imposes few constraints other than the result is a proper Model. A ModelSource may use the name to identify an existing Model and re-use it, or it may create a fresh Model each time.

        It is expected that uses of different names will answer different models (different in the strong sense of not having the same underlying graph, too).

        If the ModelSource does not have a model with this name, and if it is not prepared to create one, it should throw a DoesNotExistException. This method never returns null.

        Specified by:
        openModel in interface ModelSource
      • createModel

        public Model createModel​(java.lang.String name,
                                 boolean strict)
        Description copied from interface: ModelMaker
        Create a new Model associated with the given name. If there is no such association, create one and return it. If one exists but strict is false, return the associated Model. Otherwise throw an AlreadyExistsException.
        Specified by:
        createModel in interface ModelMaker
        Parameters:
        name - the name to give to the new Model
        strict - true to cause existing bindings to throw an exception
      • createModel

        public Model createModel​(java.lang.String name)
        Description copied from interface: ModelMaker
        Create a Model with the given name if no such model exists. Otherwise, answer the existing model. Equivalent to
        createModel( name, false ).
        Specified by:
        createModel in interface ModelMaker
      • createModelOver

        public Model createModelOver​(java.lang.String name)
      • createFreshModel

        public Model createFreshModel()
        Description copied from interface: ModelSource
        Answer a Model that satisfies this ModelSource's shape. Different calls return different models - they are not permitted to return the same model. (Doing this on a database model will create new, pseudo-anonymous, models.) This method never returns null.
        Specified by:
        createFreshModel in interface ModelSource
      • createDefaultModel

        public Model createDefaultModel()
        Description copied from interface: ModelSource
        Answer this ModelSource's default model. Every ModelSource has a default model. That model need not exist until the first call on createDefaultModel. Multiple calls of getModel will yield the *same* model. This method never returns null.
        Specified by:
        createDefaultModel in interface ModelSource
      • removeModel

        public void removeModel​(java.lang.String name)
        Description copied from interface: ModelMaker
        Remove the association between the name and the Model. create will now be able to create a Model with that name, and open will no longer be able to find it. Throws an exception if there's no such Model. The Model itself is not touched.
        Specified by:
        removeModel in interface ModelMaker
        Parameters:
        name - the name to disassociate
      • hasModel

        public boolean hasModel​(java.lang.String name)
        Description copied from interface: ModelMaker
        return true iff the factory has a Model with the given name
        Specified by:
        hasModel in interface ModelMaker
        Parameters:
        name - the name of the Model to look for
        Returns:
        true iff there's a Model with that name
      • listModels

        public ExtendedIterator<java.lang.String> listModels()
        Description copied from interface: ModelMaker
        Answer an [extended] iterator where each element is the name of a model in the maker, and the complete sequence exhausts the set of names. No particular order is expected from the list.
        Specified by:
        listModels in interface ModelMaker
        Returns:
        an extended iterator over the names of models known to this Maker.
      • getModel

        public Model getModel​(java.lang.String URL)
        ModelGetter implementation component.
        Specified by:
        getModel in interface ModelGetter
      • getModel

        public Model getModel​(java.lang.String URL,
                              ModelReader loadIfAbsent)
        Description copied from interface: ModelGetter
        Answer a model appropriate for URL, If none is to hand, and it's possible to create one, create it and load it using loadIfAbsent. Otherwise throw CannotCreateException. This method never returns null.
        Specified by:
        getModel in interface ModelGetter