当前位置: 首页>>代码示例>>Java>>正文


Java IReadableResource类代码示例

本文整理汇总了Java中com.helger.commons.io.resource.IReadableResource的典型用法代码示例。如果您正苦于以下问题:Java IReadableResource类的具体用法?Java IReadableResource怎么用?Java IReadableResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IReadableResource类属于com.helger.commons.io.resource包,在下文中一共展示了IReadableResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CryptoProperties

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
public CryptoProperties (@Nonnull final IReadableResource aRes)
{
  ValueEnforcer.notNull (aRes, "Resource");
  if (aRes.exists ())
    try
    {
      m_aProps = new NonBlockingProperties ();
      try (final InputStream aIS = aRes.getInputStream ())
      {
        m_aProps.load (aIS);
      }
    }
    catch (final Throwable t)
    {
      throw new InitializationException ("Failed to init CryptoProperties from resource " + aRes + "!", t);
    }
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:18,代码来源:CryptoProperties.java

示例2: testAll

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
@Test
public void testAll ()
{
  for (final EUBL20DocumentType e : EUBL20DocumentType.values ())
  {
    assertNotNull (e.getImplementationClass ());
    assertTrue (StringHelper.hasText (e.getLocalName ()));
    assertTrue (StringHelper.hasText (e.getNamespaceURI ()));
    assertTrue (e.getAllXSDPaths ().size () >= 1);
    for (final IReadableResource aRes : e.getAllXSDResources ())
      assertTrue (e.name (), aRes.exists ());
    assertNotNull (e.getSchema ());
    assertSame (e.getSchema (), e.getSchema ());
    assertSame (e, EUBL20DocumentType.valueOf (e.name ()));
  }
}
 
开发者ID:phax,项目名称:ph-ubl,代码行数:17,代码来源:EUBL20DocumentTypeTest.java

示例3: testBindAllInvalidSchematrons

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
@Test
public void testBindAllInvalidSchematrons ()
{
  for (final IReadableResource aRes : SchematronTestHelper.getAllInvalidSchematronFiles ())
  {
    System.out.println (aRes);
    try
    {
      // Parse the schema
      final PSSchema aSchema = new PSReader (aRes).readSchema ();
      final CollectingPSErrorHandler aCEH = new CollectingPSErrorHandler ();
      PSXPathQueryBinding.getInstance ().bind (aSchema, null, aCEH);
      // Either an ERROR was collected or an exception was thrown
      assertTrue (aCEH.getErrorList ().getMostSevereErrorLevel ().isGE (EErrorLevel.ERROR));
    }
    catch (final SchematronException ex)
    {
      System.out.println ("  " + ex.getMessage ());
    }
  }
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:22,代码来源:PSXPathBoundSchemaTest.java

示例4: testBindAllValidSchematrons

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
@Test
public void testBindAllValidSchematrons () throws SchematronException
{
  for (final IReadableResource aRes : SchematronTestHelper.getAllValidSchematronFiles ())
  {
    // Parse the schema
    final PSSchema aSchema = new PSReader (aRes).readSchema ();
    assertNotNull (aSchema);
    CommonsTestHelper.testToStringImplementation (aSchema);

    final CollectingPSErrorHandler aLogger = new CollectingPSErrorHandler ();
    assertTrue (aRes.getPath (), aSchema.isValid (aLogger));
    assertTrue (aLogger.isEmpty ());

    // Create a compiled schema
    final String sPhaseID = null;
    final IPSErrorHandler aErrorHandler = null;
    final IPSBoundSchema aBoundSchema = PSXPathQueryBinding.getInstance ().bind (aSchema, sPhaseID, aErrorHandler);
    assertNotNull (aBoundSchema);
  }
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:22,代码来源:PSXPathBoundSchemaTest.java

示例5: testIssue

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
@Test
public void testIssue ()
{
  // Multiple errors contained
  final IReadableResource aRes = new ClassPathResource ("testfiles/css30/bad_but_browsercompliant/issue19.css");
  assertTrue (aRes.exists ());
  final CascadingStyleSheet aCSS = CSSReader.readFromStream (aRes,
                                                             new CSSReaderSettings ().setFallbackCharset (StandardCharsets.UTF_8)
                                                                                     .setCSSVersion (ECSSVersion.CSS30)
                                                                                     .setCustomErrorHandler (new LoggingCSSParseErrorHandler ())
                                                                                     .setBrowserCompliantMode (true));
  assertNotNull (aCSS);
  if (false)
    System.out.println (new CSSWriter (ECSSVersion.CSS30).getCSSAsString (aCSS));
  assertEquals (1, aCSS.getRuleCount ());
  assertEquals (1, aCSS.getStyleRuleCount ());
}
 
开发者ID:phax,项目名称:ph-css,代码行数:18,代码来源:Issue19Test.java

示例6: create

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
@Nullable
public static InputSource create (@Nonnull final IReadableResource aResource)
{
  if (aResource instanceof FileSystemResource)
  {
    final File aFile = aResource.getAsFile ();
    if (aFile != null)
    {
      // Potentially use memory mapped files
      final InputSource ret = create (FileHelper.getInputStream (aFile));
      if (ret != null)
      {
        // Ensure system ID is present - may be helpful for resource
        // resolution
        final URL aURL = aResource.getAsURL ();
        if (aURL != null)
          ret.setSystemId (aURL.toExternalForm ());
      }
      return ret;
    }
  }
  return new ReadableResourceSAXInputSource (aResource);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:24,代码来源:InputSourceFactory.java

示例7: testAll

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
@Test
public void testAll ()
{
  for (final EUBLTRDocumentType e : EUBLTRDocumentType.values ())
  {
    assertNotNull (e.getImplementationClass ());
    assertTrue (StringHelper.hasText (e.getLocalName ()));
    assertTrue (StringHelper.hasText (e.getNamespaceURI ()));
    assertTrue (e.getAllXSDPaths ().size () >= 1);
    for (final IReadableResource aRes : e.getAllXSDResources ())
      assertTrue (e.name (), aRes.exists ());
    assertNotNull (e.getSchema ());
    assertSame (e.getSchema (), e.getSchema ());
    assertSame (e, EUBLTRDocumentType.valueOf (e.name ()));
  }
}
 
开发者ID:phax,项目名称:ph-ubl,代码行数:17,代码来源:EUBLTRDocumentTypeTest.java

示例8: clearCachedSize

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
/**
 * Remove a single resource from the cache.
 *
 * @param aRes
 *        The resource to be removed. May be <code>null</code>.
 * @return Never <code>null</code>.
 */
@Nonnull
public EChange clearCachedSize (@Nullable final IReadableResource aRes)
{
  if (aRes == null)
    return EChange.UNCHANGED;

  return m_aRWLock.writeLocked ( () -> {
    // Existing resource?
    if (m_aImageData.remove (aRes) != null)
      return EChange.CHANGED;

    // Non-existing resource?
    if (m_aNonExistingResources.remove (aRes))
      return EChange.CHANGED;

    return EChange.UNCHANGED;
  });
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:26,代码来源:ImageDataManager.java

示例9: testIssue

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
@Test
public void testIssue ()
{
  // Multiple errors contained
  final IReadableResource aRes = new ClassPathResource ("testfiles/css30/good/issue21.css");
  assertTrue (aRes.exists ());
  final CascadingStyleSheet aCSS = CSSReader.readFromStream (aRes,
                                                             new CSSReaderSettings ().setFallbackCharset (StandardCharsets.UTF_8)
                                                                                     .setCustomErrorHandler (new LoggingCSSParseErrorHandler ())
                                                                                     .setBrowserCompliantMode (true));
  assertNotNull (aCSS);
  if (false)
    System.out.println (new CSSWriter (ECSSVersion.CSS30).getCSSAsString (aCSS));
  assertEquals (2, aCSS.getRuleCount ());
  assertEquals (2, aCSS.getStyleRuleCount ());
}
 
开发者ID:phax,项目名称:ph-css,代码行数:17,代码来源:Issue21Test.java

示例10: _readWordList

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
private static ICommonsList <String> _readWordList (final IReadableResource aRes,
                                                    final Charset aCharset) throws IOException
{
  final ICommonsList <String> ret = new CommonsArrayList<> ();
  final NonBlockingBufferedReader aBR = new NonBlockingBufferedReader (new InputStreamReader (aRes.getInputStream (),
                                                                                              aCharset));
  String sLine;
  int nIdx = 0;
  while ((sLine = aBR.readLine ()) != null)
  {
    nIdx++;
    if ((nIdx % 3) == 0)
    {
      ret.add (sLine);
      if (ret.size () >= 100)
        break;
    }
  }
  StreamHelper.close (aBR);
  return ret;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:22,代码来源:BenchmarkLevenshteinDistance.java

示例11: isValidCSS

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
/**
 * Check if the passed CSS resource can be parsed without error
 *
 * @param aRes
 *        The resource to be parsed. May not be <code>null</code>.
 * @param aFallbackCharset
 *        The charset to be used for reading the CSS file in case neither a
 *        <code>@charset</code> rule nor a BOM is present. May not be
 *        <code>null</code>.
 * @param eVersion
 *        The CSS version to be used for scanning. May not be
 *        <code>null</code>.
 * @return <code>true</code> if the file can be parsed without error,
 *         <code>false</code> if not
 */
public static boolean isValidCSS (@Nonnull final IReadableResource aRes,
                                  @Nonnull final Charset aFallbackCharset,
                                  @Nonnull final ECSSVersion eVersion)
{
  ValueEnforcer.notNull (aRes, "Resource");
  ValueEnforcer.notNull (aFallbackCharset, "FallbackCharset");
  ValueEnforcer.notNull (eVersion, "Version");

  final Reader aReader = aRes.getReader (aFallbackCharset);
  if (aReader == null)
  {
    s_aLogger.warn ("Failed to open CSS reader " + aRes);
    return false;
  }
  return isValidCSS (aReader, eVersion);
}
 
开发者ID:phax,项目名称:ph-css,代码行数:32,代码来源:CSSReader.java

示例12: testAll

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
@Test
public void testAll ()
{
  for (final EUBL21DocumentType e : EUBL21DocumentType.values ())
  {
    assertNotNull (e.getImplementationClass ());
    assertTrue (StringHelper.hasText (e.getLocalName ()));
    assertTrue (StringHelper.hasText (e.getNamespaceURI ()));
    assertTrue (e.getAllXSDPaths ().size () >= 1);
    for (final IReadableResource aRes : e.getAllXSDResources ())
      assertTrue (e.name (), aRes.exists ());
    assertNotNull (e.getSchema ());
    assertSame (e.getSchema (), e.getSchema ());
    assertSame (e, EUBL21DocumentType.valueOf (e.name ()));
  }
}
 
开发者ID:phax,项目名称:ph-ubl,代码行数:17,代码来源:EUBL21DocumentTypeTest.java

示例13: testIssue8

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
@Test
public void testIssue8 ()
{
  final IReadableResource aRes = new ClassPathResource ("testfiles/css30/good/issue8.css");
  assertTrue (aRes.exists ());
  final CascadingStyleSheet aCSS = CSSReader.readFromStream (aRes,
                                                             StandardCharsets.UTF_8,
                                                             ECSSVersion.CSS30,
                                                             new LoggingCSSParseErrorHandler ());
  assertNotNull (aCSS);

  assertEquals (1, aCSS.getStyleRuleCount ());
  final CSSStyleRule aStyleRule = aCSS.getStyleRuleAtIndex (0);
  assertNotNull (aStyleRule);

  assertEquals (4, aStyleRule.getDeclarationCount ());
}
 
开发者ID:phax,项目名称:ph-css,代码行数:18,代码来源:Issue8Test.java

示例14: testReadAll

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
@Test
public void testReadAll () throws Exception
{
  final PSWriter aWriter = new PSWriter ();

  for (final IReadableResource aRes : SchematronTestHelper.getAllValidSchematronFiles ())
  {
    // Parse the schema
    final PSSchema aSchema1 = new PSReader (aRes).readSchema ();
    assertNotNull (aSchema1);
    final CollectingPSErrorHandler aLogger = new CollectingPSErrorHandler ();
    assertTrue (aRes.getPath (), aSchema1.isValid (aLogger));
    assertTrue (aLogger.isEmpty ());

    // Convert back to XML
    final String sXML1 = aWriter.getXMLStringNotNull (aSchema1);

    // Re-read the created XML and re-create it
    final PSSchema aSchema2 = new PSReader (new ReadableResourceString (sXML1, StandardCharsets.UTF_8)).readSchema ();
    final String sXML2 = aWriter.getXMLStringNotNull (aSchema2);

    // Originally created XML and re-created-written XML must match
    assertEquals (sXML1, sXML2);
  }
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:26,代码来源:PSWriterTest.java

示例15: AppPageViewExternal

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
public AppPageViewExternal (@Nonnull @Nonempty final String sID,
                            @Nonnull final String sName,
                            @Nonnull final IReadableResource aResource)
{
  // Special content cleaner
  super (sID, sName, aResource, AppPageViewExternal::_cleanCode);
}
 
开发者ID:phax,项目名称:peppol-directory,代码行数:8,代码来源:AppPageViewExternal.java


注:本文中的com.helger.commons.io.resource.IReadableResource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。