Switch

Switch

Generates a value based on the output of a sub-generator. Either specify a sub-generator or run another generator using a Sequential before this one to provide a value. After that, add case-elements (with 'value' attributes) to check the generated value and run the case's specified sub-generator to get a final result.

Attributes
Name Description Required Min Max Allowed Values
seed Random number generator seed of this Element. Overrides default seeding behavior. no 0 1
name (Class)Name of this element. Used to identify plugin Class. Full name is required. Example: com.en.myPluginPackage.myPuginClass no 0 1
id Identification String of this element. May be used to uniquely identify a field within the children of an Element. no 0 1
Nodes
Name Description Required Min Max Allowed Values
case Content type: Sub-generator
A specific case to check. A case element has to specify an attribute 'value' which is matched against the result of the initial sub-generator. If the result matches the specified value, the sub-generator defined within the current case element is run.
yes 1 1
default Content type: Sub-generator
If none of the specified cases match, this generator is run to get a result.
no 0 1
gen Value Generator for this field no 0 1
  • pdgf.generator.MarkovChainText
  • pdgf.generator.AsReferenceChoice
  • pdgf.generator.WeightedListItem
  • pdgf.generator.DetailFromDate
  • pdgf.generator.BuildList
  • pdgf.generator.InsertIntoString
  • pdgf.generator.UUID
  • pdgf.generator.Probability
  • pdgf.generator.RandomString
  • pdgf.generator.Sequential
  • pdgf.generator.ConvertNumberToString
  • pdgf.generator.WeightedSubListItem
  • pdgf.generator.RandomListItems
  • pdgf.generator.Email
  • pdgf.generator.ActionDeleteIsAlsoUpdate
  • pdgf.generator.DoubleNumber
  • pdgf.generator.Permutation
  • pdgf.generator.Switch
  • pdgf.generator.ReferenceValue
  • pdgf.generator.ForFormula
  • pdgf.generator.PrePostfix
  • pdgf.generator.StaticValue
  • pdgf.generator.Hash
  • pdgf.generator.Padding
  • pdgf.generator.FormatString
  • pdgf.generator.DateTime
  • pdgf.generator.Id
  • pdgf.generator.LastChoice
  • pdgf.generator.MaskString
  • pdgf.generator.Null
  • pdgf.generator.AddRandomSeconds
  • pdgf.generator.RandomStringInRange
  • pdgf.generator.Formula
  • pdgf.generator.AbstractDecimal
  • pdgf.generator.FormatFloatingPoint
  • pdgf.generator.OtherFieldValue
  • pdgf.generator.RandomSentence
  • pdgf.generator.FormatNumber
  • pdgf.generator.Template
  • pdgf.generator.BigBenchReview
  • pdgf.generator.UpperLowerCase
  • pdgf.generator.For
  • pdgf.generator.Relative
  • pdgf.generator.RandomUniqeString
  • pdgf.generator.PermutationReference
  • pdgf.generator.UpdateActionType
  • pdgf.generator.FormatNumberAsDate
  • pdgf.generator.OldReferenceGeneratorDeprecated
  • pdgf.generator.DictList
  • pdgf.generator.ExtendedFormula
  • pdgf.generator.FormatDateAsNumber
  • pdgf.generator.If
  • pdgf.generator.GlobalRowNumber
  • pdgf.generator.LongNumber
  • pdgf.generator.UnsafeDistinct

