Ejemplo n.º 1
0
  void _serializeNumber(String key, Number value) {
    NodeList elements = numberElements.getElementsByTagName(ENTRY_FLAG);

    final int size = elements.getLength();

    for (int i = 0; i < size; ++i) {
      Element e = (Element) elements.item(i);
      Attr nameAttr = e.getAttributeNode(KEY_FLAG);
      if (nameAttr == null) {
        throw newMalformedKeyAttrException(Repository.NUMBER);
      }
      if (key.equals(nameAttr.getValue())) {
        Attr valueAttr = e.getAttributeNode(VALUE_FLAG);
        if (valueAttr == null) {
          throw newMalformedValueAttrException(key, Repository.NUMBER);
        }
        Attr typeAttr = e.getAttributeNode(TYPE_FLAG);
        if (typeAttr == null) {
          throw newMalformedTypeAttrException(key, Repository.NUMBER);
        }
        typeAttr.setValue(Configs.resolveNumberType(value).name());
        valueAttr.setValue(value.toString());
        return;
      }
    }
    // no existing element found
    Element element = xmlDoc.createElement(ENTRY_FLAG);
    element.setAttribute(KEY_FLAG, key);
    element.setAttribute(VALUE_FLAG, value.toString());
    element.setAttribute(TYPE_FLAG, Configs.resolveNumberType(value).name());
    numberElements.appendChild(element);
  }
  public void setValue(Number value) {
    this.value = value;
    this.stringValue = (value != null) ? value.toString() : null;

    if (value != null) {
      try {
        Number num = convertValue(value);
        String text = (num == null ? "" : num.toString());

        super.remove(0, getLength());
        super.insertString(0, text, null);

        this.stringValue = (num == null ? null : num.toString());
        this.value = num;
      } catch (RuntimeException re) {
        throw re;
      } catch (Exception ex) {
        throw new RuntimeException(ex.getMessage(), ex);
      }
    } else {
      try {
        super.remove(0, getLength());
      } catch (BadLocationException ex) {;
      }
    }
  }
Ejemplo n.º 3
0
 /**
  * 对数字对象作处理,如果为0或空则返回默认值
  *
  * @param number 数字对象
  * @param defaultValue 默认值
  * @return
  */
 public static String number(Number number, String defaultValue) {
   if (number == null || StringUtils.isBlank(number.toString()) || "0".equals(number.toString())) {
     return defaultValue;
   } else {
     return number.toString();
   }
 }
Ejemplo n.º 4
0
 public Object convertToNumber(Number value, Class toType) throws Exception {
   if (AtomicInteger.class == toType) {
     return new AtomicInteger((Integer) convertToNumber(value, Integer.class));
   } else if (AtomicLong.class == toType) {
     return new AtomicLong((Long) convertToNumber(value, Long.class));
   } else if (Integer.class == toType) {
     return value.intValue();
   } else if (Short.class == toType) {
     return value.shortValue();
   } else if (Long.class == toType) {
     return value.longValue();
   } else if (Float.class == toType) {
     return value.floatValue();
   } else if (Double.class == toType) {
     return value.doubleValue();
   } else if (Byte.class == toType) {
     return value.byteValue();
   } else if (BigInteger.class == toType) {
     return new BigInteger(value.toString());
   } else if (BigDecimal.class == toType) {
     return new BigDecimal(value.toString());
   } else {
     return null;
   }
 }
