• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IReadableResource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: read

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
/**
 * Read a document from the specified resource. The secure reading feature has
 * affect when using this method.
 *
 * @param aResource
 *        The resource to read. May not be <code>null</code>.
 * @return <code>null</code> in case reading fails.
 */
@Nullable
default JAXBTYPE read (@Nonnull final IReadableResource aResource)
{
  ValueEnforcer.notNull (aResource, "Resource");

  // Ensure to use InputStream for BOM handling
  return read (aResource.getInputStream ());
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:17,代码来源:IJAXBReader.java


示例17: getAllXSDResources

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
/**
 * @return The resources from which the XSD can be read using the current
 *         class loader. Never <code>null</code> but maybe empty.
 */
@Nonnull
@ReturnsMutableCopy
default ICommonsList <? extends IReadableResource> getAllXSDResources ()
{
  return new CommonsArrayList <> (getAllXSDPaths (), ClassPathResource::new);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:11,代码来源:IJAXBDocumentType.java


示例18: build

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
@Nonnull
public ConfigFile build ()
{
  if (m_aPaths.isEmpty ())
    throw new IllegalStateException ("No config file path was provided!");

  IReadableResource aRes = null;
  ISettings aSettings = null;
  for (final String sConfigPath : m_aPaths)
  {
    // Support reading?
    if (m_aResProvider.supportsReading (sConfigPath))
    {
      // Convert to resource
      aRes = m_aResProvider.getReadableResource (sConfigPath);
      if (aRes != null)
      {
        // Open stream
        final InputStream aIS = aRes.getInputStream ();
        if (aIS != null)
        {
          // Read settings
          aSettings = m_aSPP.readSettings (aIS);
          if (aSettings != null)
            break;
        }
      }
    }
  }

  if (aSettings == null)
    s_aLogger.warn ("Failed to resolve config file paths: " + m_aPaths);

  return new ConfigFile (aSettings != null ? aRes : null, aSettings);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:36,代码来源:ConfigFileBuilder.java


示例19: error

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
public final void error (@Nullable final IReadableResource aRes,
                         @Nullable final IPSElement aSourceElement,
                         @Nonnull final String sMessage,
                         @Nullable final Throwable t)
{
  handle (aRes, EErrorLevel.ERROR, aSourceElement, sMessage, t);

  // Do we have a nested error handler?
  final IPSErrorHandler aNestedErrorHandler = getNestedErrorHandler ();
  if (aNestedErrorHandler != null)
    aNestedErrorHandler.error (aRes, aSourceElement, sMessage, t);
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:13,代码来源:AbstractPSErrorHandler.java


示例20: getAllInvalidSchematronFiles

import com.helger.commons.io.resource.IReadableResource; //导入依赖的package包/类
@Nonnull
@Nonempty
public static ICommonsList <IReadableResource> getAllInvalidSchematronFiles ()
{
  return s_aSCHs.getAllMapped (aFile -> aFile.getFileBaseName ().startsWith ("invalid") &&
                                        !aFile.getParentDirBaseName ().equals ("include"),
                               SchematronTestFile::getResource);
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:9,代码来源:SchematronTestHelper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ProtectionElement类代码示例发布时间:2022-05-22
下一篇:
Java GPUImageToonFilter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap