blob: 8fe258317dd4d952dc5235b45df3bb3b98fa4a75 [file] [log] [blame]
/*
* Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.glassfish.jaxb.runtime.v2.model.impl;
import org.glassfish.jaxb.core.v2.model.annotation.Locatable;
import org.glassfish.jaxb.core.v2.model.core.LeafInfo;
import org.glassfish.jaxb.core.v2.runtime.Location;
import javax.xml.namespace.QName;
/**
* @author Kohsuke Kawaguchi
*/
abstract class LeafInfoImpl<TypeT,ClassDeclT> implements LeafInfo<TypeT,ClassDeclT>, Location {
private final TypeT type;
/**
* Can be null for anonymous types.
*/
private final QName typeName;
protected LeafInfoImpl(TypeT type,QName typeName) {
assert type!=null;
this.type = type;
this.typeName = typeName;
}
/**
* A reference to the representation of the type.
*/
public TypeT getType() {
return type;
}
/**
* Leaf-type cannot be referenced from IDREF.
*
* @deprecated
* why are you calling a method whose return value is always known?
*/
public final boolean canBeReferencedByIDREF() {
return false;
}
public QName getTypeName() {
return typeName;
}
public Locatable getUpstream() {
return null;
}
public Location getLocation() {
// this isn't very accurate, but it's not too bad
// doing it correctly need leaves to hold navigator.
// otherwise revisit the design so that we take navigator as a parameter
return this;
}
public boolean isSimpleType() {
return true;
}
public String toString() {
return type.toString();
}
}