Ejemplo n.º 5
0
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.komodo.spi.repository.ValidationManager#addPropertyValueNumberValidationRule(org.komodo.spi.repository.Repository.UnitOfWork,
   *     java.lang.String, java.lang.String, java.lang.String, java.lang.Number, boolean,
   *     java.lang.Number, boolean, java.util.List, java.util.List)
   */
  @Override
  public Rule addPropertyValueNumberValidationRule(
      final UnitOfWork transaction,
      final String name,
      final String nodeType,
      final String propertyName,
      final Number minValue,
      final boolean minInclusive,
      final Number maxValue,
      final boolean maxInclusive,
      final List<LocalizedMessage> descriptions,
      final List<LocalizedMessage> messages)
      throws KException {
    ArgCheck.isNotNull(transaction, "transaction"); // $NON-NLS-1$
    ArgCheck.isTrue(
        (transaction.getState() == State.NOT_STARTED),
        "transaction state is not NOT_STARTED"); //$NON-NLS-1$
    ArgCheck.isNotEmpty(propertyName, "propertyName"); // $NON-NLS-1$
    ArgCheck.isTrue(
        (minValue != null) || (maxValue != null),
        "minValue or maxValue must not be null"); //$NON-NLS-1$

    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug(
          "addPropertyValueNumberValidationRule: transaction = {0}, name = {1}",
          transaction.getName(), name); // $NON-NLS-1$
    }

    try {
      final RuleImpl rule =
          createRule(
              transaction,
              name,
              KomodoLexicon.Rule.NUMBER_RULE,
              Rule.ValidationType.PROPERTY,
              Rule.RuleType.NUMBER,
              nodeType,
              descriptions,
              messages);
      rule.setProperty(transaction, KomodoLexicon.Rule.JCR_NAME, propertyName);

      if (minValue != null) {
        rule.setProperty(transaction, KomodoLexicon.Rule.MIN_VALUE, minValue.toString());
        rule.setProperty(transaction, KomodoLexicon.Rule.MIN_VALUE_INCLUSIVE, minInclusive);
      }

      if (maxValue != null) {
        rule.setProperty(transaction, KomodoLexicon.Rule.MAX_VALUE, maxValue.toString());
        rule.setProperty(transaction, KomodoLexicon.Rule.MAX_VALUE_INCLUSIVE, maxInclusive);
      }

      return rule;
    } catch (final Exception e) {
      throw ObjectImpl.handleError(e);
    }
  }
 /**
  * Add a numeric range facet.
  *
  * @param field The field
  * @param start The start of range
  * @param end The end of the range
  * @param gap The gap between each count
  * @return this
  */
 public SolrQuery addNumericRangeFacet(String field, Number start, Number end, Number gap) {
   add(FacetParams.FACET_RANGE, field);
   add(
       String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_START),
       start.toString());
   add(String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_END), end.toString());
   add(String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_GAP), gap.toString());
   this.set(FacetParams.FACET, true);
   return this;
 }
  protected String formatValue(Number value) {
    if (value == null) return null;
    if (formatter == null) return value.toString();

    String pattern = getFormat();
    if (pattern == null || pattern.trim().length() == 0) return value.toString();

    DecimalFormat formatter = new DecimalFormat(pattern);
    return formatter.format(value);
  }
Ejemplo n.º 8
0
    @Override
    public String convert(Number source) {
      if (source == null) {
        return null;
      }

      if (source.doubleValue() < 0d) {
        return "\\" + source.toString();
      }
      return source.toString();
    }
Ejemplo n.º 9
0
 @Override
 public String toQuery() {
   String fromString = (from == null) ? "*" : from.toString();
   String toString = (to == null) ? "*" : to.toString();
   if ((from == null) && (to == null)) {
     return "";
   } else if (extra == null) {
     return String.format("(%s:[%s TO %s])", field, fromString, toString);
   } else {
     return String.format("(%s:[%s TO %s] %s)", field, fromString, toString, extra);
   }
 }
Ejemplo n.º 10
0
  @PreAuthorize("isFullyAuthenticated()")
  @RequestMapping(value = "/getapplication", method = RequestMethod.GET)
  public ModelAndView getapplicationlist(
      @RequestParam(value = "page", required = false) Integer page,
      HttpSession session,
      Authentication auth) {
    ModelAndView mav = new ModelAndView();
    UserPrincipal user = userService.getUserByName(auth.getName());
    Status status = clientService.getStatusByName("zajavka ozhidaet obrabotku");
    if (page == null) page = 1;
    Integer pageSize = 3;
    Integer startPage = page;
    Integer endPage = page + 5;

    Number size1 = directorService.getSizeApplicationByStatus(status);
    int size = Integer.parseInt(size1.toString());

    Integer lastPage = (size + (pageSize - 1)) / pageSize;

    if (endPage >= lastPage) endPage = lastPage;
    if (endPage >= 5 && (endPage - startPage) < 5) startPage = endPage - 5;

    mav.addObject("page", page);
    mav.addObject("startpage", startPage);
    mav.addObject("endpage", endPage);

    mav.addObject("user", user);
    mav.addObject(
        "application",
        directorService.getApplicationByStatus(status, (page - 1) * pageSize, pageSize));
    mav.setViewName("director.applicationlist");
    return mav;
  };
