Examples of GenericConverter


Examples of de.ddb.conversion.GenericConverter

    final static Format B = new Format("B");

    public void testGetConverter() throws ConverterException {
        ConverterRegistry registry = new ConverterRegistry();

        Converter anyEncConverter = new GenericConverter(){
         
          // A, B, null, null
          {
            getConverterContext().setSourceFormat(A);
            getConverterContext().setTargetFormat(B);
            getConverterContext().setSourceEncoding(null);
            getConverterContext().setTargetEncoding(null);
          }

      public void convert(InputStream in, OutputStream out,
          ConversionParameters params) throws ConverterException,
          IOException
      {
        // TODO Auto-generated method stub
       
      }

      public void convert(Reader in, Writer out,
          ConversionParameters params) throws ConverterException,
          IOException
      {
        // TODO Auto-generated method stub
       
      }
         
        };
       
        Converter anySourceEncConverter = new GenericConverter(){
         
//          A, B, null, "UTF-8"
          {
            getConverterContext().setSourceFormat(A);
            getConverterContext().setTargetFormat(B);
            getConverterContext().setSourceEncoding(null);
            getConverterContext().setTargetEncoding("UTF-8");
          }

      public void convert(InputStream in, OutputStream out,
          ConversionParameters params) throws ConverterException,
          IOException
      {
        // TODO Auto-generated method stub
       
      }

      public void convert(Reader in, Writer out,
          ConversionParameters params) throws ConverterException,
          IOException
      {
        // TODO Auto-generated method stub
       
      }
         
        };
        Converter anyTargetEncConverter = new GenericConverter(){
         
//          A, B, "UTF-8", null
          {
            getConverterContext().setSourceFormat(A);
            getConverterContext().setTargetFormat(B);
            getConverterContext().setSourceEncoding("UTF-8");
            getConverterContext().setTargetEncoding(null);
          }

      public void convert(InputStream in, OutputStream out,
          ConversionParameters params) throws ConverterException,
          IOException
      {
        // TODO Auto-generated method stub
       
      }

      public void convert(Reader in, Writer out,
          ConversionParameters params) throws ConverterException,
          IOException
      {
        // TODO Auto-generated method stub
       
      }
         
        };
        Converter specifiedEncConverter = new GenericConverter(){
         
//          A, B, "UTF-8", "UTF-8"
          {
            getConverterContext().setSourceFormat(A);
            getConverterContext().setTargetFormat(B);
View Full Code Here

Examples of de.ddb.conversion.GenericConverter

            if (in != null)
                in.close();
        }

       
        GenericConverter converter = new MabToMabxmlConverter();
        converter.getConverterContext().setSourceFormat(new Format("MAB2"));
        converter.getConverterContext().setTargetFormat(new Format("MABxml-1"));
        LOGGER.info("Start conversion...\n");
        List<byte[]> records = converter.convertToList(byteArray
                .toByteArray(), "x-MAB", "UTF-8");
        for (byte[] buf : records)
        {
            LOGGER.info(buf);
        }
View Full Code Here

Examples of org.soybeanMilk.core.bean.GenericConverter

  @Test
  public void parse_genericConverter_noClassAttr() throws Exception
  {
    config=new ConfigurationParser().parse("org/soybeanMilk/test/unit/core/TestConfigurationParser-genericConverter-noClassAttr.xml");
   
    GenericConverter gc=config.getGenericConverter();
   
    Assert.assertEquals(DefaultGenericConverter.class, gc.getClass());
    Assert.assertEquals(TestConverter.class, gc.getConverter(String.class, int.class).getClass());
    Assert.assertEquals(TestConverter.class, gc.getConverter(String.class, float.class).getClass());
  }
View Full Code Here

Examples of org.soybeanMilk.core.bean.GenericConverter

  @Test
  public void parse_genericConverter_hasClassAttr() throws Exception
  {
    config=new ConfigurationParser().parse("org/soybeanMilk/test/unit/core/TestConfigurationParser-genericConverter-hasClassAttr.xml");
   
    GenericConverter gc=config.getGenericConverter();
   
    Assert.assertEquals(MyGenericConverter.class, gc.getClass());
  }
View Full Code Here

Examples of org.soybeanMilk.core.bean.GenericConverter

  protected Object convertGotObject(Object sourceObj, Type targetType) throws ObjectSourceException
  {
    if(targetType==null)
      return sourceObj;
   
    GenericConverter converter=getGenericConverter();
   
    if(converter == null)
      return sourceObj;
    else
    {
View Full Code Here

Examples of org.soybeanMilk.core.bean.GenericConverter

  {
    Element cvtEl = getSingleElementByTagName(parent, TAG_GENERIC_CONVERTER);
   
    String clazz = cvtEl==null ? null : getAttributeValueIngoreEmpty(cvtEl, TAG_GENERIC_CONVERTER_ATTR_CLASS);
   
    GenericConverter genericConverter = configuration.getGenericConverter();
    if(genericConverter == null)
    {
      if(clazz==null || clazz.length()==0)
        genericConverter = createGenericConverterInstance();
      else
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

    Class<?> type = converter.getClass();
    boolean isWriting = type.isAnnotationPresent(WritingConverter.class);
    boolean isReading = type.isAnnotationPresent(ReadingConverter.class);

    if (converter instanceof GenericConverter) {
      GenericConverter genericConverter = (GenericConverter) converter;
      for (GenericConverter.ConvertiblePair pair : genericConverter.getConvertibleTypes()) {
        register(new ConverterRegistration(pair, isReading, isWriting));
      }
    } else if (converter instanceof Converter) {
      Class<?>[] arguments = GenericTypeResolver.resolveTypeArguments(converter.getClass(), Converter.class);
      register(new ConverterRegistration(arguments[0], arguments[1], isReading, isWriting));
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

  public boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
    Assert.notNull(targetType,"The targetType to convert to cannot be null");
    if (sourceType == null) {
      return true;
    }
    GenericConverter converter = getConverter(sourceType, targetType);
    return (converter != null);
  }
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

  public boolean canBypassConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
    Assert.notNull(targetType, "The targetType to convert to cannot be null");
    if (sourceType == null) {
      return true;
    }
    GenericConverter converter = getConverter(sourceType, targetType);
    return (converter == NO_OP_CONVERTER);
  }
View Full Code Here

Examples of org.springframework.core.convert.converter.GenericConverter

    }
    if (source != null && !sourceType.getObjectType().isInstance(source)) {
      throw new IllegalArgumentException("The source to convert from must be an instance of " +
          sourceType + "; instead it was a " + source.getClass().getName());
    }
    GenericConverter converter = getConverter(sourceType, targetType);
    if (converter != null) {
      Object result = ConversionUtils.invokeConverter(converter, source, sourceType, targetType);
      return handleResult(sourceType, targetType, result);
    }
    return handleConverterNotFound(source, sourceType, targetType);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.