All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.st.p2012.mind.adl.parser.CommentProcessor Maven / Gradle / Ivy

The newest version!
/**
 \file com/st/p2012/mind/parser/CommentProcessor.java
 \brief A class to clean up comment strings.


 
 \n
 This file is part of the Platform 2012 program,
 a cooperation between STMicroelectronics and CEA.\n
 Redistribution of this file to outside parties is
 strictly prohibited without the written consent
 of the module owner indicated below.\n
 

 \par  Module owner: [email protected]


 \par  Copyright (C) 2009 STMicroelectronics

 \par  Authors: [email protected]

 \par  Id: $Id$
 \par  Date: $Date$
 \par  Revision: $Rev$

 */

package com.st.p2012.mind.adl.parser;

public final class CommentProcessor {

  public final static String processComment(String commentString) {
    commentString = commentString.trim();
    if(commentString.startsWith("/**") && commentString.endsWith("*/")) {
      String result = commentString.substring(3);
      result = result.substring(0, result.length() - 2);
      final String lines[] = result.split("\n");
      for (int i = 0; i < lines.length; i++) {
        String l = lines[i].trim();
        if (l.startsWith("*")) {
          l = l.substring(1);
        }
        lines[i] = l.trim();
      }
      final StringBuilder sb = new StringBuilder();
      for (final String string : lines) {
        sb.append(string);
        sb.append('\n');
      }
      return sb.toString();
    } else {
      return null;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy