org.dmd.dms.generated.types.NameValuePair Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dark-matter-data Show documentation
Show all versions of dark-matter-data Show documentation
The dark-matter project provides mechanism to define concepts associated with Domain Specific Languages (DSLs) and generate code that can be extended with business logic that supports the given DSL purpose.
// ---------------------------------------------------------------------------
// dark-matter-data
// Copyright (c) 2012-2021 dark-matter-data committers
// ---------------------------------------------------------------------------
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
// more details.
// You should have received a copy of the GNU Lesser General Public License along
// with this program; if not, see .
// ---------------------------------------------------------------------------
package org.dmd.dms.generated.types;
// Generated from: org.dmd.util.codegen.ImportManager.getFormattedImports(ImportManager.java:82)
// Called from: org.dmd.dms.meta.MetaComplexTypeFormatter.dumpComplexType(MetaComplexTypeFormatter.java:101)
import java.io.Serializable; // Marker interface for serialization - (MetaComplexTypeFormatter.java:76)
import java.util.ArrayList; // To store ParsedNameValuePairs - (MetaComplexTypeFormatter.java:83)
import org.dmd.dmc.DmcAttributeInfo; // For fake DmcAttributeInfo - (MetaComplexTypeFormatter.java:81)
import org.dmd.dmc.DmcInputStreamIF; // To support serialization - (MetaComplexTypeFormatter.java:77)
import org.dmd.dmc.DmcOutputStreamIF; // To support serialization - (MetaComplexTypeFormatter.java:78)
import org.dmd.dmc.DmcValueException; // For type checking - (MetaComplexTypeFormatter.java:97)
import org.dmd.dmc.util.ComplexTypeSplitter; // For parsing initial input - (MetaComplexTypeFormatter.java:82)
import org.dmd.dmc.util.ParsedNameValuePair; // To store values parsed from initial input - (MetaComplexTypeFormatter.java:84)
import org.dmd.dms.generated.enums.DataTypeEnum; // For fake DmcAttributeInfo - (MetaComplexTypeFormatter.java:79)
import org.dmd.dms.generated.enums.ValueTypeEnum; // For fake DmcAttributeInfo - (MetaComplexTypeFormatter.java:80)
@SuppressWarnings("serial")
/**
* The NameValuePair class.
* This code was auto-generated by the createmeta utility and shouldn't be alterred
* manually.
* Generated from: org.dmd.dms.meta.MetaComplexTypeFormatter.dumpComplexType(MetaComplexTypeFormatter.java:108)
*/
public class NameValuePair implements Serializable {
// The name of the value
String name;
final static DmcAttributeInfo nameAI = new DmcAttributeInfo("name",0,"String",ValueTypeEnum.SINGLE,DataTypeEnum.UNKNOWN);
// The value
String value;
final static DmcAttributeInfo valueAI = new DmcAttributeInfo("value",0,"String",ValueTypeEnum.SINGLE,DataTypeEnum.UNKNOWN);
final static int requiredParts = 2;
/**
* Default constructor.
*/
public NameValuePair(){
}
/**
* Copy constructor.
*/
public NameValuePair(NameValuePair original){
name = original.name;
value = original.value;
}
// Generated from: org.dmd.dms.meta.MetaComplexTypeFormatter.dumpComplexType(MetaComplexTypeFormatter.java:133)
/**
* All fields constructor.
*/
public NameValuePair(String f1, String f2) throws DmcValueException {
name = DmcTypeStringSTATIC.instance.typeCheck(f1);
value = DmcTypeStringSTATIC.instance.typeCheck(f2);
}
// Generated from: org.dmd.dms.meta.MetaComplexTypeFormatter.dumpComplexType(MetaComplexTypeFormatter.java:160)
/**
* String based constructor.
*/
public NameValuePair(String initialInput) throws DmcValueException {
initialize(initialInput);
}
// Generated from: org.dmd.dms.meta.MetaComplexTypeFormatter.dumpComplexType(MetaComplexTypeFormatter.java:168)
void initialize(String initialInput) throws DmcValueException {
ArrayList nvp = ComplexTypeSplitter.parse(initialInput);
if (nvp.size() < requiredParts)
throw(new DmcValueException("Missing required values for complex type: NameValuePair"));
name = DmcTypeStringSTATIC.instance.typeCheck(nvp.get(0).getValue());
value = DmcTypeStringSTATIC.instance.typeCheck(nvp.get(1).getValue());
}
/**
* Serialization.
*/
public void serializeIt(DmcOutputStreamIF dos) throws Exception {
dos.writeUTF(toString());
}
/**
* Deserialization.
*/
public void deserializeIt(DmcInputStreamIF dis) throws Exception {
initialize(dis.readUTF());
}
/**
* String form.
* Generated from: org.dmd.dms.meta.MetaComplexTypeFormatter.dumpComplexType(MetaComplexTypeFormatter.java:257)
*/
public String toString(){
StringBuffer sb = new StringBuffer();
sb.append(name.toString());
sb.append(' ');
sb.append("\"" + value.toString() + "\"");
return(sb.toString());
}
public String getName(){
return(name);
}
public String getValue(){
return(value);
}
public void toJSON(StringBuffer sb, int padding, String indent) {
throw(new IllegalStateException("This needs to be implemented"));
}
}