
io.sarl.api.naming.namespace.NamespaceService.sarl Maven / Gradle / Ivy
Show all versions of api.naming Show documentation
/*
* $Id$
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2024 SARL.io, the Original Authors and Main Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.sarl.api.naming.namespace
import io.sarl.api.naming.name.SarlName
import io.sarl.api.naming.parser.INameParser
import java.net.URI
import org.arakhne.afc.services.IService
/**
* This service enables to manage the name spaces into the SRE.
*
* Each object within the SRE may be identified by a name, stored into an {@link SarlName}.
*
* @author Stéphane Galland
* @version api.naming 0.14.0 20241106-161408
* @mavengroupid io.sarl.sdk
* @mavenartifactid api.naming
* @since 0.12
*/
interface NamespaceService extends IService {
/**
* Replies the name parser that is used by this service.
*
* @return The name parser
* @since 0.11
*/
@Pure
def getNameParser : INameParser
/**
* Replies the validator for the access to the fields that is used by this service.
*
* @return The field access validator.
* @since 0.12
*/
@Pure
def getFieldAccessValidator : IFieldAccessValidator
/**
* Finds and replies the object with the given name and of the given type.
*
* @param name the name of the object. See the documentation of {@link NamespaceService}
* for details.
* @return the root context. A {@code null} value is replied if the object is not found.
*/
@Pure
def findObject(name : SarlName, type : Class) : T with T
/**
* Finds and replies the object with the given name and of the given type.
*
* @param name the name of the object. See the documentation of {@link NamespaceService}
* for details.
* @return the object with the given name. A {@code null} value is replied if the object is not found.
*/
@Pure
def findObject(name : SarlName) : Object
/**
* Finds and replies the object with the given name and of the given type.
*
* @param name the name of the object. See the documentation of {@link NamespaceService}
* for details.
* @return the root context. A {@code null} value is replied if the object is not found.
* @since 0.11
*/
@Pure
def findObject(name : String, type : Class) : T with T {
var parser = this.nameParser
var nameURI = parser.decode(name)
if (nameURI === null) {
return null
}
var sarlName = parser.decode(nameURI)
if (sarlName === null) {
return null
}
return findObject(sarlName, type)
}
/**
* Finds and replies the object with the given name and of the given type.
*
* @param name the name of the object. See the documentation of {@link NamespaceService}
* for details.
* @return the object with the given name. A {@code null} value is replied if the object is not found.
* @since 0.11
*/
@Pure
def findObject(name : String) : Object {
var parser = this.nameParser
var nameURI = parser.decode(name)
if (nameURI === null) {
return null
}
var sarlName = parser.decode(nameURI)
if (sarlName === null) {
return null
}
return findObject(sarlName)
}
/**
* Finds and replies the object with the given name and of the given type.
*
* @param name the name of the object. See the documentation of {@link NamespaceService}
* for details.
* @return the root context. A {@code null} value is replied if the object is not found.
* @since 0.12
*/
@Pure
def findObject(name : URI, type : Class) : T with T {
var parser = this.nameParser
var sarlName = parser.decode(name)
if (sarlName === null) {
return null
}
return findObject(sarlName, type)
}
/**
* Finds and replies the object with the given name and of the given type.
*
* @param name the name of the object. See the documentation of {@link NamespaceService}
* for details.
* @return the object with the given name. A {@code null} value is replied if the object is not found.
* @since 0.12
*/
@Pure
def findObject(name : URI) : Object {
var parser = this.nameParser
var sarlName = parser.decode(name)
if (sarlName === null) {
return null
}
return findObject(sarlName)
}
}