Ejemplo n.º 11
0
 /**
  * Posts a status update for a specified item to the event bus.
  *
  * @param item the item to send the status update for
  * @param state the new state of the item as a number
  */
 public static Object postUpdate(Item item, Number state) {
   if (item != null && state != null) {
     return postUpdate(item.getName(), state.toString());
   } else {
     return null;
   }
 }
Ejemplo n.º 12
0
  @PreAuthorize("isFullyAuthenticated()")
  @RequestMapping(value = "/mechaniclistbysto/{id}", method = RequestMethod.GET)
  public ModelAndView getmechaniclistbysto(
      @RequestParam(value = "page", required = false) Integer page,
      @PathVariable Long id,
      HttpSession session,
      Authentication auth) {
    ModelAndView mav = new ModelAndView();
    UserPrincipal user = userService.getUserByName(auth.getName());
    Sto sto = directorService.getStoById(id);
    Number size1 = directorService.getSizeMechanicOnSto(sto);
    int size = Integer.parseInt(size1.toString());
    System.out.println("Test test test" + sto.getName());
    if (page == null) page = 1;
    Integer pageSize = 3;
    Integer startPage = page;
    Integer endPage = page + 5;
    Integer lastPage = (size + (pageSize - 1)) / pageSize;

    if (endPage >= lastPage) endPage = lastPage;
    if (endPage >= 5 && (endPage - startPage) < 5) startPage = endPage - 5;

    mav.addObject("page", page);
    mav.addObject("startpage", startPage);
    mav.addObject("endpage", endPage);

    mav.addObject("user", user);
    mav.addObject(
        "mechanic", directorService.getMechanicsOnSto(sto, (page - 1) * pageSize, pageSize));
    mav.setViewName("director.mechaniclistbysto");
    return mav;
  };
Ejemplo n.º 13
0
  @RequestMapping(
      value = {"/updateapplication/{id}"},
      method = {RequestMethod.POST})
  public ModelAndView updateapplication(
      @PathVariable Long id,
      @ModelAttribute("application") Application application,
      Model model,
      BindingResult bindingResult,
      HttpSession session,
      Authentication auth) {
    ModelAndView mav = new ModelAndView();
    Application application1 = mechanicService.getApplicationById(id);
    applicationValidator.validate(application, bindingResult);
    if (bindingResult.hasErrors()) {

      UserPrincipal user = userService.getUserByName(auth.getName());
      Number size1 = directorService.getSizeMechanicOnSto(application1.getSto());
      int size = Integer.parseInt(size1.toString());
      mav.addObject("application", application1);
      mav.addObject("statuss", directorService.getStatus());
      mav.addObject("mechanics", directorService.getMechanicsOnSto(application1.getSto(), 0, size));
      mav.addObject("user", user);
      mav.setViewName("director.updateapplication");
      return mav;
    }

    application1.setMechanic(application.getMechanic());
    application1.setStatus(application.getStatus());
    clientService.addOrUpdateApplication(application1);
    mav.setViewName("redirect:/home");
    return mav;
  }
 @Nullable
 @Override
 public String formatNumber(Number nb) {
   if (nb == null) return null;
   String str = nb.toString();
   return str.endsWith(".0") ? str.substring(0, str.length() - 2) : str;
 }
