當前位置: 首頁>>代碼示例>>Java>>正文


Java SingleError類代碼示例

本文整理匯總了Java中com.helger.commons.error.SingleError的典型用法代碼示例。如果您正苦於以下問題:Java SingleError類的具體用法?Java SingleError怎麽用?Java SingleError使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SingleError類屬於com.helger.commons.error包,在下文中一共展示了SingleError類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testSerialize

import com.helger.commons.error.SingleError; //導入依賴的package包/類
@Test
public void testSerialize ()
{
  final ErrorList aList = new ErrorList ();
  CommonsTestHelper.testDefaultSerialization (aList);

  aList.add (SingleError.builderInfo ()
                        .setErrorID ("test-1")
                        .setErrorFieldName ("field1")
                        .setErrorText ("TestInfo")
                        .setErrorLocation (new SimpleLocation ("here.xml", 17, 3))
                        .build ());
  CommonsTestHelper.testDefaultSerialization (aList);

  aList.add (SingleError.builderInfo ()
                        .setErrorID ("test-2")
                        .setErrorFieldName ("field1")
                        .setErrorText ("TestInfo")
                        .setErrorLocation (new SimpleLocation ("here.xml", 17, 3))
                        .setLinkedException (new MockIOException ("Mock"))
                        .build ());
  CommonsTestHelper.testDefaultSerialization (aList);
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:24,代碼來源:ErrorListTest.java

示例2: handle

import com.helger.commons.error.SingleError; //導入依賴的package包/類
@Override
protected void handle (@Nullable final IReadableResource aRes,
                       @Nonnull final IErrorLevel aErrorLevel,
                       @Nullable final IPSElement aSourceElement,
                       @Nonnull final String sMessage,
                       @Nullable final Throwable t)
{
  final SingleErrorBuilder aBuilder = SingleError.builder ()
                                                 .setErrorLevel (aErrorLevel)
                                                 .setErrorLocation (aRes == null ? null
                                                                                 : new SimpleLocation (aRes.getResourceID ()))
                                                 .setErrorText (sMessage)
                                                 .setLinkedException (t);

  if (aSourceElement != null)
  {
    String sField = ClassHelper.getClassLocalName (aSourceElement);
    if (aSourceElement instanceof IPSHasID && ((IPSHasID) aSourceElement).hasID ())
      sField += " [ID=" + ((IPSHasID) aSourceElement).getID () + "]";
    aBuilder.setErrorFieldName (sField);
  }
  m_aErrorList.add (aBuilder.build ());
}
 
開發者ID:phax,項目名稱:ph-schematron,代碼行數:24,代碼來源:AbstractCollectingPSErrorHandler.java

示例3: getAsError

import com.helger.commons.error.SingleError; //導入依賴的package包/類
@Nonnull
default IError getAsError (@Nonnull final Locale aContentLocale)
{
  return SingleError.builder ()
                    .setErrorLevel (getSeverity ().getErrorLevel ())
                    .setErrorID (getErrorCode ())
                    .setErrorText ("[" +
                                   getCategory ().getDisplayName () +
                                   "] " +
                                   StringHelper.getNotNull (getErrorDetail ().getDisplayText (aContentLocale),
                                                            getShortDescription ()))
                    .build ();
}
 
開發者ID:phax,項目名稱:ph-as4,代碼行數:14,代碼來源:IEbmsError.java

示例4: handleEvent

import com.helger.commons.error.SingleError; //導入依賴的package包/類
public final boolean handleEvent (@Nonnull final ValidationEvent aEvent)
{
  final IErrorLevel aErrorLevel = getErrorLevel (aEvent.getSeverity ());
  final SingleErrorBuilder aErrBuilder = SingleError.builder ().setErrorLevel (aErrorLevel);

  final ValidationEventLocator aLocator = aEvent.getLocator ();
  aErrBuilder.setErrorLocation (new SimpleLocation (getLocationResourceID (aLocator),
                                                   aLocator != null ? aLocator.getLineNumber ()
                                                                    : ILocation.ILLEGAL_NUMBER,
                                                   aLocator != null ? aLocator.getColumnNumber ()
                                                                    : ILocation.ILLEGAL_NUMBER))
             .setErrorFieldName (getErrorFieldName (aLocator));

  // Message may be null in some cases (e.g. when a linked exception is
  // present), but is not allowed to be null!
  String sMsg = aEvent.getMessage ();
  if (sMsg == null)
  {
    if (aEvent.getLinkedException () != null)
    {
      sMsg = aEvent.getLinkedException ().getMessage ();
      if (sMsg == null)
        sMsg = "Exception";
    }
    else
    {
      // Does this ever happen????
      sMsg = "Validation event";
    }
  }
  aErrBuilder.setErrorText (sMsg).setLinkedException (aEvent.getLinkedException ());

  // call our callback
  onEvent (aErrBuilder.build ());

  // Continue processing?
  return continueProcessing (aErrorLevel);
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:39,代碼來源:AbstractValidationEventHandler.java

示例5: _buildError

import com.helger.commons.error.SingleError; //導入依賴的package包/類
@Nonnull
private static IError _buildError (@Nonnull final TransformerException ex,
                                   @Nonnull final IErrorLevel aErrorLevel,
                                   @Nonnull final IMultilingualText aErrorMsg)
{
  final ILocation aLocation = SimpleLocation.create (ex.getLocator ());
  return SingleError.builder ()
                    .setErrorLevel (aErrorLevel)
                    .setErrorLocation (aLocation)
                    .setErrorText (aErrorMsg)
                    .setLinkedException (ex)
                    .build ();
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:14,代碼來源:AbstractTransformErrorListener.java

示例6: getSaxParseError

import com.helger.commons.error.SingleError; //導入依賴的package包/類
/**
 * Utility method to convert a {@link SAXParseException} into an
 * {@link IError}.
 *
 * @param aErrorLevel
 *        The occurred error level. May not be <code>null</code>.
 * @param ex
 *        The exception to convert. May not be <code>null</code>.
 * @return The {@link IError} representation. Never <code>null</code>.
 */
@Nonnull
public static IError getSaxParseError (@Nonnull final IErrorLevel aErrorLevel, @Nonnull final SAXParseException ex)
{
  return SingleError.builder ()
                    .setErrorLevel (aErrorLevel)
                    .setErrorLocation (SimpleLocation.create (ex))
                    .setErrorText ("[SAX] " + ex.getMessage ())
                    .setLinkedException (ex)
                    .build ();
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:21,代碼來源:AbstractSAXErrorHandler.java

示例7: testField

import com.helger.commons.error.SingleError; //導入依賴的package包/類
@Test
public void testField ()
{
  final ErrorList aFEL = new ErrorList ();
  assertTrue (aFEL.isEmpty ());
  assertFalse (aFEL.containsAtLeastOneWarningOrError ());
  assertEquals (EErrorLevel.SUCCESS, aFEL.getMostSevereErrorLevel ());

  aFEL.add (SingleError.builderInfo ().setErrorFieldName ("f1").setErrorText ("info").build ());
  assertFalse (aFEL.isEmpty ());
  assertFalse (aFEL.containsAtLeastOneWarningOrError ());
  assertEquals (EErrorLevel.INFO, aFEL.getMostSevereErrorLevel ());

  aFEL.add (SingleError.builderError ().setErrorFieldName ("f2").setErrorText ("error").build ());
  assertFalse (aFEL.isEmpty ());
  assertTrue (aFEL.containsAtLeastOneWarningOrError ());
  assertEquals (EErrorLevel.ERROR, aFEL.getMostSevereErrorLevel ());

  assertNotNull (aFEL.getListOfField ("f1"));
  assertFalse (aFEL.getListOfField ("f1").isEmpty ());
  assertNotNull (aFEL.getListOfField ("f1-gibtsned"));
  assertTrue (aFEL.getListOfField ("f1-gibtsned").isEmpty ());

  assertTrue (aFEL.removeAll ().isChanged ());
  assertFalse (aFEL.removeAll ().isChanged ());

  assertTrue (aFEL.isEmpty ());
  assertFalse (aFEL.containsAtLeastOneWarningOrError ());
  assertEquals (EErrorLevel.SUCCESS, aFEL.getMostSevereErrorLevel ());
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:31,代碼來源:ErrorListTest.java

示例8: _createError

import com.helger.commons.error.SingleError; //導入依賴的package包/類
@Nonnull
private static IError _createError (@Nonnull final String sMsg)
{
  return SingleError.builderError ().setErrorText (sMsg).build ();
}
 
開發者ID:phax,項目名稱:ph-as4,代碼行數:6,代碼來源:ESENSCompatibilityValidator.java

示例9: createError

import com.helger.commons.error.SingleError; //導入依賴的package包/類
@Nonnull
public static SingleError createError (@Nonnull final String sErrorText)
{
  return SingleError.builderError ().setErrorText (sErrorText).build ();
}
 
開發者ID:phax,項目名稱:ph-as4,代碼行數:6,代碼來源:AS4IOHelper.java


注:本文中的com.helger.commons.error.SingleError類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。