Search in sources :

Example 26 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date in project jaxdb by jaxdb.

the class Generator method generate.

private void generate() throws GeneratorExecutionException, IOException {
    if (logger.isInfoEnabled())
        logger.info("Generating jSQL: " + name);
    final File dir = new File(destDir, packageName.replace('.', '/'));
    if (!dir.exists() && !dir.mkdirs())
        throw new IOException("Unable to create output dir: " + dir.getAbsolutePath());
    final StringBuilder out = new StringBuilder(HEADER_COMMENT);
    out.append("package ").append(packageName).append(";\n\n");
    out.append(getDoc(ddlx.getNormalizedSchema(), 0, '\0', '\n'));
    out.append('@').append(SuppressWarnings.class.getName()).append("(\"all\")\n");
    out.append('@').append(Generated.class.getName()).append("(value=\"").append(GENERATED_VALUE).append("\", date=\"").append(GENERATED_DATE).append("\")\n");
    out.append("public final class ").append(schemaClassSimpleName).append(" extends ").append(Schema.class.getCanonicalName()).append(" {");
    final List<Table> tables = ddlx.getNormalizedSchema().getTable();
    final SchemaManifest schemaManifest = new SchemaManifest(tables);
    final StringBuilder cachedTables = new StringBuilder();
    for (final TableMeta tableMeta : schemaManifest.tableNameToTableMeta.values()) {
        tableMeta.init(schemaManifest);
        if (!tableMeta.isAbstract)
            cachedTables.append(tableMeta.classCase).append("(), ");
    }
    if (cachedTables.length() > 0)
        cachedTables.setLength(cachedTables.length() - 2);
    final List<$Column> templates = ddlx.getNormalizedSchema().getTemplate();
    if (templates != null)
        for (final $Column template : templates) if (template instanceof $Enum)
            out.append(declareEnumClass(schemaClassName, ($Enum) template, 2)).append('\n');
    // First create the abstract entities
    for (final TableMeta tableMeta : schemaManifest.tableNameToTableMeta.values()) if (tableMeta.table.getAbstract$().text())
        out.append(makeTable(tableMeta)).append('\n');
    // Then, in proper inheritance order, the real entities
    final List<Table> sortedTables = new ArrayList<>();
    for (final TableMeta tableMeta : schemaManifest.tableNameToTableMeta.values()) {
        if (!tableMeta.table.getAbstract$().text()) {
            sortedTables.add(tableMeta.table);
            out.append(makeTable(tableMeta)).append('\n');
        }
    }
    sortedTables.sort(namedComparator);
    out.append("\n  private static final ").append(String.class.getName()).append("[] names = {");
    for (final Table table : sortedTables) out.append('"').append(table.getName$().text()).append("\", ");
    out.setCharAt(out.length() - 2, '}');
    out.setCharAt(out.length() - 1, ';');
    out.append("\n  private static final ").append(data.Table.class.getCanonicalName()).append("<?>[] tables = {");
    for (final Table table : sortedTables) getClassNameOfTable(out, table).append("(), ");
    out.setCharAt(out.length() - 2, '}');
    out.setCharAt(out.length() - 1, ';');
    out.append('\n');
    out.append("\n  public static ").append(data.Table.class.getCanonicalName()).append("<?>[] getTables() {");
    out.append("\n    return tables;");
    out.append("\n  }\n");
    out.append("\n  public static ").append(data.Table.class.getCanonicalName()).append("<?> getTable(final ").append(String.class.getName()).append(" name) {");
    out.append("\n    final int index = ").append(Arrays.class.getName()).append(".binarySearch(names, name);");
    out.append("\n    return index < 0 ? null : tables[index];");
    out.append("\n  }\n");
    out.append("\n  private static final ").append(schemaClassSimpleName).append(" _schema$ = new ").append(schemaClassSimpleName).append("();\n");
    out.append("\n  static ").append(schemaClassSimpleName).append(" getSchema() {");
    out.append("\n    return _schema$;");
    out.append("\n  }\n");
    // out.append("\n  private static ").append(TableCache.class.getName()).append(" cache;\n");
    // out.append("\n  public static ").append(TableCache.class.getName()).append(" getRowCache() {");
    // out.append("\n    return cache;");
    // out.append("\n  }\n");
    // out.append("\n  public static void setRowCache(").append(TableCache.class.getName()).append(" cache) {");
    // out.append("\n    ").append(schemaClassSimpleName).append(".cache = cache;");
    // out.append("\n  }\n");
    out.append("\n  private ").append(schemaClassSimpleName).append("() {");
    out.append("\n  }");
    out.append("\n}");
    final File javaFile = new File(dir, schemaClassSimpleName + ".java");
    Files.write(javaFile.toPath(), out.toString().getBytes());
}
Also used : Table(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Schema.Table) org.jaxdb.jsql.data(org.jaxdb.jsql.data) ArrayList(java.util.ArrayList) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum) IOException(java.io.IOException) File(java.io.File) org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column(org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Column)

