Package net.sf.mpxj

Examples of net.sf.mpxj.MPXJException


         return (project);
      }

      catch (SQLException ex)
      {
         throw new MPXJException(MPXJException.READ_ERROR, ex);
      }

      finally
      {
         if (m_allocatedConnection && m_connection != null)
View Full Code Here


         bis.mark(1024);
         bis.read(data, 1, 5);

         if (!new String(data).equals("ERMHDR"))
         {
            throw new MPXJException(MPXJException.INVALID_FILE);
         }

         bis.reset();

         Tokenizer tk = new InputStreamTokenizer(bis);
         tk.setDelimiter('\t');
         List<String> record = new ArrayList<String>();

         while (tk.getType() != Tokenizer.TT_EOF)
         {
            readRecord(tk, record);
            if (processRecord(record))
            {
               break;
            }
            ++line;
         }
      }

      catch (Exception ex)
      {
         throw new MPXJException(MPXJException.READ_ERROR + " (failed at line " + line + ")", ex);
      }
   }
View Full Code Here

      boolean done = false;

      RecordType type = RECORD_TYPE_MAP.get(record.get(0));
      if (type == null)
      {
         throw new MPXJException(MPXJException.INVALID_FORMAT);
      }

      switch (type)
      {
         case HEADER :
         {
            processHeader(record);
            break;
         }

         case TABLE :
         {
            m_currentTableName = record.get(1).toLowerCase();
            m_skipTable = !REQUIRED_TABLES.contains(m_currentTableName);
            if (m_skipTable)
            {
               m_currentTable = null;
            }
            else
            {
               m_currentTable = new LinkedList<Row>();
               m_tables.put(m_currentTableName, m_currentTable);
            }
            break;
         }

         case FIELDS :
         {
            if (m_skipTable)
            {
               m_currentFieldNames = null;
            }
            else
            {
               m_currentFieldNames = record.toArray(new String[record.size()]);
               for (int loop = 0; loop < m_currentFieldNames.length; loop++)
               {
                  m_currentFieldNames[loop] = m_currentFieldNames[loop].toLowerCase();
               }
            }
            break;
         }

         case DATA :
         {
            if (!m_skipTable)
            {
               Map<String, Object> map = new HashMap<String, Object>();
               for (int loop = 1; loop < record.size(); loop++)
               {
                  String fieldName = m_currentFieldNames[loop];
                  String fieldValue = record.get(loop);
                  FieldType fieldType = FIELD_TYPE_MAP.get(fieldName);
                  if (fieldType == null)
                  {
                     fieldType = FieldType.STRING;
                  }

                  Object objectValue;
                  if (fieldValue.length() == 0)
                  {
                     objectValue = null;
                  }
                  else
                  {
                     switch (fieldType)
                     {
                        case DATE :
                        {
                           try
                           {
                              objectValue = m_df.parseObject(fieldValue);
                           }

                           catch (ParseException ex)
                           {
                              throw new MPXJException(MPXJException.INVALID_DATE, ex);
                           }

                           break;
                        }

                        case CURRENCY :
                        {
                           try
                           {
                              objectValue = Double.valueOf(m_numberFormat.parse(fieldValue).doubleValue());
                           }

                           catch (ParseException ex)
                           {
                              throw new MPXJException(MPXJException.INVALID_NUMBER, ex);
                           }
                           break;
                        }

                        case DOUBLE :
                        {
                           try
                           {
                              objectValue = Double.valueOf(m_numberFormat.parse(fieldValue).doubleValue());
                           }

                           catch (ParseException ex)
                           {
                              throw new MPXJException(MPXJException.INVALID_NUMBER, ex);
                           }
                           break;
                        }

                        case DURATION :
                        {
                           try
                           {
                              objectValue = Double.valueOf(m_numberFormat.parse(fieldValue).doubleValue());
                           }

                           catch (ParseException ex)
                           {
                              throw new MPXJException(MPXJException.INVALID_NUMBER, ex);
                           }
                           break;
                        }

                        case INTEGER :
View Full Code Here

   {
      Integer result = m_resourceNumbers.get(field);

      if (result == null)
      {
         throw new MPXJException(MPXJException.INVALID_RESOURCE_FIELD_NAME + " " + field);
      }

      return (result.intValue());
   }
View Full Code Here

         return (m_projectFile);
      }

      catch (ParserConfigurationException ex)
      {
         throw new MPXJException("Failed to parse file", ex);
      }

      catch (JAXBException ex)
      {
         throw new MPXJException("Failed to parse file", ex);
      }

      catch (SAXException ex)
      {
         throw new MPXJException("Failed to parse file", ex);
      }

      finally
      {
         m_projectFile = null;
View Full Code Here

         return (cal.getTime());
      }

      catch (ParseException ex)
      {
         throw new MPXJException("Failed to parse date-time " + value, ex);
      }
   }
View Full Code Here

         return (cal.getTime());
      }

      catch (ParseException ex)
      {
         throw new MPXJException("Failed to parse date " + value, ex);
      }
   }
View Full Code Here

         return (cal.getTime());
      }

      catch (ParseException ex)
      {
         throw new MPXJException("Failed to parse time " + value, ex);
      }
   }
View Full Code Here

         return (Duration.getInstance(duration, units));
      }

      catch (ParseException ex)
      {
         throw new MPXJException("Failed to parse duration", ex);
      }
   }
View Full Code Here

         }
      }

      catch (IOException ex)
      {
         throw new MPXJException(MPXJException.INVALID_RECORD, ex);
      }
   }
View Full Code Here

TOP

Related Classes of net.sf.mpxj.MPXJException

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.