Counting enum elements

Hello,
by which statement/method can the number of elements, defined in an enum, be counted (and returned)?
(Java 5)
Thomas Wiedmann

YourEnum.values().lengthEvery enum class defines a static method values() that returns an array holding the enum members. Take its length.

Similar Messages

  • How to count the elements in a Source whith method count() ?

    hi all,
    I have a Source created by:
    Source s = m1.join(m2).join(m3).join(d1).join(d2);
    m1, m2, m3: MdmMeasure of the same Cube C1
    d1, d2: MdmPrimaryDimension of the same Cube C1
    I want to count the elements in this Source that have values so I used:
    s.count()
    I want to know the result of count() is the number of lines of m1 or m2 or m3?
    Whith the same source like this, can I count the elements of m2?? If it's possible, show me how to do it please!
    Always with the same source, is it possible to know which measure: m1 or m2 or m3 have the most elements not null?
    I can count the elements of each measure then compare its together but in my exercice, I have 20 measures so I find a method that avoid the most request and comparison!
    Thanks for your reply!

    hi all,
    I have a Source created by:
    Source s = m1.join(m2).join(m3).join(d1).join(d2);
    m1, m2, m3: MdmMeasure of the same Cube C1
    d1, d2: MdmPrimaryDimension of the same Cube C1
    I want to count the elements in this Source that have values so I used:
    s.count()
    I want to know the result of count() is the number of lines of m1 or m2 or m3?
    Whith the same source like this, can I count the elements of m2?? If it's possible, show me how to do it please!
    Always with the same source, is it possible to know which measure: m1 or m2 or m3 have the most elements not null?
    I can count the elements of each measure then compare its together but in my exercice, I have 20 measures so I find a method that avoid the most request and comparison!
    Thanks for your reply!

  • To count the elements in this Source

    hi all,
    I have a Source created by:
    Source s = m1.join(m2).join(m3).join(d1).join(d2);
    m1, m2, m3: MdmMeasure of the same Cube C1
    d1, d2: MdmPrimaryDimension of the same Cube C1
    I want to count the elements in this Source that have values so I used:
    s.count()
    I want to know the result of count() is the number of lines of m1 or m2 or m3?
    Whith the same source like this, can I count the elements of m2?? If it's possible, show me how to do it please!
    Always with the same source, is it possible to know which measure: m1 or m2 or m3 have the most elements not null?
    I can count the elements of each measure then compare its together but in my exercice, I have 20 measures so I find a method that avoid the most request and comparison!
    Thanks for your reply!

    Guys - Thanks for the quick response
    Bill - I think you are recommending the approach I had in the submitted code.
    David - the whole point is that I want to use the pipeline, not the Path argument, and I had no luck with your suggestion, which I took as:
            Get-ChildItem $from -Recurse  |
                Where-Object {(New-TimeSpan -Start  $_.LastWriteTime -End $cutoff).TotalHours -le 0} |
                ForEach-Object {Copy-Item -Path $_ -Destination {Join-Path $to $_.FullName.Substring($from.length)}; $fileCount++}
    However, all this did make me go read more documentation, and there is a -PassThru argument to Copy-Item which creates pipeline output after the copy.  Specifically:
            $fileCount=0
            Get-ChildItem $from -Recurse  |
                Where-Object {(New-TimeSpan -Start  $_.LastWriteTime -End $cutoff).TotalHours -le 0} |
                Copy-Item -Destination {Join-Path $to $_.FullName.Substring($from.length)} -PassThru |
                ForEach-Object {$fileCount++}
            Write-Host ("Copied {0} files/folders successfully at {1}" -f $fileCount, $(Get-Date))
    Thanks again
    JonW
    JonW

  • Why enum elements cant be made comparable?

    Is there some special reason or I'm missing something here? Does it mean that the only way to sort a list of enum elements using Collections is by using Comparator class?

    javiator wrote:
    Is there some special reason or I'm missing something here? Does it mean that the only way to sort a list of enum elements using Collections is by using Comparator class?Enums are comparable. You can however not override the method. From the Enum class:
    public final int compareTo(E o)
    Compares this enum with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. Enum constants are only comparable to other enum constants of the same enum type. The natural order implemented by this method is the order in which the constants are declared.

  • @link nested enum elements

    Hi,
    I'm currently stuck in looking for a way to create links to enum elements of a nested enum "class". My code look similar to this.
    package some.package;
    public class MyClass {
        public enum MyEnum {
            FIRST;
    }Now I want to create a link to the FIRST element of the nested enum MyEnum by writing {@link MyClass.MyEnum#FIRST}. But on generation of the HTML JavaDoc complains about an undefined reference to MyClass.MyEnum#FIRST although some.package.MyClass is mentioned in the imports of the class containing the link tag. If I specify the link using the fully qualified name of the enum (i.e. {@link some.package.MyClass.MyEnum#FIRST}) javadoc recognizes the enum an correctly creates the according link.
    Is there any command line switch I have to enable to get this working with the non qualified links, too? Or is this a bug in javadoc?
    Regards
    P.S.: I'm talking about javadoc 1.5.0_11

    I'd also be very interested in an answer to that question. Is this a bug in javadoc or just a question of syntax or settings?
    Although not critical (since specifying fully qualified name is a workaround) it's a little annoying...

  • Xslt/xpath: count preceding elements which starts-with 'S'

    Hi everybody,
    I got the following XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <ROOT>
         <A1>
              <FOO>1</FOO>
         </A1>
         <A1>
              <FOO>2</FOO>
         </A1>
         <B1>
              <FOO>3</FOO>
         </B1>
         <A1>
              <FOO>4</FOO>
         </A1>
    </ROOT>
    I want wo count all preceding Elements of each 3
    How has the experssion has to look?
    count(/ROOT/A1/FOO/preceding::[starts-with(.,'A')])
    DOES not work
    Any suggestions?
    Regards Mario
    Edited by: Mario Müller on Sep 12, 2008 2:23 AM

    Hi Mario,
    What are you using to test xsl expressions?
    I am using XSL Tester, all sugestions that i gave you retrieve a solution. Therefore, this solution will depend from XML tree. For instance if you have something like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <ROOT>
         <A1>
              <FOO>1</FOO>
              <FOO>5</FOO>
                            <A1000>
                                  <FOO>46</FOO>
                           <FOO>400</FOO>
                            </A1000>
              <FOO>300</FOO>
         </A1>
         <A2>
              <FOO>2</FOO>
              <FO>6</FO>
         </A2>
         <B1>
              <FOO>3</FOO>
         </B1>
         <A1>
              <FOO>4</FOO>
              <FO>7</FO>
         </A1>
    </ROOT>
    Using this XSL:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:template match="/">
                <Result>
                   ---- Expression ----
              </Result>
         </xsl:template>
    </xsl:stylesheet>
    Results using the expressions that i gave you, will be:
    1.1
    <xsl:value-of select="count(//FOO[1][starts-with(name(parent::node()),'A')])"/>
    <?xml version="1.0" encoding="UTF-16"?>
         <Result>7</Result>
    1.2
    <xsl:value-of select="count(//FOO[1][starts-with(name(parent::node()),'A')])"/>
    <?xml version="1.0" encoding="UTF-16"?>
        <Result>4</Result>
    2.1
    <xsl:value-of select="count(/ROOT/*/FOO[starts-with(name(parent::node()),'A')])"/>
    <?xml version="1.0" encoding="UTF-16"?>
      <Result>5</Result>
    2.2
    <xsl:value-of select="count(/ROOT/*/FOO[1][starts-with(name(parent::node()),'A')])"/>
    <?xml version="1.0" encoding="UTF-16"?>
        <Result>3</Result>
    I think the last one, fits your solution. Give me more hints, maybe i can help you.
    Best regards,
    Pedro Pereira

  • Count of elements in pipe delimited string

    Hi,
    Is there a way to count the number of elements produced by LISTAGG?
    For instance, if LISTAGG produces:
    Jan, Feb, Mar: output should be 3
    Jan, Mar, Apr, Dec: output should be 4

    LISTAGG is causing the confusion; I updated thread title and removed it.
    Here is an example:
    create table tmp_table (
    delim_str varchar2(100 byte)
    insert into tmp_table values ('Jan|Feb|Mar|Apr');
    insert into tmp_table values ('Jan|Feb|Mar|Apr|May');
    insert into tmp_table values ('Jan|Feb|Mar|Apr|May|June');
    insert into tmp_table values ('Jan|Feb|Mar|Apr|May|June|July');
    Commit;
    Desired Output
    Num_of_months
    Delimited_Months
    4
    Jan|Feb|Mar|Apr
    5
    Jan|Feb|Mar|Apr|May
    6
    Jan|Feb|Mar|Apr|May|June
    7
    Jan|Feb|Mar|Apr|May|June|July

  • BPEL function to query the Element Name and get the count of elements

    Hi Guys,
    I have problem with the following, can you please help me out with this.
    Say i have an xml pay load:
    <ns1:sampleEBO>
                   <ns1:PhysicalLocation>
                   <ns1:propertis>
                        <ns1:filedType>12</ns1:filedType>
                             <ns1:filedType1>12</ns1:filedType1>
                             <ns1:filedType2>12</ns1:filedType2>
    <ns1:filedType3>12</ns1:filedType3>
                             <ns1:filedType4>12</ns1:filedType4>
                             <ns1:filedType5>12</ns1:filedType5>
    </ns1:properties>
    <ns1:propertis>
                        <ns1:filedType>12</ns1:filedType>
                             <ns1:filedType1>12</ns1:filedType1>
                             <ns1:filedType2>12</ns1:filedType2>
    <ns1:filedType3>12</ns1:filedType3>
                             <ns1:filedType4>12</ns1:filedType4>
                             <ns1:filedType5>12</ns1:filedType5>
                   </ns1:properties>
    <ns1:sampleEBO>
                   <ns1:PhysicalLocation>
    Here i want to retrive the Element name ( filedType,fieldType1,fieldType2......) using any BPEL function, not the value and also get the total number of elements in the each node ( <properties> ). If i am using the "count" function its returning 2 and it's counting the properties node not the elements in the properties node.
    So, can you please let me know of any function in BPEL which can do this ?
    Thanks,
    Krish

    you only want to use a default bpel function for this? not from within xsl?
    and the function should return an arraylist of elementnames i assume ?
                   <xsl:for-each select="//properties">
                        <xsl:for-each select="./*">
                             <xsl:value-of select="local-name()"/>
                             <xsl:choose>
                                  <xsl:when test="substring(local-name(),1,9) ='filedType' ">
                             </xsl:when>
                             </xsl:choose>
                        </xsl:for-each>
                   </xsl:for-each>
                   <count1><xsl:value-of select="count(//properties[1]/*)"/></count>
                   <count2><xsl:value-of select="count(//properties[2]/*)"/></count>the count can also be used in some for-each construction or from within your bpel flow itself (if you want to loop over there, instead of xsl)

  • Problem getting the count of element

    Hi all,
    I am using a webservice which converts excel to string, which i store in an variable. I parse this variable using to parseXML function and assign it to and element type. The element is created from xsd. The xsd is created from the output of the webservice.
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    targetNamespace="http://TargetNamespace.com/IncomngCS"
    xmlns:tns="http://TargetNamespace.com/IncomngCS"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified" nxsd:encoding="ASCII" nxsd:stream="chars" nxsd:version="NXSD">
         <xsd:element name="SHEET">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element name="ROW" maxOccurs="unbounded">                    <xsd:complexType>
         <xsd:sequence>
                                       <xsd:element name="DATESRV" type="xsd:string"/>
                                       <xsd:element name="TACT" type="xsd:string"/>
                                       <xsd:element name="TCHG" type="xsd:string"/>
                                       <xsd:element name="TAMNT" type="xsd:string"/>
         <xsd:element name="TQTY" type="xsd:string"/>
         </xsd:sequence>
         </xsd:complexType>
         </xsd:element>
         </xsd:sequence>
    <xsd:attribute name="currentrow"/>
         </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    The variable of element type gives output as
    <var_tmp>
    <SHEET>
    <ROW>
    <DATESRV>2/3/2006</DATESRV>
    <TACT>100561141</TACT>
    <TCHG>3403516</TCHG>
    <TAMNT>249.55</TAMNT>
    <TQTY>1</TQTY>
    </ROW>
    <ROW>
    <DATESRV>2/3/2006</DATESRV>
    <TACT>100561141</TACT>
    <TCHG>3400934</TCHG>
    <TAMNT>72.55</TAMNT>
    <TQTY>1</TQTY>
    </ROW>
    <ROW>
    <DATESRV>2/3/2006</DATESRV>
    <TACT>100567114</TACT>
    <TCHG>3406931</TCHG>
    <TAMNT>34.5</TAMNT>
    <TQTY>1</TQTY>
    </ROW>
    </SHEET>
    <var_tmp>
    And now when i try to get the count(getVariableData('var_tmp','/sheet/row')) it always gives me 0. I tried to get particular row using index its still does not seem to work.
    Does anybody have any idea about this problem?

    Can you post your .bpel source so I can see what's going on there?
    Thanks
    Dan

  • Wie kann ich aus einem Enum Element den Text (Beschriftung) fuer den Wert 2 extrahieren und einem StringElement zuweisen?

    oder aus einem Ring Element

    Hallo nobby,
    das geht sehr einfach:
    rechts klick auf das terminal der ENUM (oder des Ring)
    ->create->property node (keine ahnung wie das auf deutsch heisst, wahrscheinlich eigenschaftsknoten oder aehnlich komisch)
    Als erste eingenschaft erhaelst Du "visible". Jetzt liks klick auf das visible und aus der liste "strings[]" auswaehlen. dieses array enthaelt alle textbezeichnungen des ringes oder der enumeration.
    Aus diesem array musst Du nur noch das Dich interessierende Element auswaehlen.
    Wenn Du die property node um ein feld erweiterst (auf untere Kante klicken und nach unten ziehen) kannst Du noch "Value" auswaehlen. Dort steht der aktuelle Wert drin. Verbidest Du jetzt "Value" und das array mit Index Array aus der Array Palette, so erha
    elst Du den Text des aktuellen Wertes. (Oder Du benutzt statt "Value" fest den Wert 1, dann eben immer der Text des zweiten Elementes. Denn die Indizierung beginnt mit 0.)
    Das bindest Du jetzt entweder an einen String-Indikator an oder an die lokale Variable eines String-Controls.
    MfG
    Rainer
    Attachments:
    ring-enum.vi ‏27 KB

  • Counting xml elements using javascript

    How can I count the number of certain xml elements inside the xml file that import.
    Example xml:
    <list>
         <product>
              <name>Product_01</name>
              <detail>info here</detail>
         </product>
         <product>
              <name>Product_02</name>
              <detail>info here</detail>
         </product>
         <product>
              <name>Product_03</name>
              <detail>info here</detail>
         </product>
    </list>
    I would like to count the number of product -elements in this example xml.
    I'm using javascript for scripting.
    Thanks.

    #target indesign
    #include "/Applications/Adobe InDesign CS3/Scripts/Xml Rules/glue code.jsx"
    var myDocument = app.activeDocument;
    var myCounter = 0;
    var myRuleSet = new Array (new ProcessProduct);
    with(myDocument){
        var elements = xmlElements;
        __processRuleSet(elements.item(0), myRuleSet);
    alert("Found " + myCounter + " product elements");
    function ProcessProduct(){
        this.name = "ProcessProduct";
        this.xpath = "//product";   
        this.apply = function(myElement, myRuleProcessor){
            with(myElement){
                myCounter++;
        return true;

  • How to count the elements with values in a Source?

    I have 2 measures which needs the same dimensions as inputs. So i use "Source.join()" to fill the inputs of both the measures like this:
    Source result = m1.join(m2).join(d1).join(d2);
    m1, m2: the "Source"s of the "MdmMeasure"s
    d1, d2: the "Source"s of the "MdmPrimaryDimension"s
    So before retrieving the results, i want to know how many lines i'm gonna have:
    Source resultCount = result.count();
    Here is my problem : the 2 measures have "NA"(1) but not the same "line" of data, and count returns the number of lines with data for the first measure (m1).
    I would like to have the number of lines which have data in at least 1 measure.
    example:
    | d1 | d2 | m1 | m2 |
    | a | b | 1 | 2 |
    | b | c | NA | 2 |
    | b | c | 4 | NA |
    | b | c | NA | NA |
    right now, i get 2, but i would like to get 3
    Can you help me please?
    NA(1) : when ValueCursor.hasCurrentValue() return false.
    Source(2) : http://oraclesvca2.oracle.com/docs/cd/B14117_01/olap.101/b10994/oracle/olapi/data/source/Source.html

    You have to put table name in Capital letters
    Like
    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = 'EMP';
    or
    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = UPPER('Emp');Regards
    Arun

  • I want to count the elements in the pipeline and also process them

    The following script works, but only because I save the pipeline contents in a variable.  I would like to not have to save it - see below. The commented section is my most recent failure. (And BTW I know the script has nothing to do with ZIP: that's
    the next step.
    function ZipUpModified {
        param ([string] $from, [string]$to, [datetime]$cutOff)
        try
            Write-Host ("Copying {0} modified on or after {1} to {2} in execution at {3}" -f $from, $cutOff.toString(), $to, $(Get-Date))
            if (-not (Test-Path -Path $from)) {Throw "Source folder $from does not exist"}
            if (Test-Path -Path $to) {Throw "Target folder $to already exists"}
    # I would like to substitute the next 5 lines for the following 4; but I cannot seem to get the pipeline to reach the Copy_Item
    #       $fileCount=0
    #        Get-ChildItem $from -Recurse  |
    #            Where-Object {(New-TimeSpan -Start  $_.LastWriteTime -End $cutoff).TotalHours -le 0} |
    #            ForEach-Object {Copy-Item -Destination {Join-Path $to $_.FullName.Substring($from.length)}; $fileCount++; }
    #        Write-Host ("Copied {0} files/folders successfully at {1}" -f $fileCount, $(Get-Date))
            $filelist=Get-ChildItem $from -Recurse  |
                Where-Object {(New-TimeSpan -Start  $_.LastWriteTime -End $cutoff).TotalHours -le 0}
            $filelist | Copy-Item -Destination {Join-Path $to $_.FullName.Substring($from.length)}
            Write-Host ("Copied {0} files/folders successfully at {1}" -f $filelist.count, $(Get-Date))
        catch
            Write-Host $($_.Exception.ToString() -replace ".*: ")
            Write-Host "so we are stopping..."
        finally
            $IgnoreThis = Read-Host "hit OK or Enter"
    ### Main
    $cutOff= (Read-Host 'Enter date of most recent backup (mm/dd/yyyy):') | Get-Date
    ZipUpModified "C:\Users\Jonathan\Desktop\Test_BU\SRC" "C:\Users\Jonathan\Desktop\Test_BU\TGT" $cutOff
    ## two more calls to ZipUpModified

    Guys - Thanks for the quick response
    Bill - I think you are recommending the approach I had in the submitted code.
    David - the whole point is that I want to use the pipeline, not the Path argument, and I had no luck with your suggestion, which I took as:
            Get-ChildItem $from -Recurse  |
                Where-Object {(New-TimeSpan -Start  $_.LastWriteTime -End $cutoff).TotalHours -le 0} |
                ForEach-Object {Copy-Item -Path $_ -Destination {Join-Path $to $_.FullName.Substring($from.length)}; $fileCount++}
    However, all this did make me go read more documentation, and there is a -PassThru argument to Copy-Item which creates pipeline output after the copy.  Specifically:
            $fileCount=0
            Get-ChildItem $from -Recurse  |
                Where-Object {(New-TimeSpan -Start  $_.LastWriteTime -End $cutoff).TotalHours -le 0} |
                Copy-Item -Destination {Join-Path $to $_.FullName.Substring($from.length)} -PassThru |
                ForEach-Object {$fileCount++}
            Write-Host ("Copied {0} files/folders successfully at {1}" -f $fileCount, $(Get-Date))
    Thanks again
    JonW
    JonW

  • Xsl count the elements with value x

    Hello,
    I'm trying to set up a transformation command in a stylesheet to get the number of nodes in a xml file that have a certain value. For the following xml source
    <root>
    <a>OK</a>
    <a>FAIL</a>
    <a>OK</a>
    </root>
    I would like to create html output like this
    ok=2
    fail=1
    I've searched the xpath reference but the best match to get this done was the count() function that doesn't seem to be able to select on value level.
    Can anyone help ?
    Thanks.

    count(//*[text()='OK'])
    or something like that (with the predicate) is what you are looking for.

  • Help with counting XML elements and converting from MS SQL 2008 to ORACLE

    Hello,
    My ORACLE DB version is:
    ('Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production');
    ('PL/SQL Release 11.2.0.2.0 - Production');
    ('CORE     11.2.0.2.0     Production');
    ('TNS for Linux: Version 11.2.0.2.0 - Production');
    ('NLSRTL Version 11.2.0.2.0 - Production');
    I'm trying to convert the below SQL Server 2008 query to work on Oracle. It's important to note that the XMLData column type is CLOB.
    Query 1)
    -- Number of validations
    select br.rulename, CAST(( CAST(br.XMLData as XML)).query('count(//Validation/Expressions/Expression)') as nvarchar(50)) as "Number of //Validation/Expressions/Expression"
    from AsBusinessRules br
    where
    DATALENGTH(br.XMLData)>10
    and CAST(( CAST(br.XMLData as XML)).query('count(//Validation/Expressions/Expression)') as nvarchar(50)) not like '0'
    Any help is greatly appreciated.

    Hi,
    You can try one of these :
    select br.rulename
         , count(*) as "Num. of Expression"
    from AsBusinessRules br
       , xmltable(
           '//Validation/Expressions/Expression'
           passing xmltype(br.XMLData)
         ) x
    where length(br.XMLData) > 10
    group by br.rulename
    having count(*) != 0
    ;or,
    select br.rulename
         , xmlcast(
             xmlquery(
               'count(//Validation/Expressions/Expression)'
               passing xmltype(br.XMLData)
               returning content
             as number
           ) as "Num. of Expression"
    from AsBusinessRules br
    where length(br.XMLData) > 10
    and xmlcast(
          xmlquery(
            'count(//Validation/Expressions/Expression)'
            passing xmltype(br.XMLData)
            returning content
          as number
        ) != 0
    It's important to note that the XMLData column type is CLOB.Could you consider migrating the column to XMLType datatype?
    Given your version, it would be binary XML by default and therefore a lot more performant with XQueries, compared to a simple CLOB storage.

Maybe you are looking for

  • Can't access my ovi account

    My blackberry phone can't access my ovi.com account and it requires me to verify my password but wen I do it say my password is invalid where els I just logged in with the ame password nw

  • Application help problem

    Hello guru's, In my sap system application help is not comming.can u anybody plz  help me out. wht parameters i need to maintain to get the application help. it shows the below error message: Please check the entries in the file sapdoccd.log in the w

  • Invisible Table Columns

    Hi, first, I am a total beginner in Web Dynpro and ABAP. In a view I create a context node, a ui table element and an internal table which is bound to the context node dynamically. I took an example to do this from a developers website. Now, I want t

  • Failure of hp 8600 plus to install on mavericks OS

    I have tried to install my new HP 8600plus wireless printer somftware on my mavericks OS mac and it has failed to finalize installation 3 times, everytime when trying to communicate wirelessly with the printer. any suggestions before I bring this bac

  • Low speed of hard disk while copying or deleting files

    Why I am a heavy file copy, past my system is very slow? tazik wrote:/dev/sda: Timing cached reads:   20482 MB in  2.00 seconds = 10253.69 MB/sec Timing buffered disk reads: 374 MB in  3.02 seconds = 124.01 MB/sec [ali@Arch ~]$ sudo hdparm -t /dev/sd