Example 27 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date in project jasn1 by openmuc.

the class ModulesTest method encodingDecoding.

@Test
public void encodingDecoding() throws IOException {
    ReverseByteArrayOutputStream berOS = new ReverseByteArrayOutputStream(1000);
    MyDate1 dateOfHire = new MyDate1();
    // MyDate1 dateOfHire = new MyDate1("19710917");
    dateOfHire.value = new String("19710917").getBytes();
    dateOfHire.encode(berOS, true);
    MyInt2 myInt2Encode = new MyInt2(2);
    berOS.reset();
    myInt2Encode.encode(berOS, true);
    MyInt2 myInt2Decode = new MyInt2();
    byte[] code = HexConverter.fromShortHexString("a303020102");
    InputStream is = new ByteArrayInputStream(code);
    myInt2Decode.decode(is, true);
    Assert.assertEquals(myInt2Decode.value.intValue(), 2);
    PersonnelRecord pr = new PersonnelRecord();
    Name name = new Name();
    name.setGivenName(new BerVisibleString("givenName".getBytes()));
    name.setFamilyName(new BerVisibleString("familyName".getBytes()));
    name.setInitial(new BerVisibleString("initial".getBytes()));
    pr.setName(name);
    pr.setTitle(new BerVisibleString("title".getBytes()));
    pr.setNumber(new EmployeeNumberZ(1));
    pr.setDateOfHire(new Date("23121981".getBytes()));
    pr.setNameOfSpouse(name);
    ChildInformation child = new ChildInformation();
    child.setName(new Name("child name".getBytes()));
    child.setDateOfBirth(new Date("12121912".getBytes()));
    PersonnelRecord.Children children = new PersonnelRecord.Children();
    List<ChildInformation> childInformation = children.getChildInformation();
    childInformation.add(child);
    childInformation.add(child);
    pr.setTestBitString(new MyBitString(new byte[] { (byte) 0x80, (byte) 0xff }, 10));
    pr.setTest(new MyInt(3));
    TestChoice testChoice = new TestChoice();
    testChoice.setChoiceElement1(child);
    pr.setTest2(testChoice);
    pr.setTest3(testChoice);
    pr.setTest4(testChoice);
    pr.setTest5(testChoice);
    pr.setTest6(testChoice);
    TestSequenceOf testSequenceOf = new TestSequenceOf();
    List<BerInteger> berIntegers = testSequenceOf.getBerInteger();
    for (int i = 0; i < 10; i++) {
        berIntegers.add(new BerInteger(i));
    }
    pr.setTestSequenceOf(testSequenceOf);
    TestSequenceOf2 testSequenceOf2 = new TestSequenceOf2();
    List<SEQUENCE> sequences = testSequenceOf2.getSEQUENCE();
    for (int i = 0; i < 10; i++) {
        SEQUENCE sequence = new SEQUENCE();
        sequence.setTest1(new BerInteger(i++));
        sequence.setTest2(new BerInteger(i));
        sequences.add(sequence);
    }
    pr.setTestSequenceOf2(testSequenceOf2);
    BerEmbeddedPdv berEmbeddedPdv = new BerEmbeddedPdv();
    pr.setEmbeddedPdv(berEmbeddedPdv);
    System.out.println("PersonnelRecord.toString():\n" + pr);
}
Also used : BerVisibleString(org.openmuc.jasn1.ber.types.string.BerVisibleString) MyBitString(org.openmuc.jasn1.compiler.modules.module1.MyBitString) PersonnelRecord(org.openmuc.jasn1.compiler.modules.module1.PersonnelRecord) EmployeeNumberZ(org.openmuc.jasn1.compiler.modules.module2.EmployeeNumberZ) ReverseByteArrayOutputStream(org.openmuc.jasn1.ber.ReverseByteArrayOutputStream) Name(org.openmuc.jasn1.compiler.modules.module1.Name) BerEmbeddedPdv(org.openmuc.jasn1.ber.types.BerEmbeddedPdv) SEQUENCE(org.openmuc.jasn1.compiler.modules.module1.PersonnelRecord.TestSequenceOf2.SEQUENCE) BerVisibleString(org.openmuc.jasn1.ber.types.string.BerVisibleString) MyBitString(org.openmuc.jasn1.compiler.modules.module1.MyBitString) ChildInformation(org.openmuc.jasn1.compiler.modules.module1.ChildInformation) TestSequenceOf(org.openmuc.jasn1.compiler.modules.module1.TestSequenceOf) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) TestChoice(org.openmuc.jasn1.compiler.modules.module1.TestChoice) BerInteger(org.openmuc.jasn1.ber.types.BerInteger) TestSequenceOf2(org.openmuc.jasn1.compiler.modules.module1.PersonnelRecord.TestSequenceOf2) Date(org.openmuc.jasn1.compiler.modules.module1.Date) MyDate1(org.openmuc.jasn1.compiler.modules.module1.MyDate1) ByteArrayInputStream(java.io.ByteArrayInputStream) MyInt(org.openmuc.jasn1.compiler.modules.module1.MyInt) MyInt2(org.openmuc.jasn1.compiler.modules.module1.MyInt2) Test(org.junit.Test)

