code: public static Shortcode parse(final String shortcode) throws ParseException {
        String exp = shortcode.trim();
  
        if(exp.length() < 3) {
           throw new ParseException(String.format("Invalid shortcode ('%s')", exp), 0);
        }
  
        if(exp.charAt(0) != '[') {
           throw new ParseException("Expecting '['", 0);
        }
  
        int end = exp.indexOf(']');
        if(end == -1) {
           throw new ParseException("Expecting ']", 0);
        }
  
        Shortcode startTag = ShortcodeParser.parseStart(exp.substring(0, end + 1));
  
        end = exp.lastIndexOf("[/");
        if(end > 0) {
           if(exp.endsWith("[/" + startTag.name + "]")) {
              int start = shortcode.indexOf("]");
              return startTag.withContent(exp.substring(start + 1, end));
           } else {
              throw new ParseException("Invalid shortcode end", 0);
           }
        } else {
           return startTag;
        }
     }
docs: Parses a shortcode
  @param shortcode The shortcode string.
  @return The parsed shortcode.
  @throws ParseException on invalid code.