Ejemplo n.º 15
0
  @PreAuthorize("isFullyAuthenticated()")
  @RequestMapping(value = "/getmechanics", method = RequestMethod.GET)
  public ModelAndView getmechaniclist(
      @RequestParam(value = "page", required = false) Integer page,
      HttpSession session,
      Authentication auth) {
    ModelAndView mav = new ModelAndView();
    UserPrincipal user = userService.getUserByName(auth.getName());
    if (page == null) page = 1;
    Integer pageSize = 4;
    Integer startPage = page;
    Integer endPage = page + 5;

    Number size1 = directorService.getSizeAllMechanic();
    int size = Integer.parseInt(size1.toString());

    Integer lastPage = (size + (pageSize - 1)) / pageSize;

    if (endPage >= lastPage) endPage = lastPage;
    if (endPage >= 5 && (endPage - startPage) < 5) startPage = endPage - 5;

    mav.addObject("page", page);
    mav.addObject("startpage", startPage);
    mav.addObject("endpage", endPage);

    mav.addObject("user", user);
    mav.addObject("mechanic", directorService.getMechanicsToPage((page - 1) * pageSize, pageSize));
    mav.setViewName("director.mechanicslist");
    return mav;
  };
Ejemplo n.º 16
0
  /**
   * Invalid Entry - Start Calculator
   *
   * @param jc parent
   * @param value value
   * @param format format
   * @param displayType display type
   * @param title title
   * @param operator optional math operator +-/*
   * @return value
   */
  public static String startCalculator(
      Container jc,
      String value,
      DecimalFormat format,
      int displayType,
      String title,
      char operator) {
    log.config("Value=" + value);
    BigDecimal startValue = new BigDecimal(0.0);
    try {
      if (value != null && value.length() > 0) {
        Number number = format.parse(value);
        startValue = new BigDecimal(number.toString());
      }
    } catch (ParseException pe) {
      log.info("InvalidEntry - " + pe.getMessage());
    }

    //	Find frame
    Frame frame = Env.getFrame(jc);
    //	Actual Call
    Calculator calc = new Calculator(frame, title, displayType, format, startValue);
    if ("*+-/%".indexOf(operator) > -1) calc.handleInput(operator);
    AEnv.showCenterWindow(frame, calc);
    BigDecimal result = calc.getNumber();
    log.config("Result=" + result);
    //
    calc = null;
    if (result != null) return format.format(result);
    else return value; // 	original value
  } //	startCalculator
 /**
  * Reads a Number
  *
  * @return Number Number
  */
 @SuppressWarnings({"unchecked", "rawtypes"})
 @Override
 public Number readNumber(Type target) {
   log.debug("readNumber - target: {}", target);
   Number v;
   if (currentDataType == AMF3.TYPE_NUMBER) {
     v = buf.getDouble();
   } else {
     // we are decoding an int
     v = readAMF3Integer();
   }
   log.debug("readNumber - value: {}", v);
   if (target instanceof Class && Number.class.isAssignableFrom((Class<?>) target)) {
     Class cls = (Class) target;
     if (!cls.isAssignableFrom(v.getClass())) {
       String value = v.toString();
       log.debug("readNumber - value class: {} str: {}", v.getClass(), value);
       if (value.indexOf(".") > 0) {
         if (Float.class == v.getClass()) {
           v = (Number) convertUtilsBean.convert(value, Float.class);
         } else {
           v = (Number) convertUtilsBean.convert(value, Double.class);
         }
       } else {
         v = (Number) convertUtilsBean.convert(value, cls);
       }
     }
   }
   return v;
 }
Ejemplo n.º 18
0
 public OverflowException(Number n, Class<?> expectedClass) {
   super(
       "Overflow exception, "
           + n.toString()
           + " cannot be converted to: "
           + expectedClass.getSimpleName());
 }
Ejemplo n.º 19
0
 public void serialize(
     Number number, JsonGenerator jsongenerator, SerializerProvider serializerprovider)
     throws IOException, JsonGenerationException {
   if (number instanceof BigDecimal) {
     jsongenerator.writeNumber((BigDecimal) number);
     return;
   }
   if (number instanceof BigInteger) {
     jsongenerator.writeNumber((BigInteger) number);
     return;
   }
   if (number instanceof Integer) {
     jsongenerator.writeNumber(number.intValue());
     return;
   }
   if (number instanceof Long) {
     jsongenerator.writeNumber(number.longValue());
     return;
   }
   if (number instanceof Double) {
     jsongenerator.writeNumber(number.doubleValue());
     return;
   }
   if (number instanceof Float) {
     jsongenerator.writeNumber(number.floatValue());
     return;
   }
   if ((number instanceof Byte) || (number instanceof Short)) {
     jsongenerator.writeNumber(number.intValue());
     return;
   } else {
     jsongenerator.writeNumber(number.toString());
     return;
   }
 }
