typesxml
Version:
Open source XML library written in TypeScript
62 lines • 1.81 kB
JavaScript
/*******************************************************************************
* Copyright (c) 2023-2026 Maxprograms.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-v10.html
*
* Contributors:
* Maxprograms - initial API and implementation
*******************************************************************************/
import { Cardinality } from "./ContentModel.js";
import { ContentParticleType } from "./contentParticle.js";
export class DTDName {
name;
cardinality;
constructor(name) {
this.name = name;
this.cardinality = Cardinality.NONE;
}
getName() {
return this.name;
}
getType() {
return ContentParticleType.NAME;
}
addParticle(particle) {
// TODO: implement if needed
}
getParticles() {
let result = new Array();
result.push(this);
return result;
}
getChildren() {
const children = new Set();
children.add(this.name);
return children;
}
getCardinality() {
return this.cardinality;
}
setCardinality(cardinality) {
this.cardinality = cardinality;
}
toString() {
switch (this.cardinality) {
case Cardinality.NONE:
return this.name;
case Cardinality.OPTIONAL:
return this.name + '?';
case Cardinality.ONEMANY:
return this.name + '+';
case Cardinality.ZEROMANY:
return this.name + '*';
default:
// ignore
return '';
}
}
}
//# sourceMappingURL=dtdName.js.map