Search in sources :

Example 11 with CommentOperation

use of com.google.security.zynamics.binnavi.disassembly.CommentManager.CommentOperation in project binnavi by google.

the class PostgreSQLCommentNotificationParser method processTextNodeCommentNotification.

/**
   * Parses the {@link PGNotification} notifications from the PostgreSQL database back end for text
   * node comments by using a regular expression. If the regular expression matches the supplied
   * {@link PGNotification} notification, it is determined if the text node in the notification is
   * currently loaded, and if a {@link CommentNotificationContainer} with the gathered data from the
   * notification is returned.
   *
   * @param notification The {@link PGNotification} from the PostgreSQL database server.
   * @param provider The {@link SQLProvider} which is used to communicate with the database.
   */
static CommentNotification processTextNodeCommentNotification(final PGNotification notification, final SQLProvider provider) {
    final Matcher matcher = TEXT_NODE_PATTERN.matcher(notification.getParameter());
    if (!matcher.find()) {
        return null;
    }
    final Integer nodeId = Integer.parseInt(matcher.group(3));
    final Integer commentId = matcher.group(4).equals("null") ? null : Integer.parseInt(matcher.group(4));
    final INaviTextNode node = (INaviTextNode) NodeCache.get(provider).getNodeById(nodeId);
    if (node == null) {
        return null;
    }
    final CommentOperation operation = commentId == null ? CommentOperation.DELETE : CommentOperation.APPEND;
    return new TextNodeCommentNotificationContainer(node, operation, commentId);
}
Also used : BigInteger(java.math.BigInteger) CommentOperation(com.google.security.zynamics.binnavi.disassembly.CommentManager.CommentOperation) Matcher(java.util.regex.Matcher) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) TextNodeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.TextNodeCommentNotificationContainer)

Example 12 with CommentOperation

use of com.google.security.zynamics.binnavi.disassembly.CommentManager.CommentOperation in project binnavi by google.

the class PostgreSQLCommentNotificationParser method processEdgeLocalCommentNotification.

/**
   * Parses the notifications from the database back end for local edge comments by using a regular
   * expression. If the regular expression matches the supplied {@link PGNotification} notification,
   * it is determined if the edge in question is loaded, and if a
   * {@link CommentNotificationContainer} is build with the data from the notification.
   *
   * @param notification The {@link PGNotification} from the PostgreSQL database server.
   * @param provider The {@link SQLProvider} which is used to communicate with the database.
   */
static CommentNotification processEdgeLocalCommentNotification(final PGNotification notification, final SQLProvider provider) {
    final Matcher matcher = EDGE_LOCAL_PATTERN.matcher(notification.getParameter());
    if (!matcher.find()) {
        return null;
    }
    final Integer edgeId = Integer.parseInt(matcher.group(3));
    final Integer commentId = matcher.group(4).equals("null") ? null : Integer.parseInt(matcher.group(4));
    final INaviEdge edge = EdgeCache.get(provider).getEdgeById(edgeId);
    if (edge == null) {
        return null;
    }
    final CommentOperation operation = commentId == null ? CommentOperation.DELETE : CommentOperation.APPEND;
    return new EdgeCommentNotificationContainer(edge, operation, CommentScope.LOCAL, commentId);
}
Also used : BigInteger(java.math.BigInteger) CommentOperation(com.google.security.zynamics.binnavi.disassembly.CommentManager.CommentOperation) EdgeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.EdgeCommentNotificationContainer) Matcher(java.util.regex.Matcher) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge)

Aggregations

CommentOperation (com.google.security.zynamics.binnavi.disassembly.CommentManager.CommentOperation)12 BigInteger (java.math.BigInteger)12 Matcher (java.util.regex.Matcher)12 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)8 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)5 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)5 CodeNodeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.CodeNodeCommentNotificationContainer)3 EdgeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.EdgeCommentNotificationContainer)3 InstructionCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.InstructionCommentNotificationContainer)3 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)3 FunctionCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionCommentNotificationContainer)2 FunctionNodeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNodeCommentNotificationContainer)2 GroupNodeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.GroupNodeCommentNotificationContainer)2 TextNodeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.TextNodeCommentNotificationContainer)2 TypeInstanceCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.TypeInstanceCommentNotificationContainer)2 CommentNotification (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification)2 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)2 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)2 ArrayList (java.util.ArrayList)2 CommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.CommentNotificationContainer)1