Home /Modules/slrtp/SLRTPPointcut.sleela

SLRTPPointcut.sleela

lib/slrtp/SLRTPPointcut.sleela · 93 line(s) · sleela

<< lib/slrtp/SLRTPPointcut.sleela
   SLeeLa Standard Library Definition.
   Definition: An SLRTP pointcut -- a predicate that selects the join points an
   advice applies to, akin to a Java/AspectJ pointcut expression. It matches a
   join point on three independent fields: target type, method name, and phase.
   Each field is either an exact string or the universal wildcard "*" (match
   any). Matching uses only string equality, so it is exact and portable; it
   does not attempt substring or regex matching the primitive String type here
   cannot perform. >>
#sleela 3.0
material;
class SLRTPPointcut {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
     or catalog can read and (where appropriate) override this record.
     Values are faithful to the subject's real origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 0;
  String metaAuthor = "Max Rupplin";
  String metaDate = "2026-11-06";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "MEARVK LLC";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-11-06";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 7;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }

  << The three selection fields. "*" matches any value for that field. The
     default (all "*") is a catch-all pointcut that selects every join point. >>
  String typePattern = "*";
  String methodPattern = "*";
  String phasePattern = "*";

  << Configure the pointcut. phase accepts "*", "before", "afterReturning",
     "afterThrowing", or "around". >>
  void select(String type, String method, String phaseLabel) {
    typePattern = type;
    methodPattern = method;
    phasePattern = phaseLabel;
  }

  String getTypePattern() { return typePattern; }
  String getMethodPattern() { return methodPattern; }
  String getPhasePattern() { return phasePattern; }

  << One field matches when the pattern is the wildcard or equals the value. >>
  boolean fieldMatches(String pattern, String value) {
    if (pattern == "*") { return true; }
    return pattern == value;
  }

  << True when this pointcut selects the given join point: all three fields
     match. The phase is compared by its label so pointcuts read naturally. >>
  boolean matches(SLRTPJoinPoint jp) {
    if (!fieldMatches(typePattern, jp.getTypeName())) { return false; }
    if (!fieldMatches(methodPattern, jp.getMethodName())) { return false; }
    if (!fieldMatches(phasePattern, jp.phaseName())) { return false; }
    return true;
  }

  << A readable rendering, e.g. "pay.* @around". >>
  String describe() {
    return typePattern + "." + methodPattern + " @" + phasePattern;
  }
}