コード例 #1
0
 public final void setTimeAsArray(String key, Date value) {
   JsArrayInteger jsArray = JavaScriptObject.createArray().cast();
   jsArray.set(0, value.getHours());
   jsArray.set(1, value.getMinutes());
   jsArray.set(2, value.getSeconds());
   set(key, jsArray);
 };
コード例 #2
0
 public final void setDateAsArray(String key, Date value) {
   JsArrayInteger jsArray = JavaScriptObject.createArray().cast();
   jsArray.set(0, value.getYear());
   jsArray.set(1, value.getMonth());
   jsArray.set(2, value.getDate());
   set(key, jsArray);
 };
コード例 #3
0
ファイル: DataOutput.java プロジェクト: rareddy/console
 public void writeFloat(float v) throws IOException {
   growToFit(4);
   JsArrayInteger bytes = IEEE754.fromFloat(v);
   for (int i = 0; i < 4; i++) {
     this.bytes[pos++] = (byte) bytes.get(i);
   }
 }
コード例 #4
0
ファイル: BitSet.java プロジェクト: nikoliazekter/artemis-odb
  public void and(BitSet set) {
    // a & a is just a
    if (this == set) {
      return;
    }

    // trim the second set to avoid extra work
    trimToSize(set.array);

    // check if the length is longer than otherLength
    int otherLength = set.array.length();
    if (array.length() > otherLength) {
      // shrink the array, effectively ANDing those bits to false
      setLengthWords(array, otherLength);
    }

    // truth table
    //
    // case | a | b | a & b | change?
    // 1 | false | false | false | a is already false
    // 2 | false | true | false | a is already false
    // 3 | true | false | false | set a to false
    // 4 | true | true | true | a is already true
    //
    // we only need to change something in case 3, so iterate over set a
    int index = 0;
    while ((index = nextSetWord(array, index)) != -1) {
      setWord(array, index, array.get(index) & getWord(set.array, index));
      index++;
    }
  }
コード例 #5
0
ファイル: DataOutput.java プロジェクト: rareddy/console
 public void writeDouble(double v) throws IOException {
   growToFit(8);
   JsArrayInteger bytes = IEEE754.fromDouble(v);
   for (int i = 0; i < 8; i++) {
     this.bytes[pos++] = (byte) bytes.get(i);
   }
 }
コード例 #6
0
ファイル: Slider.java プロジェクト: jspacco/CloudCoder
 private int[] jsArrayIntegerToIntArray(JsArrayInteger values) {
   int len = values.length();
   int[] vals = new int[len];
   for (int i = 0; i < len; i++) {
     vals[i] = values.get(i);
   }
   return vals;
 }
コード例 #7
0
ファイル: OrgUnitJS.java プロジェクト: sajeeshnl/sigmah
  public static JsArrayInteger toArray(Set<OrgUnitDTO> children) {
    if (children == null) {
      return null;
    }

    final JsArrayInteger array = (JsArrayInteger) JavaScriptObject.createArray();
    for (final OrgUnitDTO child : children) {
      array.push(child.getId());
    }
    return array;
  }
コード例 #8
0
 public final Date getTime(String key) {
   String type = getType(key);
   if ("array".equals(type)) {
     JsArrayInteger jsAray = getNativeValue(key).cast();
     Date date = new Date();
     date.setHours(jsAray.get(0));
     date.setMinutes(jsAray.get(1));
     date.setSeconds(jsAray.get(2));
     return date;
   }
   return null;
 }
コード例 #9
0
    public DragObject(Element draggableElement, Element containerElement) {

      m_draggableElement = draggableElement;
      m_containerElement = containerElement;

      // User m_vertexgroup because this is what we scale instead of every vertex element
      m_transform = D3.getTransform(D3.d3().select(m_vertexGroup).attr("transform"));

      JsArrayInteger position = D3.getMouse(containerElement);
      m_startX = (int) (position.get(0) / m_transform.getScale().get(0));
      m_startY = (int) (position.get(1) / m_transform.getScale().get(1));
    }