Ejemplo n.º 20
0
 /**
  * Sends a number as a command for a specified item to the event bus.
  *
  * @param item the item to send the command to
  * @param number the number to send as a command
  */
 public static Object sendCommand(Item item, Number number) {
   if (item != null && number != null) {
     return sendCommand(item.getName(), number.toString());
   } else {
     return null;
   }
 }
Ejemplo n.º 21
0
    public void handleSampleDimensionNilValues(GridCoverage2D gc2d, double[] nodataValues) {
      start("swe:nilValues");
      start("swe:NilValues");

      if (nodataValues != null && nodataValues.length > 0) {
        for (double nodata : nodataValues) {
          final AttributesImpl nodataAttr = new AttributesImpl();
          nodataAttr.addAttribute(
              "", "reason", "reason", "", "http://www.opengis.net/def/nil/OGC/0/unknown");
          element("swe:nilValue", String.valueOf(nodata), nodataAttr);
        }
      } else if (gc2d != null) {
        // do we have already a a NO_DATA value at hand?
        if (gc2d.getProperties().containsKey("GC_NODATA")) {
          String nodata = (String) gc2d.getProperties().get("GC_NODATA"); // TODO test me
          final AttributesImpl nodataAttr = new AttributesImpl();
          nodataAttr.addAttribute(
              "", "reason", "reason", "", "http://www.opengis.net/def/nil/OGC/0/unknown");
          element("swe:nilValue", nodata, nodataAttr);
        } else {
          // let's suggest some meaningful value from the data type of the underlying image
          Number nodata =
              CoverageUtilities.suggestNoDataValue(
                  gc2d.getRenderedImage().getSampleModel().getDataType());
          final AttributesImpl nodataAttr = new AttributesImpl();
          nodataAttr.addAttribute(
              "", "reason", "reason", "", "http://www.opengis.net/def/nil/OGC/0/unknown");
          element("swe:nilValue", nodata.toString(), nodataAttr);
        }
      }

      end("swe:NilValues");
      end("swe:nilValues");
    }
Ejemplo n.º 22
0
 @SuppressWarnings("unchecked")
 public static synchronized <E> E get(CFG<E> name) {
   E value = name.def;
   try {
     if (cache.containsKey(name.path)) {
       return (E) cache.get(name.path);
     } else {
       if (name.path != null) {
         Object data = retrieve(name);
         Class<?> defClass = name.def.getClass();
         if (defClass.isAssignableFrom(data.getClass())) {
           value = (E) data;
         } else if (Number.class.isAssignableFrom(defClass)) {
           Number n = (Number) data;
           value = (E) defClass.getConstructor(String.class).newInstance(n.toString());
         } else if (Enum.class.isAssignableFrom(defClass)) {
           Class<? extends Enum> enumType = Reflect.getEnumSuperclass(defClass);
           if (enumType != null) {
             value = (E) Enum.valueOf(enumType, data.toString());
           }
         }
       }
       cache.put(name.path, value);
     }
   } catch (Exception ignored) {
   }
   return value;
 }
Ejemplo n.º 23
0
 /**
  * Convert the given number into a BigDecimal
  *
  * @param number the number to convert
  * @return the given number as BigDecimal or null if number is null
  */
 public static BigDecimal numberToBigDecimal(Number number) {
   if (number != null) {
     return new BigDecimal(number.toString());
   } else {
     return null;
   }
 }
