com.sun.xml.bind.v2.model.impl.LeafInfoImpl Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 1997, 2018 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 com.sun.xml.bind.v2.model.impl;
import javax.xml.namespace.QName;
import com.sun.xml.bind.v2.model.annotation.Locatable;
import com.sun.xml.bind.v2.model.core.LeafInfo;
import com.sun.xml.bind.v2.runtime.Location;
/**
* @author Kohsuke Kawaguchi
*/
abstract class LeafInfoImpl implements LeafInfo, 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();
}
}