Example 28 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date in project googleads-java-lib by googleads.

the class PqlTest method testCreateValue_dateSet.

@Test
public void testCreateValue_dateSet() {
    Set<Date> numberSet = new LinkedHashSet<Date>();
    numberSet.add(date1);
    Value value1 = ((SetValue) Pql.createValue(numberSet)).getValues(0);
    assertEquals("2012-12-02", DateTimes.toString(((DateValue) value1).getValue()));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DateValue(com.google.api.ads.admanager.axis.v202105.DateValue) TextValue(com.google.api.ads.admanager.axis.v202105.TextValue) BooleanValue(com.google.api.ads.admanager.axis.v202105.BooleanValue) DateTimeValue(com.google.api.ads.admanager.axis.v202105.DateTimeValue) Value(com.google.api.ads.admanager.axis.v202105.Value) DateValue(com.google.api.ads.admanager.axis.v202105.DateValue) TargetingValue(com.google.api.ads.admanager.axis.v202105.TargetingValue) NumberValue(com.google.api.ads.admanager.axis.v202105.NumberValue) SetValue(com.google.api.ads.admanager.axis.v202105.SetValue) SetValue(com.google.api.ads.admanager.axis.v202105.SetValue) Date(com.google.api.ads.admanager.axis.v202105.Date) Test(org.junit.Test)

Example 29 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date in project googleads-java-lib by googleads.

the class PqlTest method setUp.

@Before
public void setUp() throws Exception {
    column1 = new ColumnType();
    column1.setLabelName("column1");
    column2 = new ColumnType();
    column2.setLabelName("column2");
    column3 = new ColumnType();
    column3.setLabelName("column3");
    textValue1 = new TextValue();
    textValue1.setValue("value1");
    textValue2 = new TextValue();
    textValue2.setValue("value2");
    textValue3 = new TextValue();
    textValue3.setValue("value3");
    textValue4 = new TextValue();
    textValue4.setValue("comma,separated");
    booleanValue1 = new BooleanValue();
    booleanValue1.setValue(false);
    booleanValue2 = new BooleanValue();
    booleanValue2.setValue(true);
    booleanValue3 = new BooleanValue();
    booleanValue3.setValue(false);
    numberValue1 = new NumberValue();
    numberValue1.setValue("1");
    numberValue2 = new NumberValue();
    numberValue2.setValue("1.02");
    numberValue3 = new NumberValue();
    numberValue3.setValue("-1");
    numberValue4 = new NumberValue();
    numberValue4.setValue("");
    numberValue5 = new NumberValue();
    numberValue5.setValue(null);
    dateTime1 = new DateTime();
    date1 = new Date();
    date1.setYear(2012);
    date1.setMonth(12);
    date1.setDay(2);
    dateTime1.setDate(date1);
    dateTime1.setHour(12);
    dateTime1.setMinute(45);
    dateTime1.setSecond(0);
    dateTime1.setTimeZoneId(TIME_ZONE_ID1);
    dateTimeValue1 = new DateTimeValue();
    dateTimeValue1.setValue(dateTime1);
    dateValue1 = new DateValue();
    dateValue1.setValue(date1);
    AdUnitTargeting adUnitTargeting = new AdUnitTargeting();
    adUnitTargeting.setAdUnitId("100");
    InventoryTargeting inventoryTargeting = new InventoryTargeting();
    inventoryTargeting.setTargetedAdUnits(new AdUnitTargeting[] { adUnitTargeting });
    targeting1 = new Targeting();
    targeting1.setInventoryTargeting(inventoryTargeting);
    targetingValue1 = new TargetingValue();
    targetingValue1.setValue(targeting1);
    numberSetValue = new SetValue();
    numberSetValue.setValues(new Value[] { numberValue1, numberValue3 });
    textSetValue = new SetValue();
    textSetValue.setValues(new Value[] { textValue1, textValue2 });
    dateSetValue = new SetValue();
    dateSetValue.setValues(new Value[] { dateValue1 });
    dateTimeSetValue = new SetValue();
    dateTimeSetValue.setValues(new Value[] { dateTimeValue1 });
    mixedSetValue = new SetValue();
    mixedSetValue.setValues(new Value[] { textValue1, dateTimeValue1 });
    commaTextSetValue = new SetValue();
    commaTextSetValue.setValues(new Value[] { textValue1, textValue4 });
}
Also used : ColumnType(com.google.api.ads.admanager.axis.v202105.ColumnType) DateTimeValue(com.google.api.ads.admanager.axis.v202105.DateTimeValue) InventoryTargeting(com.google.api.ads.admanager.axis.v202105.InventoryTargeting) Targeting(com.google.api.ads.admanager.axis.v202105.Targeting) AdUnitTargeting(com.google.api.ads.admanager.axis.v202105.AdUnitTargeting) InventoryTargeting(com.google.api.ads.admanager.axis.v202105.InventoryTargeting) DateTime(com.google.api.ads.admanager.axis.v202105.DateTime) Date(com.google.api.ads.admanager.axis.v202105.Date) AdUnitTargeting(com.google.api.ads.admanager.axis.v202105.AdUnitTargeting) NumberValue(com.google.api.ads.admanager.axis.v202105.NumberValue) TextValue(com.google.api.ads.admanager.axis.v202105.TextValue) DateValue(com.google.api.ads.admanager.axis.v202105.DateValue) BooleanValue(com.google.api.ads.admanager.axis.v202105.BooleanValue) TargetingValue(com.google.api.ads.admanager.axis.v202105.TargetingValue) SetValue(com.google.api.ads.admanager.axis.v202105.SetValue) Before(org.junit.Before)

Example 30 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date in project googleads-java-lib by googleads.

the class PqlTest method testCreateValue_dateSet.

@Test
public void testCreateValue_dateSet() {
    Set<Date> numberSet = new LinkedHashSet<Date>();
    numberSet.add(date1);
    Value value1 = ((SetValue) Pql.createValue(numberSet)).getValues().get(0);
    assertEquals("2012-12-02", DateTimes.toString(((DateValue) value1).getValue()));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DateValue(com.google.api.ads.admanager.jaxws.v202105.DateValue) NumberValue(com.google.api.ads.admanager.jaxws.v202105.NumberValue) DateTimeValue(com.google.api.ads.admanager.jaxws.v202105.DateTimeValue) TextValue(com.google.api.ads.admanager.jaxws.v202105.TextValue) BooleanValue(com.google.api.ads.admanager.jaxws.v202105.BooleanValue) Value(com.google.api.ads.admanager.jaxws.v202105.Value) SetValue(com.google.api.ads.admanager.jaxws.v202105.SetValue) TargetingValue(com.google.api.ads.admanager.jaxws.v202105.TargetingValue) DateValue(com.google.api.ads.admanager.jaxws.v202105.DateValue) Date(com.google.api.ads.admanager.jaxws.v202105.Date) Test(org.junit.Test)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)20 Set (java.util.Set)10 Before (org.junit.Before)10 Test (org.junit.Test)9 Date (edu.princeton.cs.algs4.Date)7 Date (com.google.api.ads.admanager.axis.v202108.Date)5 Date (com.google.api.ads.admanager.axis.v202111.Date)5 Date (com.google.api.ads.admanager.axis.v202202.Date)5 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Enum)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float)4