Examples

  1. Static Values based on Numbers

    Generates either "Cat", "Dog", or "Turtle" based on the output of the underlying LongNumber generator. The generator produces "Cat" if the underlying long number is 1, "Dog" if it is 2, and "Turtle" if it is 3.

    Schema config for Static Values based on Numbers
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
    /*******************************************************************************
    * Copyright (c) 2013, bankmark and/or its affiliates. All rights reserved.
    * bankmark UG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    ******************************************************************************/
    --><schema xmlns:doc="http://bankmark.de/pdgf/doc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="demo" xsi:noNamespaceSchemaLocation="structure/pdgfSchema.xsd">
      <!-- All data is derived from this starting seed.
           If this seed is the same, the generated data will the same on each
           computer/node/platform.
           Change this seed to generate a different data set.-->
      <!--<seed>1234567890L</seed>-->
      <seed>87467532L</seed>
    
      <rng name="PdgfDefaultRandom"/>
    
      <!--Default Scale factor for all tables -->
      <property name="SF" type="double">1</property>
    
      <table name="SWITCH">
        <!-- if tables should scale with -SF command line argument.
             Specify your scaling formula here: -->
        <size>10 * ${SF}</size>
    
        <!--Static Values based on Numbers-->
          <!--
            Generates either "Cat", "Dog", or "Turtle" based on the output of the underlying LongNumber generator. The
            generator produces "Cat" if the underlying long number is 1, "Dog" if it is 2, and "Turtle" if it is 3.
          -->
          <field name="pet" size="" type="VARCHAR">
            <gen_Switch>
              <gen_LongNumber>
                <min>1</min>
                <max>3</max>
              </gen_LongNumber>
              <case value="1">
                <gen_StaticValue>
                  <value>Cat</value>
                </gen_StaticValue>
              </case>
              <case value="2">
                <gen_StaticValue>
                  <value>Dog</value>
                </gen_StaticValue>
              </case>
              <case value="3">
                <gen_StaticValue>
                  <value>Turtle</value>
                </gen_StaticValue>
              </case>
            </gen_Switch>
          </field>
          </table>
    </schema>
    
    Output for Static Values based on Numbers
    Turtle
    Dog
    Turtle
    Turtle
    Cat
    Dog
    Turtle
    Cat
    Turtle
    Turtle
  2. Static Values based on Numbers with Default Case

    Generates either "Cat", "Dog", "Turtle", or "UNKNOWN" based on the output of the underlying LongNumber generator. The default case is "UNKNOWN" for all numbers other than 1, 2, and 3.

    Schema config for Static Values based on Numbers with Default Case
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
    /*******************************************************************************
    * Copyright (c) 2013, bankmark and/or its affiliates. All rights reserved.
    * bankmark UG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    ******************************************************************************/
    --><schema xmlns:doc="http://bankmark.de/pdgf/doc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="demo" xsi:noNamespaceSchemaLocation="structure/pdgfSchema.xsd">
      <!-- All data is derived from this starting seed.
           If this seed is the same, the generated data will the same on each
           computer/node/platform.
           Change this seed to generate a different data set.-->
      <!--<seed>1234567890L</seed>-->
      <seed>87467532L</seed>
    
      <rng name="PdgfDefaultRandom"/>
    
      <!--Default Scale factor for all tables -->
      <property name="SF" type="double">1</property>
    
      <table name="SWITCH">
        <!-- if tables should scale with -SF command line argument.
             Specify your scaling formula here: -->
        <size>10 * ${SF}</size>
    
        <!--Static Values based on Numbers with Default Case-->
          <!--
            Generates either "Cat", "Dog", "Turtle", or "UNKNOWN" based on the output of the underlying LongNumber
            generator. The default case is "UNKNOWN" for all numbers other than 1, 2, and 3.
          -->
          <field name="pet_default" size="" type="VARCHAR">
            <gen_Switch>
              <gen_LongNumber>
                <min>1</min>
                <max>4</max>
              </gen_LongNumber>
              <default>
                <gen_StaticValue>
                  <value>UNKNOWN</value>
                </gen_StaticValue>
              </default>
              <case value="1">
                <gen_StaticValue>
                  <value>Cat</value>
                </gen_StaticValue>
              </case>
              <case value="2">
                <gen_StaticValue>
                  <value>Dog</value>
                </gen_StaticValue>
              </case>
              <case value="3">
                <gen_StaticValue>
                  <value>Turtle</value>
                </gen_StaticValue>
              </case>
            </gen_Switch>
          </field>
          </table>
    </schema>
    
    Output for Static Values based on Numbers with Default Case
    Cat
    Dog
    Dog
    UNKNOWN
    UNKNOWN
    Dog
    Cat
    UNKNOWN
    Turtle
    Turtle
2.6_#1486_b758 | 2016-05-24