001/*
002 * JPPF.
003 * Copyright (C) 2005-2018 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.jppf.management.diagnostics;
020
021import java.io.Serializable;
022
023/**
024 * nformation about a frame in a thread stack trace.
025 * @author Laurent Cohen
026 */
027public class StackFrameInformation implements Serializable {
028  /**
029   * Explicit serialVersionUID.
030   */
031  private static final long serialVersionUID = 1L;
032  /**
033   * The stack trace element.
034   */
035  private final StackTraceElement stackTraceElement;
036  /**
037   * The associated lock, if any.
038   */
039  private final LockInformation lock;
040
041  /**
042   * Create this object with the specified parameters.
043   * @param stackTraceElement the stack trace element.
044   * @param lock the associated lock, may be null if none exists.
045   */
046  public StackFrameInformation(final StackTraceElement stackTraceElement, final LockInformation lock) {
047    super();
048    this.stackTraceElement = stackTraceElement;
049    this.lock = lock;
050  }
051
052  /**
053   * Get the stack trace element.
054   * @return a {@link StackTraceElement} instance.
055   */
056  public StackTraceElement getStackTraceElement() {
057    return stackTraceElement;
058  }
059
060  /**
061   * Get the associated lock.
062   * @return a {@link LockInformation} instance, or <code>null</code> if no lock is associated with the frame.
063   */
064  public LockInformation getLock() {
065    return lock;
066  }
067
068  @Override
069  public String toString() {
070    /* return new StringBuilder().append(getClass().getSimpleName()).append("[stackTraceElement=").append(stackTraceElement)
071     * .append(", lock=").append(lock).append(']').toString(); */
072    return new StringBuilder().append(stackTraceElement).toString();
073  }
074}