added another "virtual member"
authorjohn <john>
Thu, 18 Apr 2002 08:58:57 +0000 (08:58 +0000)
committerjohn <john>
Thu, 18 Apr 2002 08:58:57 +0000 (08:58 +0000)
to content entities, this one does some easy string manipulation
to return content.description_sentence, the first sentence of the description
with all html tags stripped.  used for RSS right now.  works analogously to
content.description_parsed

source/mircoders/entity/EntityContent.java

index eedd1f9..2033fb6 100755 (executable)
@@ -152,6 +152,8 @@ public class EntityContent extends Entity
                }
       else if (field.equals("description_parsed"))
         returnField = getDescriptionParsed();
+      else if (field.equals("description_sentence"))
+        returnField = getDescriptionSentence();
       else if (field.equals("content_data_parsed"))
         returnField = getContentDataParsed();
       else
@@ -279,6 +281,17 @@ public class EntityContent extends Entity
     return returnField;
   }
 
+  private String getDescriptionSentence() {
+    String returnField = getValue("description");
+    if (returnField != null && returnField.length()>0) {
+       returnField = StringUtil.removeHTMLTags(returnField);
+       int endOfFirstSentence=StringUtil.findEndOfSentence(returnField,0);
+       if (endOfFirstSentence > 0){
+        returnField = returnField.substring(0,endOfFirstSentence);
+       }
+    }
+    return returnField;
+  }
 
   private String getDescriptionParsed() {
     String returnField = getValue("description");