Ejemplo n.º 24
0
 /**
  * Return Editor value
  *
  * @return value value (big decimal or integer)
  */
 public Object getValue() {
   if (m_text == null || m_text.getText() == null || m_text.getText().length() == 0) return null;
   String value = m_text.getText();
   //	return 0 if text deleted
   if (value == null || value.length() == 0) {
     if (!m_modified) return null;
     if (m_displayType == DisplayType.Integer) return new Integer(0);
     return Env.ZERO;
   }
   if (value.equals(".") || value.equals(",") || value.equals("-")) value = "0";
   // arboleda - solve bug [ 1759771 ] Parse exception when you enter ".." in a numeric field
   if (value.equals("..")) {
     value = "0";
     m_text.setText(".");
   }
   try {
     Number number = m_format.parse(value);
     value = number.toString(); // 	converts it to US w/o thousands
     BigDecimal bd = new BigDecimal(value);
     if (m_displayType == DisplayType.Integer) return new Integer(bd.intValue());
     if (bd.signum() == 0) return bd;
     return bd.setScale(m_format.getMaximumFractionDigits(), BigDecimal.ROUND_HALF_UP);
   } catch (Exception e) {
     log.log(Level.SEVERE, "Value=" + value, e);
   }
   m_text.setText(m_format.format(0));
   if (m_displayType == DisplayType.Integer) return new Integer(0);
   return Env.ZERO;
 } //	getValue
  /**
   * validates the number value using the range constraint provided
   *
   * @param result - a holder for any already run validation results
   * @param value - the value to validate
   * @param constraint - the range constraint to use
   * @param attributeValueReader - provides access to the attribute being validated
   * @return the passed in result, updated with the results of the processing
   * @throws IllegalArgumentException
   */
  protected ConstraintValidationResult validateRange(
      DictionaryValidationResult result,
      Number value,
      RangeConstraint constraint,
      AttributeValueReader attributeValueReader)
      throws IllegalArgumentException {

    // TODO: JLR - need a code review of the conversions below to make sure this is the best way to
    // ensure accuracy across all numerics
    // This will throw NumberFormatException if the value is 'NaN' or infinity... probably shouldn't
    // be a NFE but something more intelligible at a higher level
    BigDecimal number = value != null ? new BigDecimal(value.toString()) : null;

    String inclusiveMaxText = constraint.getInclusiveMax();
    String exclusiveMinText = constraint.getExclusiveMin();

    BigDecimal inclusiveMax = inclusiveMaxText != null ? new BigDecimal(inclusiveMaxText) : null;
    BigDecimal exclusiveMin = exclusiveMinText != null ? new BigDecimal(exclusiveMinText) : null;

    return isInRange(
        result,
        number,
        inclusiveMax,
        inclusiveMaxText,
        exclusiveMin,
        exclusiveMinText,
        attributeValueReader);
  }
