Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/atlassian/sitemesh2 into …
…atlassian Conflicts: src/java/com/opensymphony/sitemesh/webapp/decorator/BaseWebAppDecorator.java
- Loading branch information
Showing
77 changed files
with
1,844 additions
and
674 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
build | ||
target | ||
out | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ compile.nowarn = off | |
|
||
Name = OpenSymphony SiteMesh | ||
name = sitemesh | ||
version = 2.4.2 | ||
version = 2.5-atlassian-5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<!-- | ||
ant clean test | ||
ant clean jar sources | ||
mvn deploy:deploy-file -Dfile=./dist/sitemesh-2.5-atlassian-5.jar -DpomFile=./pom.xml -Durl=https://maven.atlassian.com/public -DrepositoryId=atlassian-public | ||
mvn deploy:deploy-file -Dfile=./dist/sitemesh-2.5-atlassian-5-sources.jar -DpomFile=./pom.xml -Dclassifier=sources -Durl=https://maven.atlassian.com/public -DrepositoryId=atlassian-public | ||
--> | ||
|
||
<groupId>opensymphony</groupId> | ||
<artifactId>sitemesh</artifactId> | ||
<version>2.5-atlassian-5</version> | ||
|
||
<packaging>jar</packaging> | ||
<name>SiteMesh</name> | ||
<description>Atlassian's fork of SiteMesh</description> | ||
<url>https://github.com/atlassian/sitemesh2</url> | ||
|
||
|
||
</project> |
137 changes: 137 additions & 0 deletions
137
src/java/com/opensymphony/module/sitemesh/DefaultSitemeshBuffer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
package com.opensymphony.module.sitemesh; | ||
|
||
import java.io.IOException; | ||
import java.io.Writer; | ||
import java.util.*; | ||
|
||
/** | ||
* The default implementation of sitemesh buffer | ||
*/ | ||
public class DefaultSitemeshBuffer implements SitemeshBuffer { | ||
|
||
private final char[] buffer; | ||
private final int length; | ||
private final TreeMap<Integer, SitemeshBufferFragment> bufferFragments; | ||
|
||
public DefaultSitemeshBuffer(char[] buffer) { | ||
this(buffer, buffer.length); | ||
} | ||
|
||
public DefaultSitemeshBuffer(char[] buffer, int length) { | ||
this(buffer, length, new TreeMap<Integer, SitemeshBufferFragment>()); | ||
} | ||
|
||
public DefaultSitemeshBuffer(char[] buffer, int length, TreeMap<Integer, SitemeshBufferFragment> bufferFragments) { | ||
this.buffer = buffer; | ||
this.length = length; | ||
this.bufferFragments = bufferFragments; | ||
} | ||
|
||
public void writeTo(Writer writer, int start, int length) throws IOException { | ||
int pos = start; | ||
for (Map.Entry<Integer, SitemeshBufferFragment> entry : bufferFragments.entrySet()) { | ||
int fragmentPosition = entry.getKey(); | ||
if (fragmentPosition < pos) { | ||
continue; | ||
} | ||
if (fragmentPosition > start + length) { | ||
break; | ||
} | ||
// Write the buffer up to the fragment | ||
writer.write(buffer, pos, fragmentPosition - pos); | ||
// Write the fragment | ||
entry.getValue().writeTo(writer); | ||
// increment pos | ||
pos = fragmentPosition; | ||
} | ||
// Write out the remaining buffer | ||
if (pos < start + length) { | ||
writer.write(buffer, pos, (start + length) - pos); | ||
} | ||
} | ||
|
||
public int getTotalLength() { | ||
return getTotalLength(0, length); | ||
} | ||
|
||
public int getTotalLength(int start, int length) { | ||
int total = length; | ||
|
||
for (Map.Entry<Integer, SitemeshBufferFragment> entry : bufferFragments.entrySet()) { | ||
int fragmentPosition = entry.getKey(); | ||
if (fragmentPosition < start) { | ||
continue; | ||
} | ||
if (fragmentPosition > start + length) { | ||
break; | ||
} | ||
total += entry.getValue().getTotalLength(); | ||
} | ||
return total; | ||
} | ||
|
||
public int getBufferLength() { | ||
return length; | ||
} | ||
|
||
public char[] getCharArray() { | ||
return buffer; | ||
} | ||
|
||
public boolean hasFragments() { | ||
return !bufferFragments.isEmpty(); | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static Builder builder(SitemeshBuffer sitemeshBuffer) { | ||
if (sitemeshBuffer instanceof DefaultSitemeshBuffer) { | ||
return new Builder((DefaultSitemeshBuffer) sitemeshBuffer); | ||
} else { | ||
return new Builder(sitemeshBuffer); | ||
} | ||
} | ||
|
||
public static class Builder { | ||
private char[] buffer; | ||
private int length; | ||
private final TreeMap<Integer, SitemeshBufferFragment> fragments; | ||
|
||
private Builder() { | ||
this.fragments = new TreeMap<Integer, SitemeshBufferFragment>(); | ||
} | ||
|
||
private Builder(DefaultSitemeshBuffer buffer) { | ||
this.buffer = buffer.buffer; | ||
this.length = buffer.length; | ||
this.fragments = new TreeMap<Integer, SitemeshBufferFragment>(buffer.bufferFragments); | ||
} | ||
|
||
private Builder(SitemeshBuffer buffer) { | ||
this.buffer = buffer.getCharArray(); | ||
this.length = buffer.getBufferLength(); | ||
this.fragments = new TreeMap<Integer, SitemeshBufferFragment>(); | ||
} | ||
|
||
public Builder setBuffer(char[] buffer) { | ||
this.buffer = buffer; | ||
return this; | ||
} | ||
|
||
public Builder setLength(int length) { | ||
this.length = length; | ||
return this; | ||
} | ||
|
||
public Builder insert(int position, SitemeshBufferFragment fragment) { | ||
this.fragments.put(position, fragment); | ||
return this; | ||
} | ||
|
||
public SitemeshBuffer build() { | ||
return new DefaultSitemeshBuffer(buffer, length, fragments); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/java/com/opensymphony/module/sitemesh/SitemeshBuffer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.opensymphony.module.sitemesh; | ||
|
||
import java.io.IOException; | ||
import java.io.Writer; | ||
|
||
/** | ||
* A potentially chained sitemesh buffer | ||
*/ | ||
public interface SitemeshBuffer { | ||
|
||
/** | ||
* Get the char array for this buffer. This array may be longer than the length of the content, you must use | ||
* getBufferLength() in combination with this method. | ||
* | ||
* @return The char array for this buffer | ||
*/ | ||
char[] getCharArray(); | ||
|
||
/** | ||
* Get the length of the buffered content. | ||
* | ||
* @return The length of the buffered content. | ||
*/ | ||
int getBufferLength(); | ||
|
||
/** | ||
* Get the total length of the buffered content, including the length of any chained buffers. | ||
* | ||
* @return The total length. | ||
*/ | ||
int getTotalLength(); | ||
|
||
/** | ||
* Get the total length of the buffered content, including chained buffers from start to length | ||
* | ||
* @param start Where to start counting the length from | ||
* @param length Where to finish | ||
* @return THe total length in the given range | ||
*/ | ||
int getTotalLength(int start, int length); | ||
|
||
/** | ||
* Write this buffer, and any chained sub buffers in the given range, out to the given writer | ||
* | ||
* @param start The position to start writing from | ||
* @param length The length to write | ||
* @param writer The writer to write to | ||
* @throws IOException If an error occurred | ||
*/ | ||
void writeTo(Writer writer, int start, int length) throws IOException; | ||
|
||
/** | ||
* Whether the buffer has fragments or not | ||
* | ||
* @return True if it has fragments | ||
*/ | ||
boolean hasFragments(); | ||
} |
Oops, something went wrong.