Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mindprod.common11
Class Misc

    java.lang.Object
      com.mindprod.common11.Misc

    public final class Misc

extends java.lang.Object

Simple convenience methods used often by CMP utilities.

Simple enough to work in any JDK1.1+.

Since:
  2003-05-15
Version:
  1.1 2006-03-04
Author:
  Roedy Green, Canadian Mind Products

Method Summary
`static void` | `beep()` makeshift system beep if awt.Toolkit.beep is not available.
`static java.lang.String[][]` | `loadProperties(java.io.InputStream fis)` Load a properties file, but not into a Property hashTable, into an array that does not disturb property order.
`static void` | `main(java.lang.String[] args)` Debug harness
`static int` | `signum(double diff)` Collapse magnitude down to +1, 0 or -1 .
`static int` | `signum(float diff)` Collapse magnitude down to +1, 0 or -1 .
`static int` | `signum(long diff)` alternate to signum for use in compare.
`static int` | `thisDayOfMonth()` Get this day e.g.
`static int` | `thisMonth()` Get this month e.g.
`static int` | `thisYear()` Get this year e.g.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### beep

    public static void beep()

  makeshift system beep if awt.Toolkit.beep is not available. Works also in JDK 1.02.

### loadProperties

    public static java.lang.String[][] loadProperties(java.io.InputStream fis)
                                               throws java.io.IOException

  Load a properties file, but not into a Property hashTable, into an array that does not disturb property order. Returns array of string pairs. Closes the given inputstream. Property file might look like something like this: # com.mindprod.inwords.InWords.properties must live in inwords.jar. # Describes languages supported to translate numbers to words. # Fully qualified classname, (without .class)=name on menu (embedded blanks ok) # Everything is case sensitive. com.mindprod.inwords.Indonesian=Bahahasa Indonesia com.mindprod.inwords.BritishEnglish=British com.mindprod.inwords.Dutch=Dutch com.mindprod.inwords.Esperanto=Esperanto com.mindprod.inwords.AmericanEnglish=North American Vector com.mindprod.inwords.Norwegian=Norwegian com.mindprod.inwords.Swedish=Swedish #-30-

  Parameters:
    `fis` - InputStream from which the properties can be read.
  Returns:
    a matrix of properties, keyword one column and value in the other.
  Throws:
    `java.io.IOException`

### signum

    public static final int signum(long diff)

  alternate to signum for use in compare. Not a true signum, since it returns ints other than +-1. Where there is any possibility of overflow, you should compare two longs with < rather than subtraction. In Pentium assembler you could implement this algorthm with following code:

        diff = edx:eax result = eax
        mov ebx,eax
        shl eax,1
        or  eax,ebx
        slr eax,1
        or  eax,edx

        which would take 5 cycles, 2 more that lohi.  However, JET did even
       better,
        with code essentially this using a clever trick to implement piotr.

         lea    ecx,0(eax,eax)  ; shifts lo left by doubling, keeps copy of
       lo
         or     eax,ecx
         shr    eax,1
         or     eax,edx
        This is 4 cycles, still one more than lohi. Why was Piotr so much
       faster
       on JET?
        Piotr has no pipeline-confounding jumps. Further, the lo then high
       operands actually
        come from the ram-based stack. Piotr nicely separates the accesses
       giving plenty of
        for pre-emptive fetch of hi. lohi insists on having them both
       upfront,
       so it has to wait
        for memory access. Piotr does not have to wait.
        Modern CPUS hurry up and wait for RAM most of the time.

  Parameters:
    `diff` - number to be collapsed to an int preserving sign and zeroness. usually represents the difference of two long.
  Returns:
    sign of diff, some -ve int, 0 or some -ve int. created with Intellij Idea

### signum

    public static int signum(double diff)

  Collapse magnitude down to +1, 0 or -1 .

  Parameters:
    `diff` - number to test.
  Returns:
    positive => +1; 0 => 0; negative => -1.

### signum

    public static int signum(float diff)

  Collapse magnitude down to +1, 0 or -1 .

  Parameters:
    `diff` - number to test.
  Returns:
    positive => +1; 0 => 0; negative => -1.

### thisDayOfMonth

    public static int thisDayOfMonth()

  Get this day e.g. 1=1st of month using default timezone

  Returns:
    dd 1=first day of month.

### thisMonth

    public static int thisMonth()

  Get this month e.g. 1=January using default timezone

  Returns:
    mm 1=Jan

### thisYear

    public static int thisYear()

  Get this year e.g. 2008 using default timezone

  Returns:
    yyyy

### main

    public static void main(java.lang.String[] args)

  Debug harness

  Parameters:
    `args` -

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD