Using " " and " " to compare enum's ordinals ?

heya,
I'm just wondering if it's possible to use the "<" and ">" operators with enum types in Java 1.5, in order to compare ordinal values.
Basically, I'm thinking of using this for security levels, as in:
public enum SecurityLevel { admin, manager, staff, user }and later on, in the methods, you check whether the SecurityLevel is equal to or above a certain level
if (curr_seclev > manager) {
     //We perform the action
} else
     //Security level not high enough..we throw an exception? Or is there a better way to handle this?
}Or if you could recommend a better way of achieving this, that would be cool =).
Thanks,
Victor

heya,
Thanks to all for the great replies =).
enum SecLevels { admin, manager, staff, user };
SecLevels iamauser = SecLevels.user;
if (curr_secLevel.ordinal() < iamauser.ordinal()) {
     System.out.println("blah");
}works great. However, this means I need to have a "iamauser" enum object to compare whatever I am comparing to. I tried using SecLevel.admin.ordinal(), to see if I can use ordinal() on the enum itself, but that fails with
EnumOrds.java:15: cannot find symbol
symbol  : method ordinals()
location: class EnumOrds.SecLevels
                if (SecLevels.admin.ordinals() < SecLevels.user.ordinals()) {Is there any other way of evaluating up the ordinal for a enum constant without having to create an object first?
Thanks,
Victor

Similar Messages

  • Two questions:  how do Skype and iChat compare for group video?  quality, reliability, cost, etc are important.  2) Is my MobileMe ID what I need to use in the window in making an iChat buddy?  It only says AIM above the window, online tutorial differs.

    Two questions:  1) How do Skype and iChat compare for group video?  Quality, reliability, cost, etc are important.  2) Is my MobileMe ID what I need to input in the window in making an iChat buddy?  It only says AIM above the window, online tutorial differs, saying MobileMe, AIM, GoogleTalk (Jabber) all work. Thnx

    Hi,
    IChat uses better Video Compression than Skype does.
    On a top flight Mac you can send a 640 X 480 pixel frame up to 30 frames a sec.
    Skype can't match this.
    iChat in Video is Peer to Peer. (you can actually Log out of the Buddy list)
    Skype seems to borrow something from everyone's bandwidth to make connections.
    What do you mean by Business account Tracking ?
    iChat Adds (or can add) the First Name, Last Name of your Buddies and create an Address Book Entry
    Whether you mark those cards connected with a  company is up to you.
    (I have heard of issues with earlier version of iChat and the Address Book that "saw" the Company Name as the part of the Name and linking several Screen Names to the one name
    Audio on a Mac using Skype tend to be the same as the streaming needs are less.
    However you have to rely on any PCs audio abilities from PCs which may not be to the same standard.
    Mac to PCs in iChat and AIM can be difficult though.  (It should work but it rarely as simple as Plug and go)
    Skype may suit your needs better on ocassions.
    9:11 PM      Thursday; May 5, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb( 10.6.7)
    , Mac OS X (10.6.7),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Are there pros and cons to using TFS as compared to Sharepoint?

    are there pros and cons to using TFS as compared to Sharepoint?

    TFS and SharePoint are two different products with overlapping functionality.
    If you are planning to use TFS for Application Lifecylce management, then I would not suggest SharePoint replacing TFS.
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • Is anyone out there finding OSX Lion a disappointment compared to previous Mac OS?  After nearly 20 yrs of using and enthusing about AppleMac, I am suddenly not enthused.  What am I missing?

    Is anyone out there finding OSX Lion a disappointment compared to previous Mac OS?  After nearly 20 yrs of using and enthusing about AppleMac, I am suddenly not enthused.  What am I missing?

    You're not heavy on specifics on what you don't like.
    Most people have little technical expertise but are wanting more and more, requiring more complex computers, ideally ending up with one from Star Trek where you basically don't have to know anything how to really use a computer and it just provides you with the exact answer you need to a not particularly well-phrased query.  If you're missing things like configuration options and the rest, well frankly I think many people are happy not to have to make complicated decisions for themselves such as in which opening do they insert a system installer disc.

  • How can I use the hardware compare feature of the 6551 card to trigger scripts

    I can dynamically and seamlessly generate different waveforms by triggering different scriptTriggers that drive one or more of the 4 PFI lines. However, I need to evaluate a channel at a specific location or locations set by a script marker in real-time and generate a different waveform stored in on-board memory based on the result of the evaluation. I have attempted to use the hardware compare feature without any success. I am trying to dynamically respond to an I2C device based on the ACKs or NACK response of the device under test. Can the 6551 card accomplish this? Has anyone successfully tested an I2C or SMBus communication stream with 6551 card?

    Hello,
    I can understand why hardware compare did not work out for you application.  Hardware compare uses a signal that was generated to make a digital pattern and then waits a few clock cycles before acquiring the signal that needs to be compared to the digital pattern. 
    I would look into using a script trigger to evaluate the channel value, where the script structure controls when it is evaluated.  Please note that script triggers will need to be cleared after they are detected for reasserting.  Some script syntax actually clear the script trigger and then use a wait until script trigger structure.  Please refer to the HS DIO Help for documentation on Common Scripting Use Cases. 
    Please provide us with further details about your application.  The more information, the better!  I was not too clear on what you where wanting to evaluate and where is it coming from. 
    I would also like to mention that National Instruments has a NI USB 8451 which is capable of I2C communication.
    NI USB 8451
    Samantha
    National Instruments
    Applications Engineer

  • How to use a custom comparator in a TableSorter?

    Hi,
    I want to use a custom comparator for sorting a table by a specific column.
    As you possibly know, the constructor for the TableSorter class looks like this:
    TableSorter(IWDTable table, IWDAction sortAction, Map comparators);
    As Map is an Interface I chose Hashmap as comparator container. So, I use the put(Key, Value) method to insert my own comparator into the Hashmap in order to deliver this Object to the TableSorter constructor.
    But there is an essential problem:
    I assume, that the column which is to be associated with my comparator is determined by the key of the Map object from the TableSorter constructor.
    Presuming this, <u>what should the map key be/look like?</u>
    An Integer counted from the columns? The column header as String? Whatever? Or am I on the wrong way?
    PS:
    Hours of search did not lead me to some kind of documentation or javadoc of the TableSorter class! This can't be, does someone have a link please?
    Thanks a lot for any help.

    (sorry Mrutyun, this did not help.)
    Ok, I solved it; let me share it with you:
    public class ExampleView
            public static void wdDoModifyView(IPrivateExampleView wdThis, IPrivateExampleView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
                     * A custom Comparator class is used for sorting by Severity.
                     * An Object of it is delivered to an object of a Map class to be delivered to the TableSorter constructor.
                     * The Map class consists of key-value pairs, and the TableSorter must accept the Key of it
                     * because he uses it to assign the mapped Comparator to the column of the table to be sorted!
                     * And this is done with the ID of the Element, which shall be sorted with the Comparator, used as Map Key.
                     * All other columns of the assigned tables will be sorted by default Comparators.
                    IWDTable table = (IWDTable) view.getElement("[TableName]");
                    HashMap tableComps = new HashMap();
                    tableComps.put(view.getElement("[ColumnName]").getId(), new MyComp(wdContext.currentExampleElement())); //The map key value I looked for is the ID of the Element of the Column!
                    wdContext.current/*yourContextNode*/Element().setTableSort(
                            new TableSorter(table, wdThis.wdGetSortTableRowAction(),
                                    tableComps)); //Insert HashMap with the new Comparator
            public void onActionSortTableRow(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
            //@@begin onActionSortTableRow(ServerEvent)
                            wdContext.currentConfigurationElement().getTableSort().sort(wdEvent, wdContext.nodeOpenIncident());
            //@@end
    As you see, the Column which is to be sorted by the custom Comparator "MyComp", is clearly assigned to it. Thus, is will only be used when sorting by this column is done.
    The "inActionSort" method is as usual.
    My Comparator sorts a column which contains variables of a "SimpleType" with an enumeration. (If you need help with this, feel free to write me.) To achieve this, the Comparator needs to know what this SimpleType consists of. That's why I deliver this Element per Constructor to it.
    public class MyComp implements Comparator
         MappedNodeElement element;
         public SeverityComp(I/*one*/Element element)
              this.element = element;
         public SeverityComp(I/*another*/Element element)
              this.element = element;
         public int compare(Object severity1, Object severity2)
    Because MappedNodeElement is such abstract, it can be used by several different Tables, provided they use the same SimpleType.
    Concerning my quest for this resolution, I hope this is helpful.
    null

  • In testing 9 and X, "Compare Docs" we have a critical issue and really need help!

    For years we have used Acrobat 7 to do PDF compares and we love it!  However, the company recently advised we must upgrade to 9 and then eventually to X.  In testing 9 and X, Compare Docs we have a critical issue and really need help.  Our PDFs are produced by IT in a batch process and one of our main, critical functions is to compare previous PDFs to current PDFs;  however, in using 9 the Compare screen automatically sets the Doc Description for our PDFs to "Scanned Doc" and does not produce any differences! If you try to change the setting to Reports --it totally shuts down both documents without running!  Version 7 runs the compare of the same PDFs  beautifully, pointing out all the differences, as usual!  Has this every happen to anyone?  Do you know what we can do to our PDFs to allow version 9 to do the compare and produce results?  Why is 9 treating these non-scanned PDF docs as such?  Thanks so much for any help or insight you can give me on this issue! 

    (Moved the discussion to the correct forum)

  • When I OCR two versions of the same document and then compare th documents in Acrobat Pro XI, I usually get the message that there are no changes to mark.  However, I know there a quite a few number of changes.  I raised this question more than a year ago

    When I OCR two versions of the same document and then compare the documents in Acrobat Pro XI, I usually get the message that there are no changes to mark.  However, I know there a quite a few number of changes.  I raised this question more than a year ago, and the response I received had to do with the quality of the OCR and the scans of the documents.  However, if I use Acrobat Pro XI to save the same documents in Word and then run a comparison in Word all of the changes are marked.  When a PDF is saved as a Word document in Acrobat Pro XI, is a different OCR module being used than the one used in Acrobat Pro XI for text recognition?

    OCR is only for recoginition of the image / picture of text provided by an scanner.
    Content typed into a Word file which is converted to a PDF is (in Word and in PDF) *not* an image  or picture of text - it is the digital text. So, no OCR involved.
    When the "digital" (renderable) text of a PDF's page content is exported to Word no OCR is involved.
    When a PDF's content is from the image output of a scanner and this is a picture of text then OCR comes into play.
    If this content is exported to Word before doing OCR then it is the image that is exported to the Word file.
    Once OCR is performed it is the OCR output that is exported.
    OCR output is (always will be) impacted by "the quality of the OCR and the scans of the documents". 
    Regardless "Compare" is based on a Word file output to PDF1 then edits to the Word file followed by an output to PDF2. You use Acrobat Pro to do a compare of PDF1 & PDF2.
    Paper 1 scanned to image 1 to image 1 in PDF1 that gets OCR 1 and
    Paper 2 scanned to image 2 to image 2 in PDF2 that gets OCR 2
    being processed with Acrobat Pro's Compare can certainly be done.
    But - well you've described what can be observed.
    Be well...

  • When to use abstract class compared to interface

    hi
    can some one plase advise me when to use abstract class compared to interface?
    Example will be appreciated...

    So an abstract class can carry implementation. This can be used to formulate a rule of thumb as to when to use it over an interface.
    If you have a so called type specialization relationship between the subtypes and the supertype then they're likely to benefit from shared implementation provided by the supertype, so use class (abstract or concrete) extension in this case. Type specialization is when the supertype represents a general concept like Fruit and the subtypes are specialized forms of that like Apple and Banana.
    Another common kind of relationship is called type expansion. In this case the subtypes are unlikely to have any use of implementation provided by the supertype, so use interface implementation. Type expansion is when the supertype represents a specific character the subtypes take on. For example Apple and Bicycle ure unrelated in the type specialization sense but still can share a common character like Comparable. The subtypes have been expanded to include the supertype character, namely the ability to be compared.

  • Reading lines and then comparing them

    Hi,
    I want to read two lines of a single file and then compare them. Right now, I've implemented:
    String line = null;
    String currentLine = null;
    String prevLine = null;
    BufferedReader bf = new BufferedReader(new FileReader(fileA));
    while ((line=bf.readLine()) != null)
                currentLine = line;
                prevLine = line;
            }I understand that this code returns the same line, but I was just hoping that maybe someone could point me in the right direction. Thanks in advance.

    800343 wrote:
    remember to use .equals() for equality comparisons. For comparing objects' states (contents), yes, absolutely. That's what it's for.
    The == tends to act funny, even in situations where it should obviously work.No it doesn't. It works exactly as it's supposed to. It compares the value on the left side to the value on the right side. Always. Whether those values are primitives or references, it behaves the same way.

  • [svn:bz-trunk] 21292: Fix BLZ-639 - avoid the use of "==" when comparing strings.

    Revision: 21292
    Revision: 21292
    Author:   [email protected]
    Date:     2011-05-25 12:09:39 -0700 (Wed, 25 May 2011)
    Log Message:
    Fix BLZ-639 - avoid the use of "==" when comparing strings.  Just check for null explicitly.
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-639
    Modified Paths:
        blazeds/trunk/modules/common/src/flex/messaging/config/ClientConfiguration.java

    Adobe has donated BlazeDS to the Apache Flex community, and the source code is hosted on the Apache Flex website in a GIT repository.
    http://flex.apache.org/dev-sourcecode.html

  • Apparently I have MULTIPLE Apple ID's, many linked to very old computers/emails that I no longer use and I have no clue what they are nor what the passwords could possibly be. I just want to be able to listen to music THAT I OWN!

    I am trying to play music on my iTunes that I had burned from either CD's that I had bought & own (in order to preserve the CD from damage and it is all only for my personal use) or purchased through iTunes. Much, but not all of this was done on an old computer, and on old e-mails that no longer exist, and for that matter I have no clue what the passwords could possibly be! The computer that I use now is at least 10 years old, so how am I supposed to remember passwords from that long ago? I am constantly being told to reset my password, but that apparently just seems to compound the issue. One account will not even accept my birthday and my security question which I know with 100% certainty are correct. I JUST WANT ACCESS TO MUSIC I OWN OR HAVE PURCHASED over the past 20+ years, and I don't care what computer I did it on or what e-mail address I used, and forget about trying to recall my password! Apple makes it so difficult to do passwords it's ridiculous! I would need a book to write down every password that I have tried, and apparently not succeeded in using! add to my frustration is that my son put literally TONS of his music onto my computer and used his various Apple ID's and passwords, and it's just a bumble cluck of a mess. AGAIN, I only want access to MY MUSIC!

    You're supposed to remember them or make note of them because they are key to a resource in which you have invested financially, just like keeping records for bank accounts you have or keys to your car.  It is just that people haven't woken up to the importance of having a digital legacy too.
    Here are resources for forgotten passwords:
    https://iforgot.apple.com/
    http://www.apple.com/support/appleid/contact/
    Contact Apple for help with Apple ID account security - http://support.apple.com/en-us/HT5699 "This article provides country-specific Apple Support contact information for customers seeking help with their Apple ID password or other security-related issues."

  • I need to do a clean install of maverick on my 2010 mbp what disk do i use and how do i move certain files from an external hard drive

    I want to do a clean install of maverick on my 2010 mbp.  I need to know what disk to use and also how i take certain files off my external hard drive and put on my computer.  When I was having problems with my airport they did a clean install and they pulled files of my time machine.   however they forgot to put the partition back in for a windows side.  Originally I had Parellels on my computer.  After my external hard drive got corrupted i called apple and they fixed the problem but didn't have me set up the time machine except for the external hard drive.  Now my only back up is from the external not from the laptop.    I am not sure how to do any of this.  I am not computer savvy...PLEASE I NEED  HELP>

    First, you need to make a backup of your MBP onto your external drive. I suggest you start by cloning your MBP drive to the external drive:
    Clone Mavericks, Lion/Mountain Lion using Restore Option of Disk Utility
    Boot to the Recovery HD:
    Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
         1. Select Disk Utility from the main menu then press the Continue
             button.
         2. Select the destination volume from the left side list.
         3. Click on the Restore tab in the DU main window.
         4. Select the destination volume from the left side list and drag it
             to the Destination entry field.
         5. Select the source volume from the left side list and drag it to
             the Source entry field.
         6. Double-check you got it right, then click on the Restore button.
    Destination means the external backup drive. Source means the internal startup drive.
    This clone is fully bootable and also contains a clone of your Recovery HD.
    Second, you need to do a clean install of OS X onto your MBP as follows:
    Install or Reinstall Mavericks or Mountain Lion from Scratch
    Be sure you backup your files to an external drive or second internal drive because the following procedure will remove everything from the hard drive.
    OS X Mavericks- Erase and reinstall OS X
    OS X Mountain Lion- Erase and reinstall OS X
    OS X Lion- Erase and reinstall Mac OS X
    Note: You will need an active Internet connection. I suggest using Ethernet if possible
                because it is three times faster than wireless.
    This should accomplish your goals. You will have a clean install of OS X on your MBP and a bootable clone of your old system and all your files on the external drive.

  • I am getting frequent lock-ups and blue screens during boot up. The lock ups occur during normal use and I cannot click anything or force quit. The cursor shows something is loading, but never stops. I have to use power button. Ideas?

    I am getting frequent lock-ups and blue screens during boot up on my Mac Pro.  The lock- ups occur sometimes during normal use and I cannot click anything or force quit. The cursor shows something is loading, but never stops. I have to use power button.
    I had the Mac Defender malware and I have used apple jack but still having issues.

    I am getting frequent lock-ups and blue screens during boot up on my Mac Pro.  The lock- ups occur sometimes during normal use and I cannot click anything or force quit. The cursor shows something is loading, but never stops. I have to use power button.
    I had the Mac Defender malware and I have used apple jack but still having issues.

  • I have a contact I no longer use and have deleted it from Contacts on my iMac and iPad, but it still keeps appearing in the To: box when I enter a similar contac, obote the iMac and iPad. How do I completely delete it to prevent this from happening? Thank

    I have a email address I no longer use and want, so have deleted it from my address book on my iMac and iPad. It kept reappearing when I started to type a similar email address, so I was advised to delete it by going to Mail on the iMac...  Mail > Window > Previous Recipients... and Delete from there... which worked, and it now no longer appears in the To: box when typing a similar email address in Mail on my iMac.
    However, even though I have deleted the same contact/email address on my iPad, it still appears when typing a similar email address in Mail on the iPad. How do I perform a similar action as I did on my iMac, to prevent it from reappearing?
    Hope someone can help.
    Thanks, Simon.
    On the iMac..

    The only way that I currently know of to remove old and invalid email addresses on the iPad is to restore back to factory defaults, which I assume that you won't want to do. You could try leaving feedback for Apple, and maybe in a future update we'll be able to edit them : http://www.apple.com/feedback/ipad.html

Maybe you are looking for

  • Take too much time to convert QT movie to iPod format

    Hi, I got QuickTime Pro and was able to convert avi format home video to iPod (mpg4). But for a 30 minutes movie, it took more than 8 hours to convert (From avi to mpg4) and QT consume 90% CPU all the time. Is there something wrong with my settings?

  • Totem Movie Player not playing files online

    well Hello. I have one problem, when i try to play Video online, like this site: http://www.lrt.lt/ltv-LT-high.asx (it's for Lithuanian users) tv online, to watch olimpiad, i get nothing, it just auto cancel playing. Well then i tryed to add that Lin

  • User exit to set user status

    Hi, We have a requirement to implement our own status management for SD orders. I have configured a new SD item object status profile in transaction BS02. Now I need to program the logic to update the item object status when the user is saving the sa

  • Song order on albums

    My iPod always displays the wrong order of songs for particular albums. I tried connecting it to the computer and changing the song order via iTunes but it was correct on iTunes. Went back to iPod and it is still the wrong song order on those albums.

  • App Store set for UK how do I change settings back to US?

    Every time I try to download an app it tells me I cannot download from App Store UK change settings. I've went into settings and I don't see anywhere to change it. Help?