Ejemplo n.º 26
0
 public void write(JsonWriter jsonWriter, Number number) throws IOException {
   if (number == null) {
     jsonWriter.nullValue();
   } else {
     jsonWriter.value(number.toString());
   }
 }
  /**
   * Checks whether the provided value is greater than the minimum. In case the value is an instance
   * of string: checks whether the length of the string is equal to or smaller than the minLength
   * property. In case the value is an instance of number: checks whether the length of the integer
   * value is equal to or smaller than the minLength property.
   *
   * @return boolean true if the length of value is equal to or less than the minLength property,
   *     false otherwise
   * @see
   *     nl.openedge.baritus.validation.FieldValidator#isValid(org.infohazard.maverick.flow.ControllerContext,
   *     nl.openedge.baritus.FormBeanContext, java.lang.String, java.lang.Object)
   */
  @Override
  public boolean isValid(
      ControllerContext cctx, FormBeanContext formBeanContext, String fieldName, Object value) {
    if (minLength == NO_MINIMUM) return true;

    boolean minExceeded = false;
    if (value != null) {
      if (value instanceof String) {
        String toCheck = (String) value;
        int length = toCheck.length();
        minExceeded = (length < minLength);
      } else if (value instanceof Number) {
        Number toCheck = (Number) value;
        int length = toCheck.toString().length();
        minExceeded = (length < minLength);
      } else {
        // just ignore; wrong type to check on
        log.warn(
            fieldName + " with value: " + value + " is of the wrong type for checking on length");
      }
    }

    if (minExceeded) {
      setErrorMessage(
          formBeanContext,
          fieldName,
          getErrorMessageKey(),
          new Object[] {
            getFieldName(formBeanContext, fieldName), value, Integer.valueOf(minLength)
          });
    }

    return (!minExceeded);
  }
  @Test
  public void testCursorPosition() throws Exception {
    selenium.open("../tests/html/test_type_page1.html");
    try {
      assertEquals(selenium.getCursorPosition("username"), "8");
      fail("expected failure");
    } catch (Throwable e) {
    }
    selenium.windowFocus();
    verifyEquals(selenium.getValue("username"), "");
    selenium.type("username", "TestUser");
    selenium.setCursorPosition("username", "0");

    Number position = 0;
    try {
      position = selenium.getCursorPosition("username");
    } catch (SeleniumException e) {
      if (!isWindowInFocus(e)) {
        return;
      }
    }
    verifyEquals(position.toString(), "0");
    selenium.setCursorPosition("username", "-1");
    verifyEquals(selenium.getCursorPosition("username"), "8");
    selenium.refresh();
    selenium.waitForPageToLoad("30000");
    try {
      assertEquals(selenium.getCursorPosition("username"), "8");
      fail("expected failure");
    } catch (Throwable e) {
    }
  }
 public String getBadValue(int icol) {
   if (colWriters[icol] == null) {
     return null;
   } else {
     Number badnum = colWriters[icol].getBadNumber();
     return badnum == null ? null : badnum.toString();
   }
 }
Ejemplo n.º 30
0
 public String format(String type, Number val) {
   if (type == null) {
     return val.toString();
   } else if (val == null) {
     return null;
   } else if ("Integer".endsWith(type) || "int".equalsIgnoreCase(type)) {
     return "" + val.intValue();
   } else if ("Float".endsWith(type) || "float".equalsIgnoreCase(type)) {
     return "" + val.floatValue();
   } else if ("Double".endsWith(type) || "double".equalsIgnoreCase(type)) {
     return "" + val.doubleValue();
   } else if ("Boolean".endsWith(type) || "boolean".equalsIgnoreCase(type)) {
     if (val.doubleValue() == 1.0) return "true";
     if (val.doubleValue() == 0.0) return "false";
     throw new NumberFormatException("Boolean expected, found " + val);
   } else if ("String".endsWith(type)) {
     return "\"" + val.toString() + "\"";
   } else if ("Date".endsWith(type)) {
     return "\"" + (new SimpleDateFormat().format(new Date(val.longValue()))) + "\"";
   } else if ("Time".endsWith(type)) {
     return "\"" + val.toString() + "\"";
   } else if ("DateTime".endsWith(type)) {
     return "\"" + (new SimpleDateFormat().format(new Date(val.longValue()))) + "\"";
   } else if ("DateDaysSince[0]".equalsIgnoreCase(type)) {
     throw new UnsupportedOperationException("TODO");
   } else if ("DateDaysSince[1960]".equalsIgnoreCase(type)) {
     throw new UnsupportedOperationException("TODO");
   } else if ("DateDaysSince[1970]".equalsIgnoreCase(type)) {
     throw new UnsupportedOperationException("TODO");
   } else if ("DateDaysSince[1980]".equalsIgnoreCase(type)) {
     throw new UnsupportedOperationException("TODO");
   } else if ("TimeSeconds".equalsIgnoreCase(type)) {
     throw new UnsupportedOperationException("TODO");
   } else if ("DateTimeSecondsSince[0]".equalsIgnoreCase(type)) {
     throw new UnsupportedOperationException("TODO");
   } else if ("DateTimeSecondsSince[1960]".equalsIgnoreCase(type)) {
     throw new UnsupportedOperationException("TODO");
   } else if ("DateTimeSecondsSince[1970]".equalsIgnoreCase(type)) {
     throw new UnsupportedOperationException("TODO");
   } else if ("DateTimeSecondsSince[1980]".equalsIgnoreCase(type)) {
     throw new UnsupportedOperationException("TODO");
   } else {
     return val.toString();
   }
 }