コード例 #10
0
ファイル: BitSet.java プロジェクト: nikoliazekter/artemis-odb
  // sets all bits to true within the given range
  private static void set(JsArrayInteger array, int fromIndex, int toIndex) {
    int first = wordIndex(fromIndex);
    int last = wordIndex(toIndex);
    int startBit = bitOffset(fromIndex);
    int endBit = bitOffset(toIndex);

    if (first == last) {
      // set the bits in between first and last
      maskInWord(array, first, startBit, endBit);

    } else {
      // set the bits from fromIndex to the next 32 bit boundary
      if (startBit != 0) {
        maskInWord(array, first++, startBit, 32);
      }

      // set the bits from the last 32 bit boundary to the toIndex
      if (endBit != 0) {
        maskInWord(array, last, 0, endBit);
      }

      //
      // set everything in between
      //
      for (int i = first; i < last; i++) {
        array.set(i, 0xffffffff);
      }
    }
  }
コード例 #11
0
ファイル: BitSet.java プロジェクト: nikoliazekter/artemis-odb
  public int nextSetBit(int fromIndex) {
    checkIndex(fromIndex);

    int index = wordIndex(fromIndex);

    // check the current word
    int word = getWord(array, index);
    if (word != 0) {
      for (int i = bitOffset(fromIndex); i < 32; i++) {
        if ((word & (1 << i)) != 0) {
          return (bitIndex(index)) + i;
        }
      }
    }
    index++;

    // find the next set word
    trimToSize(array);
    index = nextSetWord(array, index);
    if (index == -1) {
      return -1;
    }

    // return the next set bit
    return (bitIndex(index)) + Integer.numberOfTrailingZeros(array.get(index));
  };
コード例 #12
0
ファイル: BitSet.java プロジェクト: nikoliazekter/artemis-odb
  public void andNot(BitSet set) {
    // a & !a is false
    if (this == set) {
      // all falses result in an empty BitSet
      clear();
      return;
    }

    // trim the second set to avoid extra work
    trimToSize(array);
    int length = array.length();

    // truth table
    //
    // case | a | b | !b | a & !b | change?
    // 1 | false | false | true | false | a is already false
    // 2 | false | true | false | false | a is already false
    // 3 | true | false | true | true | a is already true
    // 4 | true | true | false | false | set a to false
    //
    // we only need to change something in case 4
    // whenever b is true, a should be false, so iterate over set b
    int index = 0;
    while ((index = nextSetWord(set.array, index)) != -1) {
      setWord(array, index, getWord(array, index) & ~set.array.get(index));
      if (++index >= length) {
        // nothing further will affect anything
        break;
      }
    }
  }
コード例 #13
0
ファイル: BitSet.java プロジェクト: nikoliazekter/artemis-odb
 // sets all bits at a certain index to the given value
 private static void setWord(JsArrayInteger array, int index, int value) {
   // keep 0s out of the array
   if (value == 0) {
     deleteWord(array, index);
   } else {
     array.set(index, value);
   }
 }
コード例 #14
0
ファイル: BitSet.java プロジェクト: nikoliazekter/artemis-odb
 // flips all bits stored at a certain index
 private static void flipWord(JsArrayInteger array, int index) {
   int word = getWord(array, index);
   if (word == 0) {
     array.set(index, 0xffffffff);
   } else {
     word = ~word;
     setWord(array, index, word);
   }
 }
コード例 #15
0
ファイル: BitSet.java プロジェクト: nikoliazekter/artemis-odb
 // sets all bits to true at a certain index within the given bit range
 private static void maskInWord(JsArrayInteger array, int index, int from, int to) {
   // shifting by 32 is the same as shifting by 0, this check prevents that
   // from happening in addition to the obvious avoidance of extra work
   if (from != to) {
     // adjust "to" so it will shift out those bits
     to = 32 - to;
     // create a mask and OR it in
     int value = getWord(array, index);
     value |= ((0xffffffff >>> from) << (from + to)) >>> to;
     array.set(index, value);
   }
 };
