Package java.text

Examples of java.text.ParseException


        } catch (ParseException pe) {
          // keep trying.
        }
      }
      if (lDate == null) {
        throw new ParseException("Not RFC 822 parsebale date format", 0);
      }
    } else {
      throw new IllegalArgumentException();
    }
    return lDate;
View Full Code Here


            // Server: read the client header byte + sizeof adapter name
            // Client: read just the server header byte
            semiBlockingRead( channel, magicBuf, timeout );
            if ( magicBuf.hasRemaining() )
            {
                throw new ParseException( "Header too long!", magicBuf.position() );
            }

            magicBuf.flip();
            InetAddress address = channel.socket().getInetAddress();
            int port = channel.socket().getPort();
View Full Code Here

            throw new ClosedChannelException();
        }
        // stream ended but HTTP header isn't complete?
        else if ( !HttpHeaderParser.isComplete( headerBuf ) )
        {
            throw new ParseException( "Received HTTP Header missing finalizing line terminators (\\r\\n\\r\\n)!",
                                      readControl );
        }

        if ( logger.isLoggable( Level.FINEST ) )
        {
            logger.log( Level.FINEST, "HTTP Header read: complete=" + HttpHeaderParser.isComplete( headerBuf )
                    + ", readControl=" + readControl + ", bytes read: " + headerBuf.position() );
        }

        headerBuf.flip();

        if ( logger.isLoggable( Level.FINE ) )
        {
            logger.log( Level.FINE, IOUtil.decodeToString( headerBuf ) );
            headerBuf.position( 0 );
        }

        // instantiate an appropiate HTTP header parser depending on whether the data are a HTTP request or a response
        if ( isRequest )
        {
            httpHeaderParser = new HttpResponseParser( headerBuf );
        }
        else
        {
            httpHeaderParser = new HttpRequestParser( headerBuf );
        }

        // validate the data
        if ( !httpHeaderParser.isValid() )
        {
            headerBuf.rewind();
            throw new ParseException( httpHeaderParser.getClass().getName() + ": Invalid HTTP header detected!!!\n"
                    + IOUtil.decodeToString( headerBuf ), 0 );
        }

        return httpHeaderParser;
    }
View Full Code Here

            // perform basic type checking
            DateFormat df = new SimpleDateFormat(dateTimeFormat);
            try {
                df.parse(v);
            } catch (Exception e) {
                throw new ParseException(i18n.tr("Field ") + this.name
                        + i18n.tr(" must contain a datetime in the format: ") + dateTimeFormat, 0);
            }
            // value is valid
            checkedValues.add(v);
        }
View Full Code Here

           
            // perform basic type checking
            SWAMPHashSet values = new SWAMPHashSet(v, ",");
            for (Iterator it = values.iterator(); it.hasNext(); ){
                if (!this.getEnumvalues().contains(it.next())){
                    throw new ParseException(i18n.tr("Assignment to Field ") + this.getName()
                            + i18n.tr(" must be in Enumeration-Array!"), 0);
                }
            }
            // value is valid
            checkedValues.add(v);
View Full Code Here

    } catch (IllegalArgumentException e) {
      // Since the IAE can originate at several different points inside
      // fromValid(), we implement this method in terms of that one rather
      // than the reverse.

      ParseException parseException =
          new ParseException("Invalid host specifier: " + specifier, 0);
      parseException.initCause(e);
      throw parseException;
    }
  }
View Full Code Here

      return parsedNullOrEmpty;
    if (value.equals(trueString))
      return Boolean.TRUE;
    if (value.equals(falseString))
      return Boolean.FALSE;
    throw new ParseException("Cannot parse: " + value, 0);
  }
View Full Code Here

    Number d = (Number) super.parse(value);
    if (d == null || d instanceof Byte)
      return d;
    long l = d.longValue();
    if (l < Byte.MIN_VALUE || l > Byte.MAX_VALUE)
      throw new ParseException("", 0);
    return new Byte(d.byteValue());
  }
View Full Code Here

    if (d == Double.NEGATIVE_INFINITY)
      return new Float(Float.NEGATIVE_INFINITY);
    if (d == Double.POSITIVE_INFINITY)
      return new Float(Float.POSITIVE_INFINITY);
    if (d < -Float.MAX_VALUE || d > Float.MAX_VALUE)
      throw new ParseException("", 0);
    return new Float(n.floatValue());
  }
View Full Code Here

    Number d = (Number) super.parse(value);
    if (d == null || d instanceof Integer)
      return d;
    long l = d.longValue();
    if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE)
      throw new ParseException("", 0);
    return new Integer(d.intValue());
  }
View Full Code Here

TOP

Related Classes of java.text.ParseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.