コード例 #16
0
ファイル: BitSet.java プロジェクト: nikoliazekter/artemis-odb
  // flips one bit
  private static void flip(JsArrayInteger array, int bitIndex) {
    // calculate index and offset
    int index = wordIndex(bitIndex);
    int offset = bitOffset(bitIndex);

    // figure out if the bit is on or off
    int word = getWord(array, index);
    if (((word >>> offset) & 1) == 1) {
      // if on, turn it off
      setWord(array, index, word & ~(1 << offset));
    } else {
      // if off, turn it on
      array.set(index, word | (1 << offset));
    }
  };
コード例 #17
0
ファイル: BitSet.java プロジェクト: nikoliazekter/artemis-odb
  public boolean intersects(BitSet set) {
    int last = trimToSize(array);

    if (this == set) {
      // if it has any bits then it intersects itself
      return last != -1;
    }

    int length = set.array.length();
    int index = 0;
    while ((index = nextSetWord(array, index)) != -1) {
      if ((array.get(index) & getWord(set.array, index)) != 0) {
        return true;
      }
      if (++index >= length) {
        // nothing further can intersect
        break;
      }
    }

    return false;
  }
コード例 #18
0
 public final Date getDate(String key) {
   String type = getType(key);
   if ("number".equals(type)) {
     return new Date(getLong(key));
   } else if ("date".equals(type)) {
     return getNativeDate(key);
   } else if ("string".equals(type)) {
     // DateTimeFormat dtf = DateTimeFormat.getFormat(Defaults.getDateFormat());
     // return dtf.parse(get(key));
   } else if ("array".equals(type)) {
     JsArrayInteger jsAray = getNativeValue(key).cast();
     Date date = new Date();
     date.setYear(jsAray.get(0));
     date.setMonth(jsAray.get(1));
     date.setDate(jsAray.get(2));
     if (jsAray.length() > 3) {
       date.setHours(jsAray.get(3));
       date.setMinutes(jsAray.get(4));
       date.setSeconds(jsAray.get(5));
     }
     return date;
   }
   return null;
 }
コード例 #19
0
  @SuppressWarnings("deprecation")
  public JsJobTrigger getJsJobTrigger() {
    JsJobTrigger jsJobTrigger = JsJobTrigger.instance();

    ScheduleType scheduleType = scheduleEditorWizardPanel.getScheduleType();
    Date startDate = scheduleEditorWizardPanel.getStartDate();
    String startTime = scheduleEditorWizardPanel.getStartTime();

    int startHour = getStartHour(startTime);
    int startMin = getStartMin(startTime);
    int startYear = startDate.getYear();
    int startMonth = startDate.getMonth();
    int startDay = startDate.getDate();
    Date startDateTime = new Date(startYear, startMonth, startDay, startHour, startMin);

    Date endDate = scheduleEditorWizardPanel.getEndDate();
    MonthOfYear monthOfYear = scheduleEditor.getRecurrenceEditor().getSelectedMonth();
    List<DayOfWeek> daysOfWeek = scheduleEditor.getRecurrenceEditor().getSelectedDaysOfWeek();
    Integer dayOfMonth = scheduleEditor.getRecurrenceEditor().getSelectedDayOfMonth();
    WeekOfMonth weekOfMonth = scheduleEditor.getRecurrenceEditor().getSelectedWeekOfMonth();

    if (isBlockoutDialog) {
      jsJobTrigger.setBlockDuration(calculateBlockoutDuration());
    } else {
      // blockDuration is only valid for blockouts
      jsJobTrigger.setBlockDuration(new Long(-1));
    }

    if (scheduleType == ScheduleType.RUN_ONCE) { // Run once types
      jsJobTrigger.setType("simpleJobTrigger"); // $NON-NLS-1$
      jsJobTrigger.setRepeatInterval(0);
      jsJobTrigger.setRepeatCount(0);
      jsJobTrigger.setNativeStartTime(
          DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(startDateTime));
    } else if ((scheduleType == ScheduleType.SECONDS)
        || (scheduleType == ScheduleType.MINUTES)
        || (scheduleType == ScheduleType.HOURS)) {
      int repeatInterval = 0;
      try { // Simple Trigger Types
        repeatInterval = Integer.parseInt(scheduleEditorWizardPanel.getRepeatInterval());
      } catch (Exception e) {
        // ignored
      }
      jsJobTrigger.setType("simpleJobTrigger"); // $NON-NLS-1$
      jsJobTrigger.setRepeatInterval(repeatInterval);
      jsJobTrigger.setRepeatCount(-1);
      jsJobTrigger.setNativeStartTime(
          DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(startDateTime));
      if (endDate != null) {
        jsJobTrigger.setNativeEndTime(
            DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(endDate));
      }
    } else if (scheduleType == ScheduleType.DAILY) {
      if (scheduleEditor.getRecurrenceEditor().isEveryNDays()) {
        int repeatInterval = 0;
        try { // Simple Trigger Types
          repeatInterval = Integer.parseInt(scheduleEditorWizardPanel.getRepeatInterval());
        } catch (Exception e) {
          // ignored
        }
        jsJobTrigger.setType("simpleJobTrigger"); // $NON-NLS-1$
        jsJobTrigger.setRepeatInterval(repeatInterval);
        jsJobTrigger.setRepeatCount(-1);
        jsJobTrigger.setNativeStartTime(
            DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(startDateTime));
        if (endDate != null) {
          jsJobTrigger.setNativeEndTime(
              DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(endDate));
        }
      } else {
        JsArrayInteger jsDaysOfWeek = (JsArrayInteger) JavaScriptObject.createArray();
        int i = 0;
        for (DayOfWeek dayOfWeek : daysOfWeek) {
          jsDaysOfWeek.set(i++, dayOfWeek.ordinal() + 1);
        }
        JsArrayInteger hours = (JsArrayInteger) JavaScriptObject.createArray();
        hours.set(0, startHour);
        JsArrayInteger minutes = (JsArrayInteger) JavaScriptObject.createArray();
        hours.set(0, startMin);
        JsArrayInteger seconds = (JsArrayInteger) JavaScriptObject.createArray();
        hours.set(0, 0);

        jsJobTrigger.setType("complexJobTrigger"); // $NON-NLS-1$
        jsJobTrigger.setDayOfWeekRecurrences(jsDaysOfWeek);
        jsJobTrigger.setHourRecurrences(hours);
        jsJobTrigger.setMinuteRecurrences(minutes);
        jsJobTrigger.setSecondRecurrences(seconds);
        jsJobTrigger.setNativeStartTime(
            DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(startDateTime));
        if (endDate != null) {
          jsJobTrigger.setNativeEndTime(
              DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(endDate));
        }
      }
    } else if (scheduleType == ScheduleType.CRON) { // Cron jobs
      jsJobTrigger.setType("cronJobTrigger"); // $NON-NLS-1$
    } else if ((scheduleType == ScheduleType.WEEKLY) && (daysOfWeek.size() > 0)) {
      JsArrayInteger jsDaysOfWeek = (JsArrayInteger) JavaScriptObject.createArray();
      int i = 0;
      for (DayOfWeek dayOfWeek : daysOfWeek) {
        jsDaysOfWeek.set(i++, dayOfWeek.ordinal() + 1);
      }
      JsArrayInteger hours = (JsArrayInteger) JavaScriptObject.createArray();
      hours.set(0, startHour);
      JsArrayInteger minutes = (JsArrayInteger) JavaScriptObject.createArray();
      hours.set(0, startMin);
      JsArrayInteger seconds = (JsArrayInteger) JavaScriptObject.createArray();
      hours.set(0, 0);

      jsJobTrigger.setType("complexJobTrigger"); // $NON-NLS-1$
      jsJobTrigger.setDayOfWeekRecurrences(jsDaysOfWeek);
      jsJobTrigger.setHourRecurrences(hours);
      jsJobTrigger.setMinuteRecurrences(minutes);
      jsJobTrigger.setSecondRecurrences(seconds);
      jsJobTrigger.setNativeStartTime(
          DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(startDateTime));
      if (endDate != null) {
        jsJobTrigger.setNativeEndTime(
            DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(endDate));
      }
    } else if ((scheduleType == ScheduleType.MONTHLY)
        || ((scheduleType == ScheduleType.YEARLY) && (monthOfYear != null))) {
      jsJobTrigger.setType("complexJobTrigger"); // $NON-NLS-1$

      if (dayOfMonth != null) {
        JsArrayInteger jsDaysOfMonth = (JsArrayInteger) JavaScriptObject.createArray();
        jsDaysOfMonth.set(0, dayOfMonth);

        JsArrayInteger hours = (JsArrayInteger) JavaScriptObject.createArray();
        hours.set(0, startHour);
        JsArrayInteger minutes = (JsArrayInteger) JavaScriptObject.createArray();
        hours.set(0, startMin);
        JsArrayInteger seconds = (JsArrayInteger) JavaScriptObject.createArray();
        hours.set(0, 0);

        jsJobTrigger.setType("complexJobTrigger"); // $NON-NLS-1$
        if (monthOfYear != null) {
          JsArrayInteger jsMonthsOfYear = (JsArrayInteger) JavaScriptObject.createArray();
          jsMonthsOfYear.set(0, monthOfYear.ordinal() + 1);
          jsJobTrigger.setMonthlyRecurrences(jsMonthsOfYear);
        }
        jsJobTrigger.setDayOfMonthRecurrences(jsDaysOfMonth);
        jsJobTrigger.setHourRecurrences(hours);
        jsJobTrigger.setMinuteRecurrences(minutes);
        jsJobTrigger.setSecondRecurrences(seconds);
        jsJobTrigger.setNativeStartTime(
            DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(startDateTime));
        if (endDate != null) {
          jsJobTrigger.setNativeEndTime(
              DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(endDate));
        }
      } else if ((daysOfWeek.size() > 0) && (weekOfMonth != null)) {
        JsArrayInteger jsDaysOfWeek = (JsArrayInteger) JavaScriptObject.createArray();
        int i = 0;
        for (DayOfWeek dayOfWeek : daysOfWeek) {
          jsDaysOfWeek.set(i++, dayOfWeek.ordinal() + 1);
        }

        JsArrayInteger hours = (JsArrayInteger) JavaScriptObject.createArray();
        hours.set(0, startHour);
        JsArrayInteger minutes = (JsArrayInteger) JavaScriptObject.createArray();
        hours.set(0, startMin);
        JsArrayInteger seconds = (JsArrayInteger) JavaScriptObject.createArray();
        hours.set(0, 0);

        jsJobTrigger.setType("complexJobTrigger"); // $NON-NLS-1$
        if (monthOfYear != null) {
          JsArrayInteger jsMonthsOfYear = (JsArrayInteger) JavaScriptObject.createArray();
          jsMonthsOfYear.set(0, monthOfYear.ordinal() + 1);
          jsJobTrigger.setMonthlyRecurrences(jsMonthsOfYear);
        }
        jsJobTrigger.setHourRecurrences(hours);
        jsJobTrigger.setMinuteRecurrences(minutes);
        jsJobTrigger.setSecondRecurrences(seconds);
        jsJobTrigger.setQualifiedDayOfWeek(daysOfWeek.get(0).name());
        jsJobTrigger.setDayOfWeekQualifier(weekOfMonth.name());
        jsJobTrigger.setNativeStartTime(
            DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(startDateTime));
        if (endDate != null) {
          jsJobTrigger.setNativeEndTime(
              DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(endDate));
        }
      }
    }
    return jsJobTrigger;
  }
コード例 #20
0
ファイル: BitSet.java プロジェクト: nikoliazekter/artemis-odb
 public int size() {
   // the number of bytes that can fit without using "more" memory
   return bitIndex(array.length());
 }
コード例 #21
0
 public int getCurrentY() {
   JsArrayInteger position = D3.getMouse(m_containerElement);
   return (int) (position.get(1) / m_transform.getScale().get(1));
 }
コード例 #22
0
ファイル: BitSet.java プロジェクト: nikoliazekter/artemis-odb
 // sets one bit to true
 private static void set(JsArrayInteger array, int bitIndex) {
   int index = wordIndex(bitIndex);
   array.set(index, getWord(array, index) | (1 << (bitOffset(bitIndex))));
 }